summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp35
-rw-r--r--noncore/applets/pcmcia/pcmcia.h5
2 files changed, 39 insertions, 1 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 186dfea..0787c3c 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -57,55 +57,78 @@ using namespace Opie::Ui;
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
69PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) 69PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent )
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( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); 79 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
80 configuring = false; 80 configuring = false;
81
82 QCopChannel *channel = new QCopChannel( "QPE/System", this );
83 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
84 this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) );
81} 85}
82 86
83 87
84PcmciaManager::~PcmciaManager() 88PcmciaManager::~PcmciaManager()
85{ 89{
86} 90}
87 91
92void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& )
93{
94 if ( msg == "returnFromSuspend()" )
95 {
96 if ( !OPcmciaSystem::instance()->cardCount() ) return;
97 OPcmciaSystem* sys = OPcmciaSystem::instance();
98 OPcmciaSystem::CardIterator it = sys->iterator();
99 OPcmciaSocket* theCard = 0;
100
101 while ( it.current() )
102 {
103 if ( it.current()->isEmpty() )
104 {
105 executeResumeAction( theCard );
106 }
107 ++it;
108 }
109 }
110}
88 111
89void PcmciaManager::popUp( QString message, QString icon ) 112void PcmciaManager::popUp( QString message, QString icon )
90{ 113{
91 if ( !popupMenu ) { 114 if ( !popupMenu ) {
92 popupMenu = new QPopupMenu( this ); 115 popupMenu = new QPopupMenu( this );
93 } 116 }
94 117
95 popupMenu->clear(); 118 popupMenu->clear();
96 if ( icon.isEmpty() ) { 119 if ( icon.isEmpty() ) {
97 popupMenu->insertItem( message, 0 ); 120 popupMenu->insertItem( message, 0 );
98 } else { 121 } else {
99 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), 122 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ),
100 message, 0 ); 123 message, 0 );
101 } 124 }
102 125
103 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 126 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
104 QSize s = popupMenu->sizeHint(); 127 QSize s = popupMenu->sizeHint();
105 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 128 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
106 p.y() - s.height() ), 0 ); 129 p.y() - s.height() ), 0 );
107 130
108 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 131 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
109} 132}
110 133
111 134
@@ -176,48 +199,50 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
176 bool newCard = true; 199 bool newCard = true;
177 OPcmciaSocket* theCard = 0; 200 OPcmciaSocket* theCard = 0;
178 201
179 while ( it.current() && newCard ) 202 while ( it.current() && newCard )
180 { 203 {
181 if ( it.current()->isEmpty() ) 204 if ( it.current()->isEmpty() )
182 { 205 {
183 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; 206 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl;
184 ++it; 207 ++it;
185 continue; 208 continue;
186 } 209 }
187 else 210 else
188 { 211 {
189 theCard = it.current(); 212 theCard = it.current();
190 QString cardName = theCard->productIdentity().join( " " ); 213 QString cardName = theCard->productIdentity().join( " " );
191 for ( int i = 0; i < nCards; ++i ) 214 for ( int i = 0; i < nCards; ++i )
192 { 215 {
193 QString cardSection = QString( "Card_%1" ).arg( i ); 216 QString cardSection = QString( "Card_%1" ).arg( i );
194 cfg.setGroup( cardSection ); 217 cfg.setGroup( cardSection );
195 QString name = cfg.readEntry( "name" ); 218 QString name = cfg.readEntry( "name" );
196 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; 219 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
197 if ( cardName == name ) 220 if ( cardName == name )
198 { 221 {
199 newCard = false; 222 newCard = false;
223 odebug << "pcmcia: we have seen this card before" << oendl;
224 executeInsertAction( theCard );
200 break; 225 break;
201 } 226 }
202 } 227 }
203 if ( !newCard ) ++it; else break; 228 if ( !newCard ) ++it; else break;
204 } 229 }
205 } 230 }
206 if ( newCard ) 231 if ( newCard )
207 { 232 {
208 odebug << "pcmcia: unconfigured card detected" << oendl; 233 odebug << "pcmcia: unconfigured card detected" << oendl;
209 QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); 234 QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace();
210 int result = QMessageBox::information( qApp->desktop(), 235 int result = QMessageBox::information( qApp->desktop(),
211 tr( "PCMCIA/CF Subsystem" ), 236 tr( "PCMCIA/CF Subsystem" ),
212 tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), 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 ),
213 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 238 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
214 odebug << "pcmcia: result = " << result << oendl; 239 odebug << "pcmcia: result = " << result << oendl;
215 if ( result == 0 ) 240 if ( result == 0 )
216 { 241 {
217 QString insertAction; QString resumeAction; QString driver; QString conf; 242 QString insertAction; QString resumeAction; QString driver; QString conf;
218 bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); 243 bool configured = configure( theCard, insertAction, resumeAction, driver, conf );
219 244
220 if ( configured ) 245 if ( configured )
221 { 246 {
222 odebug << "pcmcia: card has been configured. writing out to database" << oendl; 247 odebug << "pcmcia: card has been configured. writing out to database" << oendl;
223 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); 248 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
@@ -323,27 +348,37 @@ void PcmciaManager::userCardAction( int action )
323 if ( !success ) 348 if ( !success )
324 { 349 {
325 owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; 350 owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl;
326 } 351 }
327 352
328} 353}
329 354
330bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) 355bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf )
331{ 356{
332 configuring = true; 357 configuring = true;
333 ConfigDialog dialog( card, qApp->desktop() ); 358 ConfigDialog dialog( card, qApp->desktop() );
334 int configresult = QPEApplication::execDialog( &dialog, false ); 359 int configresult = QPEApplication::execDialog( &dialog, false );
335 configuring = false; 360 configuring = false;
336 odebug << "pcmcia: configresult = " << configresult << oendl; 361 odebug << "pcmcia: configresult = " << configresult << oendl;
337 if ( configresult ) 362 if ( configresult )
338 { 363 {
339 insertAction = dialog.cbInsertAction->currentText(); 364 insertAction = dialog.cbInsertAction->currentText();
340 resumeAction = dialog.cbResumeAction->currentText(); 365 resumeAction = dialog.cbResumeAction->currentText();
341 driver = dialog.cbBindTo->currentText(); 366 driver = dialog.cbBindTo->currentText();
342 conf = dialog.bindEntries[driver]; 367 conf = dialog.bindEntries[driver];
343 } 368 }
344 return configresult; 369 return configresult;
345} 370}
346 371
372void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card )
373{
374 odebug << "pcmcia: execute insert action" << oendl;
375}
376
377void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card )
378{
379 odebug << "pcmcia: execute resume action" << oendl;
380}
381
347 382
348EXPORT_OPIE_APPLET_v1( PcmciaManager ) 383EXPORT_OPIE_APPLET_v1( PcmciaManager )
349 384
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index 94203d3..6567cd7 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -24,47 +24,50 @@
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
37namespace Opie { namespace Core { class OPcmciaSocket; } }; 37namespace Opie { namespace Core { class OPcmciaSocket; } };
38 38
39class PcmciaManager : public QWidget 39class 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 handleSystemChannel( const QCString&, const QByteArray& );
49 void cardMessage( const QCString&, const QByteArray& );
49 void userCardAction( int action ); 50 void userCardAction( int action );
50 void popupTimeout(); 51 void popupTimeout();
51 52
52 protected: 53 protected:
53 void paintEvent( QPaintEvent* ); 54 void paintEvent( QPaintEvent* );
54 void mousePressEvent( QMouseEvent * ); 55 void mousePressEvent( QMouseEvent * );
55 56
56 private: 57 private:
57 bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); 58 bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& );
58 void execCommand( const QStringList &command ); 59 void execCommand( const QStringList &command );
60 void executeInsertAction( Opie::Core::OPcmciaSocket* );
61 void executeResumeAction( Opie::Core::OPcmciaSocket* );
59 void popUp(QString message, QString icon = QString::null ); 62 void popUp(QString message, QString icon = QString::null );
60 63
61 private: 64 private:
62 bool configuring; 65 bool configuring;
63 int commandOrig; 66 int commandOrig;
64 QPixmap pm; 67 QPixmap pm;
65 QPopupMenu *popupMenu; 68 QPopupMenu *popupMenu;
66 69
67}; 70};
68 71
69#endif 72#endif
70 73