summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 0787c3c..e435f61 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -1,175 +1,175 @@
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>
44using namespace Opie::Core; 44using namespace Opie::Core;
45using namespace Opie::Ui; 45using 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
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( "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
88PcmciaManager::~PcmciaManager() 88PcmciaManager::~PcmciaManager()
89{ 89{
90} 90}
91 91
92void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) 92void 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; 99 OPcmciaSocket* theCard = 0;
100 100
101 while ( it.current() ) 101 while ( it.current() )
102 { 102 {
103 if ( it.current()->isEmpty() ) 103 if ( it.current()->isEmpty() )
104 { 104 {
105 executeResumeAction( theCard ); 105 executeResumeAction( theCard );
106 } 106 }
107 ++it; 107 ++it;
108 } 108 }
109 } 109 }
110} 110}
111 111
112void PcmciaManager::popUp( QString message, QString icon ) 112void PcmciaManager::popUp( QString message, QString icon )
113{ 113{
114 if ( !popupMenu ) { 114 if ( !popupMenu ) {
115 popupMenu = new QPopupMenu( this ); 115 popupMenu = new QPopupMenu( this );
116 } 116 }
117 117
118 popupMenu->clear(); 118 popupMenu->clear();
119 if ( icon.isEmpty() ) { 119 if ( icon.isEmpty() ) {
120 popupMenu->insertItem( message, 0 ); 120 popupMenu->insertItem( message, 0 );
121 } else { 121 } else {
122 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 ) ),
123 message, 0 ); 123 message, 0 );
124 } 124 }
125 125
126 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 126 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
127 QSize s = popupMenu->sizeHint(); 127 QSize s = popupMenu->sizeHint();
128 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 128 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
129 p.y() - s.height() ), 0 ); 129 p.y() - s.height() ), 0 );
130 130
131 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 131 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
132} 132}
133 133
134 134
135void PcmciaManager::popupTimeout() 135void PcmciaManager::popupTimeout()
136{ 136{
137 popupMenu->hide(); 137 popupMenu->hide();
138} 138}
139 139
140enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; 140enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE };
141 141
142void PcmciaManager::mousePressEvent( QMouseEvent* ) 142void PcmciaManager::mousePressEvent( QMouseEvent* )
143{ 143{
144 QPopupMenu* menu = new QPopupMenu( this ); 144 QPopupMenu* menu = new QPopupMenu( this );
145 QStringList cmd; 145 QStringList cmd;
146 bool execute = true; 146 bool execute = true;
147 147
148 OPcmciaSystem* sys = OPcmciaSystem::instance(); 148 OPcmciaSystem* sys = OPcmciaSystem::instance();
149 OPcmciaSystem::CardIterator it = sys->iterator(); 149 OPcmciaSystem::CardIterator it = sys->iterator();
150 if ( !sys->count() ) return; 150 if ( !sys->count() ) return;
151 151
152 int i = 0; 152 int i = 0;
153 while ( it.current() ) 153 while ( it.current() )
154 { 154 {
155 QPopupMenu* submenu = new QPopupMenu( menu ); 155 QPopupMenu* submenu = new QPopupMenu( menu );
156 submenu->insertItem( "&Eject", EJECT+i*100 ); 156 submenu->insertItem( "&Eject", EJECT+i*100 );
157 submenu->insertItem( "&Insert", INSERT+i*100 ); 157 submenu->insertItem( "&Insert", INSERT+i*100 );
158 submenu->insertItem( "&Suspend", SUSPEND+i*100 ); 158 submenu->insertItem( "&Suspend", SUSPEND+i*100 );
159 submenu->insertItem( "&Resume", RESUME+i*100 ); 159 submenu->insertItem( "&Resume", RESUME+i*100 );
160 submenu->insertItem( "Rese&t", RESET+i*100 ); 160 submenu->insertItem( "Rese&t", RESET+i*100 );
161 submenu->insertItem( "&Configure", CONFIGURE+i*100 ); 161 submenu->insertItem( "&Configure", CONFIGURE+i*100 );
162 162
163 submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); 163 submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() );
164 submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); 164 submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() );
165 submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); 165 submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() );
166 submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); 166 submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() );
167 submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); 167 submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring );
168 168
169 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); 169 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) );
170 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); 170 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 );
171 ++it; 171 ++it;
172 } 172 }
173 173
174 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 174 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
175 QSize s = menu->sizeHint(); 175 QSize s = menu->sizeHint();