summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/pcmcia.cpp249
-rw-r--r--core/applets/cardmon/pcmcia.h65
-rw-r--r--core/applets/cardmon/pcmcia.pro12
3 files changed, 0 insertions, 326 deletions
diff --git a/core/applets/cardmon/pcmcia.cpp b/core/applets/cardmon/pcmcia.cpp
deleted file mode 100644
index 5183572..0000000
--- a/core/applets/cardmon/pcmcia.cpp
+++ b/dev/null
@@ -1,249 +0,0 @@
1/*
2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l.
5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "pcmcia.h"
31
32/* OPIE */
33#include <opie2/odebug.h>
34#include <opie2/odevice.h>
35#include <opie2/oconfig.h>
36#include <opie2/oprocess.h>
37#include <opie2/opcmciasystem.h>
38#include <opie2/oresource.h>
39#include <opie2/otaskbarapplet.h>
40#include <qpe/applnk.h>
41#include <qpe/resource.h>
42using namespace Opie::Core;
43using namespace Opie::Ui;
44
45/* QT */
46#include <qcopchannel_qws.h>
47#include <qpainter.h>
48#include <qfile.h>
49#include <qtextstream.h>
50#include <qmessagebox.h>
51#include <qsound.h>
52#include <qtimer.h>
53
54/* STD */
55#include <stdio.h>
56#include <unistd.h>
57#include <stdlib.h>
58#include <string.h>
59#include <fcntl.h>
60#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
61#include <sys/vfs.h>
62#include <mntent.h>
63#endif
64
65PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent )
66{
67 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
68 connect( pcmciaChannel,
69 SIGNAL( received(const QCString&,const QByteArray&) ), this,
70 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
71
72 setFocusPolicy( NoFocus );
73 setFixedWidth ( AppLnk::smallIconSize() );
74 setFixedHeight ( AppLnk::smallIconSize() );
75 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
76}
77
78
79PcmciaManager::~PcmciaManager()
80{
81}
82
83
84void PcmciaManager::popUp( QString message, QString icon )
85{
86 if ( !popupMenu ) {
87 popupMenu = new QPopupMenu( this );
88 }
89
90 popupMenu->clear();
91 if ( icon.isEmpty() ) {
92 popupMenu->insertItem( message, 0 );
93 } else {
94 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ),
95 message, 0 );
96 }
97
98 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
99 QSize s = popupMenu->sizeHint();
100 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
101 p.y() - s.height() ), 0 );
102
103 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
104}
105
106
107void PcmciaManager::popupTimeout()
108{
109 popupMenu->hide();
110}
111
112
113void PcmciaManager::mousePressEvent( QMouseEvent* )
114{
115 QPopupMenu * menu = new QPopupMenu( this );
116 QStringList cmd;
117 bool execute = true;
118
119 OPcmciaSystem* sys = OPcmciaSystem::instance();
120 OPcmciaSystem::CardIterator it = sys->iterator();
121 if ( !sys->count() ) return;
122
123 int i = 0;
124 while ( it.current() )
125 {
126 menu->insertItem( tr( "Eject card %1: %2" ).arg( i++ ).arg( it.currentKey() ), 1 );
127 ++it;
128 }
129
130
131 /* insert items depending on number of cards etc.
132
133 if ( cardInSd ) {
134 menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ),
135 tr( "Eject SD/MMC card" ), 0 );
136 }
137
138
139
140 if ( cardInPcmcia0 ) {
141 menu->
142 insertItem( QIconSet
143 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ),
144 tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 );
145 }
146
147 if ( cardInPcmcia1 ) {
148 menu->
149 insertItem( QIconSet
150 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ),
151 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
152 }
153 */
154
155 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
156 QSize s = menu->sizeHint();
157 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 );
158 qDebug( "pcmcia: menu result = %d", opt );
159 delete menu;
160}
161
162
163void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
164{
165 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl;
166 if ( msg != "stabChanged()" ) return;
167
168 /* check if a previously unknown card has been inserted */
169 OPcmciaSystem::instance()->synchronize();
170
171 if ( !OPcmciaSystem::instance()->count() ) return;
172
173 OConfig cfg( "PCMCIA" );
174 cfg.setGroup( "Global" );
175 int nCards = cfg.readNumEntry( "nCards", 0 );
176
177 OPcmciaSystem* sys = OPcmciaSystem::instance();
178 OPcmciaSystem::CardIterator it = sys->iterator();
179
180 bool newCard = true;
181 while ( it.current() && newCard )
182 {
183 QString name = it.currentKey();
184 for ( int i = 0; i < nCards; ++i )
185 {
186 QString cardSection = QString( "Card_%1" ).arg( i );
187 cfg.setGroup( cardSection );
188 QString cardName = cfg.readEntry( "name" );
189 odebug << "comparing card '" << name << "' with known card '" << cardName << "'" << oendl;
190 if ( cardName == name )
191 {
192 newCard = false;
193 break;
194 }
195 }
196 if ( !newCard ) ++it; else break;
197 }
198 QString newCardName = it.currentKey();
199
200 if ( newCard )
201 {
202 odebug << "pcmcia: new card detected" << oendl;
203 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
204 cfg.writeEntry( "name", newCardName );
205 cfg.setGroup( "Global" );
206 cfg.writeEntry( "nCards", nCards+1 );
207 cfg.write();
208
209 int result = QMessageBox::information( qApp->desktop(),
210 tr( "PCMCIA/CF Subsystem" ),
211 tr( "You have inserted a new card\n%1\nDo you want to configure this card?" ).arg( newCardName ),
212 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
213 odebug << "result = " << result << oendl;
214
215 }
216 else
217 {
218 odebug << "pcmcia: card has been previously inserted" << oendl;
219 }
220 repaint( TRUE );
221}
222
223
224void PcmciaManager::paintEvent( QPaintEvent * )
225{
226 QPainter p( this );
227 qDebug( "count = %d", (OPcmciaSystem::instance()->count() ) );
228 if ( OPcmciaSystem::instance()->count() )
229 {
230 p.drawPixmap( 0, 0, pm );
231 show();
232 }
233 else
234 {
235 hide();
236 }
237}
238
239int PcmciaManager::position()
240{
241 return 7;
242}
243
244void PcmciaManager::execCommand( const QStringList &strList )
245{
246}
247
248EXPORT_OPIE_APPLET_v1( PcmciaManager )
249
diff --git a/core/applets/cardmon/pcmcia.h b/core/applets/cardmon/pcmcia.h
deleted file mode 100644
index 5c20433..0000000
--- a/core/applets/cardmon/pcmcia.h
+++ b/dev/null
@@ -1,65 +0,0 @@
1/*
2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l.
5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef PCMCIA_H
31#define PCMCIA_H
32
33#include <qwidget.h>
34#include <qpixmap.h>
35#include <qpopupmenu.h>
36
37class PcmciaManager : public QWidget
38{
39 Q_OBJECT
40 public:
41 PcmciaManager( QWidget *parent = 0 );
42 ~PcmciaManager();
43 static int position();
44
45 private slots:
46 void cardMessage( const QCString& msg, const QByteArray& );
47 void popupTimeout();
48
49 protected:
50 void paintEvent( QPaintEvent* );
51 void mousePressEvent( QMouseEvent * );
52
53 private:
54 void execCommand( const QStringList &command );
55 void popUp(QString message, QString icon = QString::null );
56
57 private:
58 int m_commandOrig;
59 QPixmap pm;
60 QPopupMenu *popupMenu;
61
62};
63
64#endif
65
diff --git a/core/applets/cardmon/pcmcia.pro b/core/applets/cardmon/pcmcia.pro
deleted file mode 100644
index c4f7b62..0000000
--- a/core/applets/cardmon/pcmcia.pro
+++ b/dev/null
@@ -1,12 +0,0 @@
1TEMPLATE = lib
2CONFIG += qt plugin warn_on
3HEADERS = pcmcia.h
4SOURCES = pcmcia.cpp
5TARGET = pcmciaapplet
6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopiecore2
10VERSION = 0.1.0
11
12include( $(OPIEDIR)/include.pro )