-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 10 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 98 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 5 |
3 files changed, 60 insertions, 53 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index f5812ba..f94edde 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -1,177 +1,179 @@ | |||
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 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 insertAction = preferredAction( card, "insert" ); | 54 | QString insertAction = preferredAction( card, "insert" ); |
55 | QString resumeAction = preferredAction( card, "resume" ); | 55 | QString resumeAction = preferredAction( card, "resume" ); |
56 | 56 | ||
57 | odebug << "pcmcia: preferred insertion action for card '" << card->name() << "' seems to be '" << insertAction << "'" << 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; | 58 | odebug << "pcmcia: preferred resume action for card '" << card->name() << "' seems to be '" << resumeAction << "'" << oendl; |
59 | 59 | ||
60 | if ( !insertAction.isEmpty() ) | 60 | if ( !insertAction.isEmpty() ) |
61 | { | 61 | { |
62 | for ( int i; i < cbInsertAction->count(); ++i ) | 62 | for ( int i; i < cbInsertAction->count(); ++i ) |
63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); | 63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); |
64 | } | 64 | } |
65 | 65 | ||
66 | if ( !resumeAction.isEmpty() ) | 66 | if ( !resumeAction.isEmpty() ) |
67 | { | 67 | { |
68 | for ( int i; i < cbResumeAction->count(); ++i ) | 68 | for ( int i; i < cbResumeAction->count(); ++i ) |
69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); | 69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); |
70 | } | 70 | } |
71 | 71 | ||
72 | if ( !card->isUnsupported() ) | 72 | if ( !card->isUnsupported() ) |
73 | { | 73 | { |
74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; | 74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; |
75 | textInfo->hide(); | 75 | textInfo->hide(); |
76 | textBindTo->hide(); | 76 | textBindTo->hide(); |
77 | cbBindTo->hide(); | 77 | cbBindTo->hide(); |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | else | 80 | else |
81 | { | 81 | { |
82 | odebug << "card is unsupported yet - showing possible bindings" << oendl; | 82 | odebug << "card is unsupported yet - showing possible bindings" << oendl; |
83 | textInfo->show(); | 83 | textInfo->show(); |
84 | textBindTo->show(); | 84 | textBindTo->show(); |
85 | cbBindTo->show(); | 85 | cbBindTo->show(); |
86 | } | 86 | } |
87 | 87 | ||
88 | // parse possible bind entries out of /etc/pcmcia/*.conf | 88 | // parse possible bind entries out of /etc/pcmcia/*.conf |
89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
90 | 90 | ||
91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) | 91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) |
92 | { | 92 | { |
93 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | 93 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; |
94 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | 94 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); |
95 | QFile conffile( conffilename ); | 95 | QFile conffile( conffilename ); |
96 | if ( conffile.open( IO_ReadOnly ) ) | 96 | if ( conffile.open( IO_ReadOnly ) ) |
97 | { | 97 | { |
98 | QTextStream ts( &conffile ); | 98 | QTextStream ts( &conffile ); |
99 | while ( !ts.atEnd() ) | 99 | while ( !ts.atEnd() ) |
100 | { | 100 | { |
101 | QString word; | 101 | QString word; |
102 | ts >> word; | 102 | ts >> word; |
103 | if ( word == "bind" ) | 103 | if ( word == "bind" ) |
104 | { | 104 | { |
105 | word = ts.readLine(); | 105 | word = ts.readLine(); |
106 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | 106 | bindEntries[ word.stripWhiteSpace() ] = conffilename; |
107 | continue; | 107 | continue; |
108 | } | 108 | } |
109 | ts.readLine(); | 109 | ts.readLine(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | else | 112 | else |
113 | { | 113 | { |
114 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; | 114 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; |
115 | continue; | 115 | continue; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) | 119 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) |
120 | { | 120 | { |
121 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; | 121 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; |
122 | cbBindTo->insertItem( it.key() ); | 122 | cbBindTo->insertItem( it.key() ); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | ConfigDialog::~ConfigDialog() | 126 | ConfigDialog::~ConfigDialog() |
127 | { | 127 | { |
128 | } | 128 | } |
129 | 129 | ||
130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) | 130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) |
131 | { | 131 | { |
132 | OConfig cfg( "PCMCIA" ); | 132 | OConfig cfg( "PCMCIA" ); |
133 | cfg.setGroup( "Global" ); | 133 | cfg.setGroup( "Global" ); |
134 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 134 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
135 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | ||
135 | QString action; | 136 | QString action; |
136 | 137 | ||
137 | for ( int i = 0; i < nCards; ++i ) | 138 | for ( int i = 0; i < nCards; ++i ) |
138 | { | 139 | { |
139 | QString cardSection = QString( "Card_%1" ).arg( i ); | 140 | QString cardSection = QString( "Card_%1" ).arg( i ); |
140 | cfg.setGroup( cardSection ); | 141 | cfg.setGroup( cardSection ); |
141 | QString name = cfg.readEntry( "name" ); | 142 | QString name = cfg.readEntry( "name" ); |
142 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 143 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
143 | if ( card->name() == name ) | 144 | if ( cardName == name ) |
144 | { | 145 | { |
145 | cfg.writeEntry( key, value ); | 146 | cfg.writeEntry( key, value ); |
146 | break; | 147 | break; |
147 | } | 148 | } |
148 | } | 149 | } |
149 | } | 150 | } |
150 | 151 | ||
151 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) | 152 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) |
152 | { | 153 | { |
153 | OConfig cfg( "PCMCIA" ); | 154 | OConfig cfg( "PCMCIA" ); |
154 | cfg.setGroup( "Global" ); | 155 | cfg.setGroup( "Global" ); |
155 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 156 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
157 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | ||
156 | QString value; | 158 | QString value; |
157 | 159 | ||
158 | for ( int i = 0; i < nCards; ++i ) | 160 | for ( int i = 0; i < nCards; ++i ) |
159 | { | 161 | { |
160 | QString cardSection = QString( "Card_%1" ).arg( i ); | 162 | QString cardSection = QString( "Card_%1" ).arg( i ); |
161 | cfg.setGroup( cardSection ); | 163 | cfg.setGroup( cardSection ); |
162 | QString name = cfg.readEntry( "name" ); | 164 | QString name = cfg.readEntry( "name" ); |
163 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 165 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
164 | if ( card->name() == name ) | 166 | if ( cardName == name ) |
165 | { | 167 | { |
166 | value = cfg.readEntry( key, defaultValue ); | 168 | value = cfg.readEntry( key, defaultValue ); |
167 | break; | 169 | break; |
168 | } | 170 | } |
169 | } | 171 | } |
170 | return value; | 172 | return value; |
171 | } | 173 | } |
172 | 174 | ||
173 | 175 | ||
174 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | 176 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) |
175 | { | 177 | { |
176 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | 178 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); |
177 | } | 179 | } |
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index e435f61..af23f58 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -1,384 +1,390 @@ | |||
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/global.h> |
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
45 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
46 | 46 | ||
47 | /* QT */ | 47 | /* QT */ |
48 | #include <qcombobox.h> | 48 | #include <qcombobox.h> |
49 | #include <qcopchannel_qws.h> | 49 | #include <qcopchannel_qws.h> |
50 | #include <qpainter.h> | 50 | #include <qpainter.h> |
51 | #include <qfile.h> | 51 | #include <qfile.h> |
52 | #include <qtextstream.h> | 52 | #include <qtextstream.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qsound.h> | 54 | #include <qsound.h> |
55 | #include <qtimer.h> | 55 | #include <qtimer.h> |
56 | 56 | ||
57 | /* STD */ | 57 | /* STD */ |
58 | #include <stdio.h> | 58 | #include <stdio.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 64 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
65 | #include <sys/vfs.h> | 65 | #include <sys/vfs.h> |
66 | #include <mntent.h> | 66 | #include <mntent.h> |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ), popupMenu( 0 ) |
70 | { | 70 | { |
71 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 71 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
72 | connect( pcmciaChannel, | 72 | connect( pcmciaChannel, |
73 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 73 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
74 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 74 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
75 | 75 | ||
76 | setFocusPolicy( NoFocus ); | 76 | setFocusPolicy( NoFocus ); |
77 | setFixedWidth ( AppLnk::smallIconSize() ); | 77 | setFixedWidth ( AppLnk::smallIconSize() ); |
78 | setFixedHeight ( AppLnk::smallIconSize() ); | 78 | setFixedHeight ( AppLnk::smallIconSize() ); |
79 | pm = Opie::Core::OResource::loadPixmap( "pcmcia/pcmcia", Opie::Core::OResource::SmallIcon ); | 79 | pm = Opie::Core::OResource::loadPixmap( "pcmcia/pcmcia", Opie::Core::OResource::SmallIcon ); |
80 | configuring = false; | 80 | configuring = false; |
81 | 81 | ||
82 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 82 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
83 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 83 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
84 | this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) ); | 84 | this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) ); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | PcmciaManager::~PcmciaManager() | 88 | PcmciaManager::~PcmciaManager() |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) | 92 | void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) |
93 | { | 93 | { |
94 | if ( msg == "returnFromSuspend()" ) | 94 | if ( msg == "returnFromSuspend()" ) |
95 | { | 95 | { |
96 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 96 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
97 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 97 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
98 | OPcmciaSystem::CardIterator it = sys->iterator(); | 98 | OPcmciaSystem::CardIterator it = sys->iterator(); |
99 | OPcmciaSocket* theCard = 0; | ||
100 | 99 | ||
101 | while ( it.current() ) | 100 | while ( it.current() ) |
102 | { | 101 | { |
103 | if ( it.current()->isEmpty() ) | 102 | if ( !it.current()->isEmpty() ) |
104 | { | 103 | { |
105 | executeResumeAction( theCard ); | 104 | executeAction( it.current(), "resume" ); |
106 | } | 105 | } |
107 | ++it; | 106 | ++it; |
108 | } | 107 | } |
109 | } | 108 | } |
110 | } | 109 | } |
111 | 110 | ||
112 | void PcmciaManager::popUp( QString message, QString icon ) | 111 | void PcmciaManager::popUp( QString message, QString icon ) |
113 | { | 112 | { |
114 | if ( !popupMenu ) { | 113 | if ( !popupMenu) |
114 | { | ||
115 | popupMenu = new QPopupMenu( this ); | 115 | popupMenu = new QPopupMenu( this ); |
116 | popupMenu->setFocusPolicy( QWidget::NoFocus ); | ||
116 | } | 117 | } |
117 | |||
118 | popupMenu->clear(); | 118 | popupMenu->clear(); |
119 | |||
119 | if ( icon.isEmpty() ) { | 120 | if ( icon.isEmpty() ) { |
120 | popupMenu->insertItem( message, 0 ); | 121 | popupMenu->insertItem( message, 0 ); |
121 | } else { | 122 | } else { |
122 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 123 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
123 | message, 0 ); | 124 | message, 0 ); |
124 | } | 125 | } |
125 | 126 | ||
126 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 127 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
127 | QSize s = popupMenu->sizeHint(); | 128 | QSize s = popupMenu->sizeHint(); |
128 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 129 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
129 | p.y() - s.height() ), 0 ); | 130 | p.y() - s.height() ), 0 ); |
130 | 131 | ||
131 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 132 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
132 | } | 133 | } |
133 | 134 | ||
134 | 135 | ||
135 | void PcmciaManager::popupTimeout() | 136 | void PcmciaManager::popupTimeout() |
136 | { | 137 | { |
137 | popupMenu->hide(); | 138 | popupMenu->hide(); |
138 | } | 139 | } |
139 | 140 | ||
140 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; | 141 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; |
142 | static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur" }; | ||
141 | 143 | ||
142 | void PcmciaManager::mousePressEvent( QMouseEvent* ) | 144 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
143 | { | 145 | { |
144 | QPopupMenu* menu = new QPopupMenu( this ); | 146 | QPopupMenu* menu = new QPopupMenu( this ); |
145 | QStringList cmd; | 147 | QStringList cmd; |
146 | bool execute = true; | 148 | bool execute = true; |
147 | 149 | ||
148 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 150 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
151 | sys->synchronize(); | ||
149 | OPcmciaSystem::CardIterator it = sys->iterator(); | 152 | OPcmciaSystem::CardIterator it = sys->iterator(); |
150 | if ( !sys->count() ) return; | 153 | if ( !sys->count() ) return; |
151 | 154 | ||
152 | int i = 0; | 155 | int i = 0; |
153 | while ( it.current() ) | 156 | while ( it.current() ) |
154 | { | 157 | { |
155 | QPopupMenu* submenu = new QPopupMenu( menu ); | 158 | QPopupMenu* submenu = new QPopupMenu( menu ); |
156 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 159 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
157 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 160 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
158 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 161 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
159 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 162 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
160 | submenu->insertItem( "Rese&t", RESET+i*100 ); | 163 | submenu->insertItem( "Rese&t", RESET+i*100 ); |
161 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 164 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
162 | 165 | ||
163 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 166 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
164 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 167 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
165 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 168 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
166 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 169 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
167 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); | 170 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); |
168 | 171 | ||
169 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 172 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
170 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 173 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
171 | ++it; | 174 | ++it; |
172 | } | 175 | } |
173 | 176 | ||
174 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 177 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
175 | QSize s = menu->sizeHint(); | 178 | QSize s = menu->sizeHint(); |
176 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 179 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
177 | qDebug( "pcmcia: menu result = %d", opt ); | 180 | qDebug( "pcmcia: menu result = %d", opt ); |
178 | delete menu; | 181 | delete menu; |
179 | } | 182 | } |
180 | 183 | ||
181 | 184 | ||
182 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 185 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
183 | { | 186 | { |
184 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; | 187 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
185 | if ( msg != "stabChanged()" ) return; | 188 | if ( msg != "stabChanged()" ) return; |
186 | 189 | ||
187 | /* check if a previously unknown card has been inserted */ | 190 | /* check if a previously unknown card has been inserted */ |
188 | OPcmciaSystem::instance()->synchronize(); | 191 | OPcmciaSystem::instance()->synchronize(); |
189 | 192 | ||
190 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 193 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
191 | 194 | ||
192 | OConfig cfg( "PCMCIA" ); | 195 | OConfig cfg( "PCMCIA" ); |
193 | cfg.setGroup( "Global" ); | 196 | cfg.setGroup( "Global" ); |
194 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 197 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
195 | 198 | ||
196 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 199 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
197 | OPcmciaSystem::CardIterator it = sys->iterator(); | 200 | OPcmciaSystem::CardIterator it = sys->iterator(); |
198 | 201 | ||
199 | bool newCard = true; | 202 | bool newCard = true; |
200 | OPcmciaSocket* theCard = 0; | 203 | OPcmciaSocket* theCard = 0; |
201 | 204 | ||
202 | while ( it.current() && newCard ) | 205 | while ( it.current() && newCard ) |
203 | { | 206 | { |
204 | if ( it.current()->isEmpty() ) | 207 | if ( it.current()->isEmpty() ) |
205 | { | 208 | { |
206 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; | 209 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; |
207 | ++it; | 210 | ++it; |
208 | continue; | 211 | continue; |
209 | } | 212 | } |
210 | else | 213 | else |
211 | { | 214 | { |
212 | theCard = it.current(); | 215 | theCard = it.current(); |
213 | QString cardName = theCard->productIdentity().join( " " ); | 216 | QString cardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
214 | for ( int i = 0; i < nCards; ++i ) | 217 | for ( int i = 0; i < nCards; ++i ) |
215 | { | 218 | { |
216 | QString cardSection = QString( "Card_%1" ).arg( i ); | 219 | QString cardSection = QString( "Card_%1" ).arg( i ); |
217 | cfg.setGroup( cardSection ); | 220 | cfg.setGroup( cardSection ); |
218 | QString name = cfg.readEntry( "name" ); | 221 | QString name = cfg.readEntry( "name" ); |
219 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 222 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
220 | if ( cardName == name ) | 223 | if ( cardName == name ) |
221 | { | 224 | { |
222 | newCard = false; | 225 | newCard = false; |
223 | odebug << "pcmcia: we have seen this card before" << oendl; | 226 | odebug << "pcmcia: we have seen this card before" << oendl; |
224 | executeInsertAction( theCard ); | 227 | executeAction( theCard, "insert" ); |
225 | break; | 228 | break; |
226 | } | 229 | } |
227 | } | 230 | } |
228 | if ( !newCard ) ++it; else break; | 231 | if ( !newCard ) ++it; else break; |
229 | } | 232 | } |
230 | } | 233 | } |
231 | if ( newCard ) | 234 | if ( newCard ) |
232 | { | 235 | { |
233 | odebug << "pcmcia: unconfigured card detected" << oendl; | 236 | odebug << "pcmcia: unconfigured card detected" << oendl; |
234 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); | 237 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
235 | int result = QMessageBox::information( qApp->desktop(), | 238 | int result = QMessageBox::information( qApp->desktop(), |
236 | tr( "PCMCIA/CF Subsystem" ), | 239 | tr( "PCMCIA/CF Subsystem" ), |
237 | 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 ), | 240 | 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 ), |
238 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 241 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
239 | odebug << "pcmcia: result = " << result << oendl; | 242 | odebug << "pcmcia: result = " << result << oendl; |
240 | if ( result == 0 ) | 243 | if ( result == 0 ) |
241 | { | 244 | { |
242 | QString insertAction; QString resumeAction; QString driver; QString conf; | 245 | QString insertAction; QString resumeAction; QString driver; QString conf; |
243 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); | 246 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); |
244 | 247 | ||
245 | if ( configured ) | 248 | if ( configured ) |
246 | { | 249 | { |
247 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; | 250 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; |
248 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | 251 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); |
249 | cfg.writeEntry( "name", newCardName ); | 252 | cfg.writeEntry( "name", newCardName ); |
250 | cfg.writeEntry( "insertAction", insertAction ); | 253 | cfg.writeEntry( "insertAction", insertAction ); |
251 | cfg.writeEntry( "resumeAction", resumeAction ); | 254 | cfg.writeEntry( "resumeAction", resumeAction ); |
252 | cfg.setGroup( "Global" ); | 255 | cfg.setGroup( "Global" ); |
253 | cfg.writeEntry( "nCards", nCards+1 ); | 256 | cfg.writeEntry( "nCards", nCards+1 ); |
254 | cfg.write(); | 257 | cfg.write(); |
255 | 258 | ||
256 | QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); | 259 | QFile confFile( conf ); |
257 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | 260 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) |
258 | { | 261 | { |
259 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | 262 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); |
260 | QString entryVersion( " version " ); | 263 | QString entryVersion( " version " ); |
261 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) | 264 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) |
262 | { | 265 | { |
263 | entryVersion += QString( "\"%1\", " ).arg( *it ); | 266 | entryVersion += QString( "\"%1\", " ).arg( *it ); |
264 | } | 267 | } |
265 | QString entryBind = QString( " bind %1" ).arg( driver ); | 268 | QString entryBind = QString( " bind %1" ).arg( driver ); |
266 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | 269 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); |
267 | odebug << "pcmcia: writing entry...:" << entry << oendl; | 270 | odebug << "pcmcia: writing entry...:" << entry << oendl; |
268 | 271 | ||
269 | confFile.writeBlock( (const char*) entry, entry.length() ); | 272 | confFile.writeBlock( (const char*) entry, entry.length() ); |
270 | Global::statusMessage( "restarting pcmcia services..." ); | 273 | Global::statusMessage( "restarting pcmcia services..." ); |
271 | ::system( "/etc/init.d/pcmcia restart" ); | 274 | ::system( "/etc/init.d/pcmcia restart" ); |
272 | } | 275 | } |
273 | else | 276 | else |
274 | { | 277 | { |
275 | owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; | 278 | owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl; |
276 | } | 279 | } |
277 | } | 280 | } |
278 | else | 281 | else |
279 | { | 282 | { |
280 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; | 283 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; |
281 | } | 284 | } |
282 | } | 285 | } |
283 | else | 286 | else |
284 | { | 287 | { |
285 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; | 288 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; |
286 | } | 289 | } |
287 | } | 290 | } |
288 | else // it's an already configured card | 291 | else // it's an already configured card |
289 | { | 292 | { |
290 | QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); | 293 | odebug << "pcmcia: doing nothing... why do we come here?" << oendl; |
291 | odebug << "pcmcia: card has been previously configured" << oendl; | ||
292 | odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl; | ||
293 | } | 294 | } |
294 | repaint( true ); | ||
295 | } | 295 | } |
296 | 296 | ||
297 | |||
298 | void PcmciaManager::paintEvent( QPaintEvent * ) | 297 | void PcmciaManager::paintEvent( QPaintEvent * ) |
299 | { | 298 | { |
300 | QPainter p( this ); | 299 | QPainter p( this ); |
301 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; | 300 | p.drawPixmap( 0, 0, pm ); |
302 | |||
303 | if ( OPcmciaSystem::instance()->cardCount() ) | ||
304 | { | ||
305 | p.drawPixmap( 0, 0, pm ); | ||
306 | show(); | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | hide(); | ||
311 | } | ||
312 | } | 301 | } |
313 | 302 | ||
314 | int PcmciaManager::position() | 303 | int PcmciaManager::position() |
315 | { | 304 | { |
316 | return 7; | 305 | return 7; |
317 | } | 306 | } |
318 | 307 | ||
319 | void PcmciaManager::execCommand( const QStringList &strList ) | 308 | void PcmciaManager::execCommand( const QStringList &strList ) |
320 | { | 309 | { |
321 | } | 310 | } |
322 | 311 | ||
323 | void PcmciaManager::userCardAction( int action ) | 312 | void PcmciaManager::userCardAction( int action ) |
324 | { | 313 | { |
325 | odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; | 314 | odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; |
326 | 315 | ||
327 | int socket = action / 100; | 316 | int socket = action / 100; |
328 | int what = action % 100; | 317 | int what = action % 100; |
329 | bool success = false; | 318 | bool success = false; |
330 | 319 | ||
331 | switch ( what ) | 320 | switch ( what ) |
332 | { | 321 | { |
333 | case CONFIGURE: | 322 | case CONFIGURE: |
334 | { | 323 | { |
335 | QString insertAction; QString resumeAction; QString driver; QString conf; | 324 | QString insertAction; QString resumeAction; QString driver; QString conf; |
336 | bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | 325 | configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); |
337 | success = true; | 326 | return; |
338 | break; | ||
339 | } | 327 | } |
340 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 328 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); |
341 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 329 | break; |
342 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 330 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); |
343 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 331 | break; |
344 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 332 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); |
345 | default: odebug << "pcmcia: not yet implemented" << oendl; | 333 | break; |
334 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); | ||
335 | break; | ||
336 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); | ||
337 | break; | ||
338 | default: odebug << "pcmcia: not yet implemented" << oendl; | ||
346 | } | 339 | } |
347 | 340 | ||
348 | if ( !success ) | 341 | if ( success ) |
349 | { | 342 | { |
350 | owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; | 343 | popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); |
344 | } | ||
345 | else | ||
346 | { | ||
347 | popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); | ||
351 | } | 348 | } |
352 | |||
353 | } | 349 | } |
354 | 350 | ||
355 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) | 351 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) |
356 | { | 352 | { |
357 | configuring = true; | 353 | configuring = true; |
358 | ConfigDialog dialog( card, qApp->desktop() ); | 354 | ConfigDialog dialog( card, qApp->desktop() ); |
359 | int configresult = QPEApplication::execDialog( &dialog, false ); | 355 | int configresult = QPEApplication::execDialog( &dialog, false ); |
360 | configuring = false; | 356 | configuring = false; |
361 | odebug << "pcmcia: configresult = " << configresult << oendl; | 357 | odebug << "pcmcia: configresult = " << configresult << oendl; |
362 | if ( configresult ) | 358 | if ( configresult ) |
363 | { | 359 | { |
364 | insertAction = dialog.cbInsertAction->currentText(); | 360 | insertAction = dialog.cbInsertAction->currentText(); |
365 | resumeAction = dialog.cbResumeAction->currentText(); | 361 | resumeAction = dialog.cbResumeAction->currentText(); |
366 | driver = dialog.cbBindTo->currentText(); | 362 | driver = dialog.cbBindTo->currentText(); |
367 | conf = dialog.bindEntries[driver]; | 363 | conf = dialog.bindEntries[driver]; |
368 | } | 364 | } |
369 | return configresult; | 365 | return configresult; |
370 | } | 366 | } |
371 | 367 | ||
372 | void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card ) | 368 | void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type ) |
373 | { | ||
374 | odebug << "pcmcia: execute insert action" << oendl; | ||
375 | } | ||
376 | |||
377 | void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card ) | ||
378 | { | 369 | { |
379 | odebug << "pcmcia: execute resume action" << oendl; | 370 | odebug << "pcmcia: performing " << type << " action ..." << oendl; |
371 | QString theAction = ConfigDialog::preferredAction( card, type ); | ||
372 | int intAction = card->number() * 100; | ||
373 | if ( theAction == "activate" ) ; | ||
374 | else if ( theAction == "eject" ) intAction += EJECT; | ||
375 | else if ( theAction == "suspend" ) intAction += SUSPEND; | ||
376 | else if ( theAction == "prompt for" ) | ||
377 | { | ||
378 | odebug << "pcmcia: sorry, not 'prompt for' is not yet implemented!" << oendl; | ||
379 | return; | ||
380 | } | ||
381 | else | ||
382 | { | ||
383 | owarn << "pcmcia: action '" << theAction << "' not known. Huh?" << oendl; | ||
384 | return; | ||
385 | } | ||
386 | userCardAction( intAction ); | ||
380 | } | 387 | } |
381 | 388 | ||
382 | |||
383 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 389 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
384 | 390 | ||
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h index 6567cd7..de7d6bf 100644 --- a/noncore/applets/pcmcia/pcmcia.h +++ b/noncore/applets/pcmcia/pcmcia.h | |||
@@ -1,73 +1,72 @@ | |||
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 handleSystemChannel( const QCString&, const QByteArray& ); | 48 | void handleSystemChannel( const QCString&, const QByteArray& ); |
49 | void cardMessage( const QCString&, const QByteArray& ); | 49 | void cardMessage( const QCString&, const QByteArray& ); |
50 | void userCardAction( int action ); | 50 | void userCardAction( int action ); |
51 | void popupTimeout(); | 51 | void popupTimeout(); |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | void paintEvent( QPaintEvent* ); | 54 | void paintEvent( QPaintEvent* ); |
55 | void mousePressEvent( QMouseEvent * ); | 55 | void mousePressEvent( QMouseEvent * ); |
56 | 56 | ||
57 | private: | 57 | private: |
58 | bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); | 58 | bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); |
59 | void execCommand( const QStringList &command ); | 59 | void execCommand( const QStringList &command ); |
60 | void executeInsertAction( Opie::Core::OPcmciaSocket* ); | 60 | void executeAction( Opie::Core::OPcmciaSocket*, const QString& ); |
61 | void executeResumeAction( Opie::Core::OPcmciaSocket* ); | 61 | void popUp( QString message, QString icon = QString::null ); |
62 | void popUp(QString message, QString icon = QString::null ); | ||
63 | 62 | ||
64 | private: | 63 | private: |
65 | bool configuring; | 64 | bool configuring; |
66 | int commandOrig; | 65 | int commandOrig; |
67 | QPixmap pm; | 66 | QPixmap pm; |
68 | QPopupMenu *popupMenu; | 67 | QPopupMenu *popupMenu; |
69 | 68 | ||
70 | }; | 69 | }; |
71 | 70 | ||
72 | #endif | 71 | #endif |
73 | 72 | ||