-rw-r--r-- | Rules.make | 1 | ||||
-rw-r--r-- | core/applets/cardmon/.cvsignore | 6 | ||||
-rw-r--r-- | core/applets/cardmon/config.in | 4 | ||||
-rw-r--r-- | core/applets/cardmon/pcmcia.cpp | 371 | ||||
-rw-r--r-- | core/applets/cardmon/pcmcia.h | 80 | ||||
-rw-r--r-- | core/applets/cardmon/pcmcia.pro | 12 | ||||
-rw-r--r-- | packages | 1 |
7 files changed, 472 insertions, 3 deletions
@@ -151,64 +151,65 @@ $(TOPDIR)/.depends.cfgs: | |||
151 | @echo $(configs) | sed -e 's,/config.in,,g' | ( for i in `cat`; do echo $$i; done ) > dirs | 151 | @echo $(configs) | sed -e 's,/config.in,,g' | ( for i in `cat`; do echo $$i; done ) > dirs |
152 | @cat dirs | ( for i in `cat`; do if [ "`cat dirs|grep $$i 2>/dev/null|wc -l`" -ne "1" ]; then deps=`cat dirs|grep $$i| grep -v "^$$i$$"|for i in \`cat|sed -e's,^$(TOPDIR)/,$$(TOPDIR)/,g'\`; do echo $$i/config.in; done`; echo `echo $$i/config.in|sed -e 's,^$(TOPDIR)/,$$(TOPDIR)/,'` : $$deps; fi; done ) >> $@ | 152 | @cat dirs | ( for i in `cat`; do if [ "`cat dirs|grep $$i 2>/dev/null|wc -l`" -ne "1" ]; then deps=`cat dirs|grep $$i| grep -v "^$$i$$"|for i in \`cat|sed -e's,^$(TOPDIR)/,$$(TOPDIR)/,g'\`; do echo $$i/config.in; done`; echo `echo $$i/config.in|sed -e 's,^$(TOPDIR)/,$$(TOPDIR)/,'` : $$deps; fi; done ) >> $@ |
153 | @-rm -f dirs | 153 | @-rm -f dirs |
154 | 154 | ||
155 | $(QTDIR)/stamp-headers : | 155 | $(QTDIR)/stamp-headers : |
156 | @-rm -f $(QTDIR)/stamp-headers* | 156 | @-rm -f $(QTDIR)/stamp-headers* |
157 | ( cd $(QTDIR)/include; \ | 157 | ( cd $(QTDIR)/include; \ |
158 | $(patsubst %,ln -sf ../src/kernel/%;,qgfx_qws.h qwsmouse_qws.h \ | 158 | $(patsubst %,ln -sf ../src/kernel/%;,qgfx_qws.h qwsmouse_qws.h \ |
159 | qcopchannel_qws.h qwindowsystem_qws.h \ | 159 | qcopchannel_qws.h qwindowsystem_qws.h \ |
160 | qfontmanager_qws.h qwsdefaultdecoration_qws.h)) | 160 | qfontmanager_qws.h qwsdefaultdecoration_qws.h)) |
161 | touch $@ | 161 | touch $@ |
162 | 162 | ||
163 | $(QTDIR)/stamp-headers-x11 : | 163 | $(QTDIR)/stamp-headers-x11 : |
164 | @-rm -f $(QTDIR)/stamp-headers* | 164 | @-rm -f $(QTDIR)/stamp-headers* |
165 | cd $(QTDIR)/include; $(patsubst %,ln -sf $(OPIEDIR)/x11/libqpe-x11/qt/%;,qgfx_qws.h qwsmouse_qws.h qcopchannel_qws.h qwindowsystem_qws.h qfontmanager_qws.h qwsdefaultdecoration_qws.h) | 165 | cd $(QTDIR)/include; $(patsubst %,ln -sf $(OPIEDIR)/x11/libqpe-x11/qt/%;,qgfx_qws.h qwsmouse_qws.h qcopchannel_qws.h qwindowsystem_qws.h qfontmanager_qws.h qwsdefaultdecoration_qws.h) |
166 | touch $@ | 166 | touch $@ |
167 | 167 | ||
168 | $(OPIEDIR)/stamp-headers : | 168 | $(OPIEDIR)/stamp-headers : |
169 | @-rm -f $(OPIEDIR)/stamp-headers* | 169 | @-rm -f $(OPIEDIR)/stamp-headers* |
170 | mkdir -p $(TOPDIR)/include/qpe \ | 170 | mkdir -p $(TOPDIR)/include/qpe \ |
171 | $(TOPDIR)/include/qtopia \ | 171 | $(TOPDIR)/include/qtopia \ |
172 | $(TOPDIR)/include/opie \ | 172 | $(TOPDIR)/include/opie \ |
173 | $(TOPDIR)/include/opie2 \ | 173 | $(TOPDIR)/include/opie2 \ |
174 | $(TOPDIR)/include/opie2/private \ | 174 | $(TOPDIR)/include/opie2/private \ |
175 | $(TOPDIR)/include/qtopia/private \ | 175 | $(TOPDIR)/include/qtopia/private \ |
176 | $(TOPDIR)/include/sl | 176 | $(TOPDIR)/include/sl |
177 | ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) | 177 | ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) |
178 | ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) | 178 | ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) |
179 | ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) | 179 | ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) |
180 | # libopie2 | 180 | # libopie2 |
181 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/*.h .; ) | 181 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/*.h .; ) |
182 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/device/*.h .; ) | 182 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/device/*.h .; ) |
183 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/linux/*.h .; ) | ||
183 | ( cd include/opie2 && ln -sf ../../libopie2/opiemm/*.h .; ) | 184 | ( cd include/opie2 && ln -sf ../../libopie2/opiemm/*.h .; ) |
184 | ( cd include/opie2 && ln -sf ../../libopie2/opiedb/*.h .; ) | 185 | ( cd include/opie2 && ln -sf ../../libopie2/opiedb/*.h .; ) |
185 | ( cd include/opie2 && ln -sf ../../libopie2/opienet/*.h .; ) | 186 | ( cd include/opie2 && ln -sf ../../libopie2/opienet/*.h .; ) |
186 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/*.h .; ) | 187 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/*.h .; ) |
187 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/core/*.h .; ) | 188 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/core/*.h .; ) |
188 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/backend/*.h .; ) | 189 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/backend/*.h .; ) |
189 | ( cd include/opie2/private && ln -sf ../../../libopie2/opiepim/private/*.h .; ) | 190 | ( cd include/opie2/private && ln -sf ../../../libopie2/opiepim/private/*.h .; ) |
190 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/ui/*.h .; ) | 191 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/ui/*.h .; ) |
191 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/*.h .; ) | 192 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/*.h .; ) |
192 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/fileselector/*.h .; ) | 193 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/fileselector/*.h .; ) |
193 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/big-screen/*.h .; ) | 194 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/big-screen/*.h .; ) |
194 | ( cd include/opie2 && ln -sf ../../libopie2/opiesecurity/*.h .; ) | 195 | ( cd include/opie2 && ln -sf ../../libopie2/opiesecurity/*.h .; ) |
195 | # auxilliary libraries | 196 | # auxilliary libraries |
196 | ( cd include/opie2 && ln -sf ../../libqtaux/*.h .; ) | 197 | ( cd include/opie2 && ln -sf ../../libqtaux/*.h .; ) |
197 | ( cd include/sl && ln -sf ../../libslcompat/*.h .; ) | 198 | ( cd include/sl && ln -sf ../../libslcompat/*.h .; ) |
198 | ( cd include/ && ln -sf ../noncore/net/ftplib/*.h .; ) | 199 | ( cd include/ && ln -sf ../noncore/net/ftplib/*.h .; ) |
199 | ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardcfg.h .; ) | 200 | ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardcfg.h .; ) |
200 | ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardpicks.h .; ) | 201 | ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardpicks.h .; ) |
201 | # all | 202 | # all |
202 | ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opieui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ | 203 | ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opieui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ |
203 | ln -sf ../../libopie2/opieui/$$generatedHeader $$generatedHeader; done ) | 204 | ln -sf ../../libopie2/opieui/$$generatedHeader $$generatedHeader; done ) |
204 | ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opiepim/ui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ | 205 | ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opiepim/ui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ |
205 | ln -sf ../../libopie2/opiepim/ui/$$generatedHeader $$generatedHeader; done ) | 206 | ln -sf ../../libopie2/opiepim/ui/$$generatedHeader $$generatedHeader; done ) |
206 | ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h | 207 | ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h |
207 | touch $@ | 208 | touch $@ |
208 | 209 | ||
209 | $(OPIEDIR)/stamp-headers-x11 : | 210 | $(OPIEDIR)/stamp-headers-x11 : |
210 | @-rm -f $(OPIEDIR)/stamp-headers* | 211 | @-rm -f $(OPIEDIR)/stamp-headers* |
211 | mkdir -p $(TOPDIR)/include/qpe \ | 212 | mkdir -p $(TOPDIR)/include/qpe \ |
212 | $(TOPDIR)/include/qtopia \ | 213 | $(TOPDIR)/include/qtopia \ |
213 | $(TOPDIR)/include/qtopia/private \ | 214 | $(TOPDIR)/include/qtopia/private \ |
214 | $(TOPDIR)/include/opie \ | 215 | $(TOPDIR)/include/opie \ |
diff --git a/core/applets/cardmon/.cvsignore b/core/applets/cardmon/.cvsignore index 37c45ac..d704947 100644 --- a/core/applets/cardmon/.cvsignore +++ b/core/applets/cardmon/.cvsignore | |||
@@ -1,5 +1,9 @@ | |||
1 | *.moc | 1 | *moc |
2 | *.~ | ||
2 | Makefile* | 3 | Makefile* |
3 | moc_* | 4 | moc_* |
5 | opieobj | ||
6 | obj | ||
7 | moc_ | ||
4 | .moc | 8 | .moc |
5 | .obj | 9 | .obj |
diff --git a/core/applets/cardmon/config.in b/core/applets/cardmon/config.in index 50a52b4..5f5af73 100644 --- a/core/applets/cardmon/config.in +++ b/core/applets/cardmon/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config CARDMON | 1 | config PCMCIA-APPLET |
2 | boolean "opie-cardmon (monitor cf/sd/mmc card status, and eject function)" | 2 | boolean "opie-pcmciaapplet (monitor and configure pcmcia/cf cards)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE |
diff --git a/core/applets/cardmon/pcmcia.cpp b/core/applets/cardmon/pcmcia.cpp new file mode 100644 index 0000000..2486f17 --- a/dev/null +++ b/core/applets/cardmon/pcmcia.cpp | |||
@@ -0,0 +1,371 @@ | |||
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/oprocess.h> | ||
36 | #include <opie2/oresource.h> | ||
37 | #include <opie2/otaskbarapplet.h> | ||
38 | #include <qpe/applnk.h> | ||
39 | #include <qpe/resource.h> | ||
40 | using namespace Opie::Core; | ||
41 | using namespace Opie::Ui; | ||
42 | |||
43 | /* QT */ | ||
44 | #include <qcopchannel_qws.h> | ||
45 | #include <qpainter.h> | ||
46 | #include <qfile.h> | ||
47 | #include <qtextstream.h> | ||
48 | #include <qsound.h> | ||
49 | #include <qtimer.h> | ||
50 | |||
51 | /* STD */ | ||
52 | #include <stdio.h> | ||
53 | #include <unistd.h> | ||
54 | #include <stdlib.h> | ||
55 | #include <string.h> | ||
56 | #include <fcntl.h> | ||
57 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | ||
58 | #include <sys/vfs.h> | ||
59 | #include <mntent.h> | ||
60 | #endif | ||
61 | |||
62 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | ||
63 | { | ||
64 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | ||
65 | #if 0 | ||
66 | QCopChannel *channel = new QCopChannel("QPE/System", this); | ||
67 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | ||
68 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | ||
69 | #endif | ||
70 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | ||
71 | connect( pcmciaChannel, | ||
72 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | ||
73 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | ||
74 | |||
75 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); | ||
76 | connect( sdChannel, | ||
77 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | ||
78 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | ||
79 | |||
80 | cardInPcmcia0 = FALSE; | ||
81 | cardInPcmcia1 = FALSE; | ||
82 | cardInSd = FALSE; | ||
83 | |||
84 | setFocusPolicy( NoFocus ); | ||
85 | |||
86 | setFixedWidth ( AppLnk::smallIconSize() ); | ||
87 | setFixedHeight ( AppLnk::smallIconSize() ); | ||
88 | |||
89 | getStatusPcmcia( TRUE ); | ||
90 | getStatusSd( TRUE ); | ||
91 | repaint( FALSE ); | ||
92 | popupMenu = 0; | ||
93 | } | ||
94 | |||
95 | |||
96 | PcmciaManager::~PcmciaManager() | ||
97 | { | ||
98 | delete popupMenu; | ||
99 | } | ||
100 | |||
101 | |||
102 | void PcmciaManager::popUp( QString message, QString icon ) | ||
103 | { | ||
104 | if ( !popupMenu ) { | ||
105 | popupMenu = new QPopupMenu( this ); | ||
106 | } | ||
107 | |||
108 | popupMenu->clear(); | ||
109 | if ( icon.isEmpty() ) { | ||
110 | popupMenu->insertItem( message, 0 ); | ||
111 | } else { | ||
112 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | ||
113 | message, 0 ); | ||
114 | } | ||
115 | |||
116 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | ||
117 | QSize s = popupMenu->sizeHint(); | ||
118 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | ||
119 | p.y() - s.height() ), 0 ); | ||
120 | |||
121 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | ||
122 | } | ||
123 | |||
124 | |||
125 | void PcmciaManager::popupTimeout() | ||
126 | { | ||
127 | popupMenu->hide(); | ||
128 | } | ||
129 | |||
130 | |||
131 | void PcmciaManager::mousePressEvent( QMouseEvent * ) | ||
132 | { | ||
133 | QPopupMenu * menu = new QPopupMenu( this ); | ||
134 | QStringList cmd; | ||
135 | bool execute = true; | ||
136 | |||
137 | if ( cardInSd ) { | ||
138 | menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), | ||
139 | tr( "Eject SD/MMC card" ), 0 ); | ||
140 | } | ||
141 | |||
142 | if ( cardInPcmcia0 ) { | ||
143 | menu-> | ||
144 | insertItem( QIconSet | ||
145 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), | ||
146 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | ||
147 | } | ||
148 | |||
149 | if ( cardInPcmcia1 ) { | ||
150 | menu-> | ||
151 | insertItem( QIconSet | ||
152 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), | ||
153 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | ||
154 | } | ||
155 | |||
156 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | ||
157 | QSize s = menu->sizeHint(); | ||
158 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | ||
159 | p.y() - s.height() ), 0 ); | ||
160 | |||
161 | if ( opt == 1 ) { | ||
162 | m_commandOrig = PCMCIA_Socket1; | ||
163 | cmd << "/sbin/cardctl" << "eject" << "0"; | ||
164 | } else if ( opt == 0 ) { | ||
165 | m_commandOrig = MMC_Socket; | ||
166 | cmd << "umount" << cardSdName; | ||
167 | } else if ( opt == 2 ) { | ||
168 | m_commandOrig = PCMCIA_Socket2; | ||
169 | cmd << "/sbin/cardctl" << "eject" << "1"; | ||
170 | }else | ||
171 | execute = false; | ||
172 | |||
173 | if ( execute ) | ||
174 | execCommand( cmd ); | ||
175 | |||
176 | delete menu; | ||
177 | } | ||
178 | |||
179 | |||
180 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | ||
181 | { | ||
182 | if ( msg == "stabChanged()" ) { | ||
183 | // odebug << "Pcmcia: stabchanged" << oendl; | ||
184 | getStatusPcmcia(); | ||
185 | } else if ( msg == "mtabChanged()" ) { | ||
186 | // odebug << "CARDMONAPPLET: mtabchanged" << oendl; | ||
187 | getStatusSd(); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | |||
192 | bool PcmciaManager::getStatusPcmcia( int showPopUp ) { | ||
193 | |||
194 | bool cardWas0 = cardInPcmcia0; // remember last state | ||
195 | bool cardWas1 = cardInPcmcia1; | ||
196 | |||
197 | QString fileName; | ||
198 | |||
199 | if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } | ||
200 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } | ||
201 | else { fileName = "/var/lib/pcmcia/stab"; } | ||
202 | |||
203 | QFile f( fileName ); | ||
204 | |||
205 | if ( f.open( IO_ReadOnly ) ) { | ||
206 | QStringList list; | ||
207 | QTextStream stream( &f ); | ||
208 | QString streamIn; | ||
209 | streamIn = stream.read(); | ||
210 | list = QStringList::split( "\n", streamIn ); | ||
211 | for ( QStringList::Iterator line = list.begin(); line != list.end(); | ||
212 | line++ ) { | ||
213 | if ( ( *line ).startsWith( "Socket 0:" ) ) { | ||
214 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) { | ||
215 | cardInPcmcia0 = FALSE; | ||
216 | } else if ( !( *line ).startsWith( "Socket 0: empty" ) | ||
217 | && !cardInPcmcia0 ) { | ||
218 | cardInPcmcia0Name = | ||
219 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | ||
220 | ( *line ).length() - 9 ); | ||
221 | cardInPcmcia0Name.stripWhiteSpace(); | ||
222 | cardInPcmcia0 = TRUE; | ||
223 | show(); | ||
224 | line++; | ||
225 | int pos = ( *line ).find( '\t' ) + 1; | ||
226 | cardInPcmcia0Type = | ||
227 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | ||
228 | } | ||
229 | } else if ( ( *line ).startsWith( "Socket 1:" ) ) { | ||
230 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { | ||
231 | cardInPcmcia1 = FALSE; | ||
232 | } else if ( !( *line ).startsWith( "Socket 1: empty" ) | ||
233 | && !cardInPcmcia1 ) { | ||
234 | cardInPcmcia1Name = | ||
235 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | ||
236 | ( *line ).length() - 9 ); | ||
237 | cardInPcmcia1Name.stripWhiteSpace(); | ||
238 | cardInPcmcia1 = TRUE; | ||
239 | show(); | ||
240 | line++; | ||
241 | int pos = ( *line ).find( '\t' ) + 1; | ||
242 | cardInPcmcia1Type = | ||
243 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | f.close(); | ||
248 | |||
249 | if ( !showPopUp | ||
250 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) { | ||
251 | QString text = QString::null; | ||
252 | QString what = QString::null; | ||
253 | if ( cardWas0 != cardInPcmcia0 ) { | ||
254 | if ( cardInPcmcia0 ) { | ||
255 | text += tr( "New card: " ); | ||
256 | what = "on"; | ||
257 | } else { | ||
258 | text += tr( "Ejected: " ); | ||
259 | what = "off"; | ||
260 | } | ||
261 | text += cardInPcmcia0Name; | ||
262 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | ||
263 | } | ||
264 | |||
265 | if ( cardWas1 != cardInPcmcia1 ) { | ||
266 | if ( cardInPcmcia1 ) { | ||
267 | text += tr( "New card: " ); | ||
268 | what = "on"; | ||
269 | } else { | ||
270 | text += tr( "Ejected: " ); | ||
271 | what = "off"; | ||
272 | } | ||
273 | text += cardInPcmcia1Name; | ||
274 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | ||
275 | } | ||
276 | #ifndef QT_NO_SOUND | ||
277 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | ||
278 | #endif | ||
279 | |||
280 | } | ||
281 | } else { | ||
282 | // no file found | ||
283 | odebug << "no file found" << oendl; | ||
284 | cardInPcmcia0 = FALSE; | ||
285 | cardInPcmcia1 = FALSE; | ||
286 | } | ||
287 | |||
288 | repaint( FALSE ); | ||
289 | return ( ( cardWas0 == cardInPcmcia0 | ||
290 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | ||
291 | |||
292 | } | ||
293 | |||
294 | |||
295 | bool PcmciaManager::getStatusSd( int showPopUp ) | ||
296 | { | ||
297 | |||
298 | bool cardWas = cardInSd; // remember last state | ||
299 | cardInSd = FALSE; | ||
300 | |||
301 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | ||
302 | |||
303 | struct mntent *me; | ||
304 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | ||
305 | |||
306 | if ( mntfp ) { | ||
307 | while ( ( me = getmntent( mntfp ) ) != 0 ) { | ||
308 | QString fs = QFile::decodeName( me->mnt_fsname ); | ||
309 | //odebug << fs << oendl; | ||
310 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" | ||
311 | || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) { | ||
312 | cardInSd = TRUE; | ||
313 | cardSdName = fs; | ||
314 | show(); | ||
315 | } | ||
316 | // else { | ||
317 | // cardInSd = FALSE; | ||
318 | // } | ||
319 | } | ||
320 | endmntent( mntfp ); | ||
321 | } | ||
322 | |||
323 | if ( !showPopUp && cardWas != cardInSd ) { | ||
324 | QString text = QString::null; | ||
325 | QString what = QString::null; | ||
326 | if ( cardInSd ) { | ||
327 | text += tr("New card: SD/MMC"); | ||
328 | what = "on"; | ||
329 | } else { | ||
330 | text += tr("Ejected: SD/MMC"); | ||
331 | what = "off"; | ||
332 | } | ||
333 | //odebug << "TEXT: " + text << oendl; | ||
334 | #ifndef QT_NO_SOUND | ||
335 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | ||
336 | #endif | ||
337 | |||
338 | popUp( text, "cardmon/ide" ); // XX add SD pic | ||
339 | } | ||
340 | #else | ||
341 | #error "Not on Linux" | ||
342 | #endif | ||
343 | repaint( FALSE ); | ||
344 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); | ||
345 | } | ||
346 | |||
347 | void PcmciaManager::paintEvent( QPaintEvent * ) | ||
348 | { | ||
349 | |||
350 | QPainter p( this ); | ||
351 | |||
352 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | ||
353 | p.drawPixmap( 0, 0, pm ); | ||
354 | show(); | ||
355 | } else { | ||
356 | //p.eraseRect(rect()); | ||
357 | hide(); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | int PcmciaManager::position() | ||
362 | { | ||
363 | return 7; | ||
364 | } | ||
365 | |||
366 | void PcmciaManager::execCommand( const QStringList &strList ) | ||
367 | { | ||
368 | } | ||
369 | |||
370 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | ||
371 | |||
diff --git a/core/applets/cardmon/pcmcia.h b/core/applets/cardmon/pcmcia.h new file mode 100644 index 0000000..58a2d42 --- a/dev/null +++ b/core/applets/cardmon/pcmcia.h | |||
@@ -0,0 +1,80 @@ | |||
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 | |||
37 | class PcmciaManager : public QWidget | ||
38 | { | ||
39 | Q_OBJECT | ||
40 | public: | ||
41 | enum { | ||
42 | PCMCIA_Socket1, | ||
43 | PCMCIA_Socket2, | ||
44 | MMC_Socket | ||
45 | }; | ||
46 | |||
47 | PcmciaManager( QWidget *parent = 0 ); | ||
48 | ~PcmciaManager(); | ||
49 | bool getStatusPcmcia( int showPopUp = FALSE ); | ||
50 | bool getStatusSd( int showPopUp = FALSE ); | ||
51 | static int position(); | ||
52 | private slots: | ||
53 | void cardMessage( const QCString &msg, const QByteArray & ); | ||
54 | void popupTimeout(); | ||
55 | |||
56 | protected: | ||
57 | void paintEvent( QPaintEvent* ); | ||
58 | void mousePressEvent( QMouseEvent * ); | ||
59 | |||
60 | private: | ||
61 | void execCommand( const QStringList &command ); | ||
62 | int m_commandOrig; | ||
63 | QPixmap pm; | ||
64 | // pcmcia socket 0 | ||
65 | bool cardInPcmcia0; | ||
66 | QString cardInPcmcia0Name; | ||
67 | QString cardInPcmcia0Type; | ||
68 | // pcmcia socket 1 | ||
69 | bool cardInPcmcia1; | ||
70 | QString cardInPcmcia1Name; | ||
71 | QString cardInPcmcia1Type; | ||
72 | bool cardInSd; | ||
73 | QString cardSdName; // the device which is mounted | ||
74 | void iconShow(); | ||
75 | QPopupMenu *popupMenu; | ||
76 | void popUp(QString message, QString icon = QString::null ); | ||
77 | }; | ||
78 | |||
79 | #endif | ||
80 | |||
diff --git a/core/applets/cardmon/pcmcia.pro b/core/applets/cardmon/pcmcia.pro new file mode 100644 index 0000000..c4f7b62 --- a/dev/null +++ b/core/applets/cardmon/pcmcia.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt plugin warn_on | ||
3 | HEADERS = pcmcia.h | ||
4 | SOURCES = pcmcia.cpp | ||
5 | TARGET = pcmciaapplet | ||
6 | DESTDIR = $(OPIEDIR)/plugins/applets | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lqpe -lopiecore2 | ||
10 | VERSION = 0.1.0 | ||
11 | |||
12 | include( $(OPIEDIR)/include.pro ) | ||
@@ -148,64 +148,65 @@ CONFIG_NS2PROFILE noncore/settings/networksettings2/profile profile.pro | |||
148 | CONFIG_NS2USB noncore/settings/networksettings2/usbusb.pro | 148 | CONFIG_NS2USB noncore/settings/networksettings2/usbusb.pro |
149 | CONFIG_NS2VPN noncore/settings/networksettings2/vpnvpn.pro | 149 | CONFIG_NS2VPN noncore/settings/networksettings2/vpnvpn.pro |
150 | CONFIG_NS2WLAN noncore/settings/networksettings2/wlanwlan.pro | 150 | CONFIG_NS2WLAN noncore/settings/networksettings2/wlanwlan.pro |
151 | CONFIG_OAPP core/apps/oappoapp.pro | 151 | CONFIG_OAPP core/apps/oappoapp.pro |
152 | CONFIG_OBEX core/obexobex.pro | 152 | CONFIG_OBEX core/obexobex.pro |
153 | CONFIG_ODICT noncore/apps/odictodict.pro | 153 | CONFIG_ODICT noncore/apps/odictodict.pro |
154 | CONFIG_OIPKG noncore/unsupported/oipkgoipkg.pro | 154 | CONFIG_OIPKG noncore/unsupported/oipkgoipkg.pro |
155 | CONFIG_OPIEALARM core/opiealarmopiealarm.pro | 155 | CONFIG_OPIEALARM core/opiealarmopiealarm.pro |
156 | CONFIG_OPIE-CONSOLE noncore/apps/opie-consoleopie-console.pro | 156 | CONFIG_OPIE-CONSOLE noncore/apps/opie-consoleopie-console.pro |
157 | CONFIG_OPIE_EYE noncore/graphics/opie-eyephunk_view.pro | 157 | CONFIG_OPIE_EYE noncore/graphics/opie-eyephunk_view.pro |
158 | CONFIG_OPIE_EYE_SLAVE noncore/graphics/opie-eye/slaveslave.pro | 158 | CONFIG_OPIE_EYE_SLAVE noncore/graphics/opie-eye/slaveslave.pro |
159 | CONFIG_OPIEFTP noncore/net/opieftpopieftp.pro | 159 | CONFIG_OPIEFTP noncore/net/opieftpopieftp.pro |
160 | CONFIG_OPIEIRC noncore/net/opieircopieirc.pro | 160 | CONFIG_OPIEIRC noncore/net/opieircopieirc.pro |
161 | CONFIG_OPIE-LOGIN core/opie-loginopie-login.pro | 161 | CONFIG_OPIE-LOGIN core/opie-loginopie-login.pro |
162 | CONFIG_OPIEMAIL2noncore/unsupported/mail2 mail.pro | 162 | CONFIG_OPIEMAIL2noncore/unsupported/mail2 mail.pro |
163 | CONFIG_OPIEPLAYER2 noncore/multimedia/opieplayer2opieplayer2.pro | 163 | CONFIG_OPIEPLAYER2 noncore/multimedia/opieplayer2opieplayer2.pro |
164 | CONFIG_OPIEPLAYER3 noncore/multimedia/opieplayer3opieplayer3.pro | 164 | CONFIG_OPIEPLAYER3 noncore/multimedia/opieplayer3opieplayer3.pro |
165 | CONFIG_OPIEPLAYER core/multimedia/opieplayeropieplayer.pro | 165 | CONFIG_OPIEPLAYER core/multimedia/opieplayeropieplayer.pro |
166 | CONFIG_OPIE-RDESKTOP noncore/net/opierdesktopopierdesktop.pro | 166 | CONFIG_OPIE-RDESKTOP noncore/net/opierdesktopopierdesktop.pro |
167 | CONFIG_OPIE-READER noncore/apps/opie-readeropie-reader.pro | 167 | CONFIG_OPIE-READER noncore/apps/opie-readeropie-reader.pro |
168 | CONFIG_OPIE-READER-FLITEDYN noncore/apps/opie-reader/FliteDynFliteDyn.pro | 168 | CONFIG_OPIE-READER-FLITEDYN noncore/apps/opie-reader/FliteDynFliteDyn.pro |
169 | CONFIG_OPIE-READER-FLITEDYN16 noncore/apps/opie-reader/FliteDyn16FliteDyn16.pro | 169 | CONFIG_OPIE-READER-FLITEDYN16 noncore/apps/opie-reader/FliteDyn16FliteDyn16.pro |
170 | CONFIG_OPIEREC noncore/multimedia/opierecopierec.pro | 170 | CONFIG_OPIEREC noncore/multimedia/opierecopierec.pro |
171 | CONFIG_OPIE-SHEET noncore/apps/opie-sheetopie-sheet.pro | 171 | CONFIG_OPIE-SHEET noncore/apps/opie-sheetopie-sheet.pro |
172 | CONFIG_OPIE-SH noncore/tools/opie-shopie-sh.pro | 172 | CONFIG_OPIE-SH noncore/tools/opie-shopie-sh.pro |
173 | CONFIG_OPIETOOTH-APPLET noncore/net/opietooth/appletapplet.pro | 173 | CONFIG_OPIETOOTH-APPLET noncore/net/opietooth/appletapplet.pro |
174 | CONFIG_OPIETOOTH-MANAGER noncore/net/opietooth/managermanager.pro | 174 | CONFIG_OPIETOOTH-MANAGER noncore/net/opietooth/managermanager.pro |
175 | CONFIG_OPIE-WRITE noncore/apps/opie-writeopie-write.pro | 175 | CONFIG_OPIE-WRITE noncore/apps/opie-writeopie-write.pro |
176 | CONFIG_OSEARCH core/pim/osearchosearch.pro | 176 | CONFIG_OSEARCH core/pim/osearchosearch.pro |
177 | CONFIG_OXYGEN noncore/apps/oxygenoxygen.pro | 177 | CONFIG_OXYGEN noncore/apps/oxygenoxygen.pro |
178 | CONFIG_PACKAGEMANAGER noncore/settings/packagemanagerpackagemanager.pro | 178 | CONFIG_PACKAGEMANAGER noncore/settings/packagemanagerpackagemanager.pro |
179 | CONFIG_PARASHOOT noncore/games/parashootparashoot.pro | 179 | CONFIG_PARASHOOT noncore/games/parashootparashoot.pro |
180 | CONFIG_PCMCIA-APPLET noncore/applets/pcmciapcmcia.pro | ||
180 | CONFIG_PHASE noncore/styles/phasephase.pro | 181 | CONFIG_PHASE noncore/styles/phasephase.pro |
181 | CONFIG_PICKBOARD inputmethods/pickboardpickboard.pro | 182 | CONFIG_PICKBOARD inputmethods/pickboardpickboard.pro |
182 | CONFIG_PIMCONVERTER noncore/tools/pimconverter converter.pro | 183 | CONFIG_PIMCONVERTER noncore/tools/pimconverter converter.pro |
183 | CONFIG_POWERCHORD noncore/multimedia/powerchordpowerchord.pro | 184 | CONFIG_POWERCHORD noncore/multimedia/powerchordpowerchord.pro |
184 | CONFIG_PPP noncore/settings/networksettings/ppp ppp.pro | 185 | CONFIG_PPP noncore/settings/networksettings/ppp ppp.pro |
185 | CONFIG_PYQUICKLAUNCH-APPLET noncore/applets/pyquicklaunchpyquicklaunch.pro | 186 | CONFIG_PYQUICKLAUNCH-APPLET noncore/applets/pyquicklaunchpyquicklaunch.pro |
186 | CONFIG_PYQUICKLAUNCHER noncore/tools/pyquicklauncherpyquicklauncher.pro | 187 | CONFIG_PYQUICKLAUNCHER noncore/tools/pyquicklauncherpyquicklauncher.pro |
187 | CONFIG_PYTHON-EXAMPLESexamples/python bla.pro | 188 | CONFIG_PYTHON-EXAMPLESexamples/python bla.pro |
188 | CONFIG_QASHMONEY noncore/unsupported/qashmoneyqashmoney.pro | 189 | CONFIG_QASHMONEY noncore/unsupported/qashmoneyqashmoney.pro |
189 | CONFIG_QASTEROIDS noncore/games/qasteroidsqasteroids.pro | 190 | CONFIG_QASTEROIDS noncore/games/qasteroidsqasteroids.pro |
190 | CONFIG_QCOP core/apps/qcopqcop.pro | 191 | CONFIG_QCOP core/apps/qcopqcop.pro |
191 | CONFIG_QPDF noncore/unsupported/qpdfqpdf.pro | 192 | CONFIG_QPDF noncore/unsupported/qpdfqpdf.pro |
192 | CONFIG_QSS core/apps/qssqss.pro | 193 | CONFIG_QSS core/apps/qssqss.pro |
193 | CONFIG_QUICKLAUNCHER core/tools/quicklauncher quicklauncher.pro | 194 | CONFIG_QUICKLAUNCHER core/tools/quicklauncher quicklauncher.pro |
194 | CONFIG_QWS core/qwsqws.pro | 195 | CONFIG_QWS core/qwsqws.pro |
195 | CONFIG_REMOTE noncore/tools/remoteremote.pro | 196 | CONFIG_REMOTE noncore/tools/remoteremote.pro |
196 | CONFIG_RESTARTAPPLET2 core/applets/restartapplet2restartapplet2.pro | 197 | CONFIG_RESTARTAPPLET2 core/applets/restartapplet2restartapplet2.pro |
197 | CONFIG_RESTARTAPPLET core/applets/restartappletrestartapplet.pro | 198 | CONFIG_RESTARTAPPLET core/applets/restartappletrestartapplet.pro |
198 | CONFIG_ROTATEAPPLET core/applets/rotateappletrotateapplet.pro | 199 | CONFIG_ROTATEAPPLET core/applets/rotateappletrotateapplet.pro |
199 | CONFIG_ROTATION noncore/settings/rotationrotation.pro | 200 | CONFIG_ROTATION noncore/settings/rotationrotation.pro |
200 | CONFIG_RUNAPPLET core/applets/runappletrunapplet.pro | 201 | CONFIG_RUNAPPLET core/applets/runappletrunapplet.pro |
201 | CONFIG_SCREENSHOTAPPLET core/applets/screenshotappletscreenshotapplet.pro | 202 | CONFIG_SCREENSHOTAPPLET core/applets/screenshotappletscreenshotapplet.pro |
202 | CONFIG_SECURITY core/settings/securitysecurity.pro | 203 | CONFIG_SECURITY core/settings/securitysecurity.pro |
203 | CONFIG_MULTIAUTH_DEMO core/settings/security/demomultiauth.pro | 204 | CONFIG_MULTIAUTH_DEMO core/settings/security/demomultiauth.pro |
204 | CONFIG_SFCAVE noncore/games/sfcavesfcave.pro | 205 | CONFIG_SFCAVE noncore/games/sfcavesfcave.pro |
205 | CONFIG_SFCAVE-SDL noncore/games/sfcave-sdlsfcave-sdl.pro | 206 | CONFIG_SFCAVE-SDL noncore/games/sfcave-sdlsfcave-sdl.pro |
206 | CONFIG_SHOWIMG noncore/unsupported/showimgshowimg.pro | 207 | CONFIG_SHOWIMG noncore/unsupported/showimgshowimg.pro |
207 | CONFIG_SIMPLE_EXAMPLE examples/simple simple.pro | 208 | CONFIG_SIMPLE_EXAMPLE examples/simple simple.pro |
208 | CONFIG_SIMPLE_ICON examples/simple-icon simple-icon.pro | 209 | CONFIG_SIMPLE_ICON examples/simple-icon simple-icon.pro |
209 | CONFIG_SIMPLE_MAIN examples/simple-main simple-main.pro | 210 | CONFIG_SIMPLE_MAIN examples/simple-main simple-main.pro |
210 | CONFIG_SIMPLE noncore/tools/calc2/simplesimple.pro | 211 | CONFIG_SIMPLE noncore/tools/calc2/simplesimple.pro |
211 | CONFIG_SIMPLE_PIM examples/simple-pim simple-pim.pro | 212 | CONFIG_SIMPLE_PIM examples/simple-pim simple-pim.pro |