author | mickeyl <mickeyl> | 2004-04-05 12:48:49 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-05 12:48:49 (UTC) |
commit | f1708be741dfb73ceaffb633b44093f2cb2b3d57 (patch) (unidiff) | |
tree | 0bdcab2ac6c5f0e5cac67eb58807a50bb79d82e0 | |
parent | 0b481957a2eebf28b05d9803780d05ad4232aa00 (diff) | |
download | opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.zip opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.gz opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.bz2 |
convert core/applets/* to Opie debug framework
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 26 | ||||
-rw-r--r-- | core/applets/clockapplet/clock.cpp | 10 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 4 | ||||
-rw-r--r-- | core/applets/multikeyapplet/multikey.cpp | 2 | ||||
-rw-r--r-- | core/applets/restartapplet/restart.cpp | 2 | ||||
-rw-r--r-- | core/applets/restartapplet/restartappletimpl.cpp | 5 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 9 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 522 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 108 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 65 | ||||
-rw-r--r-- | core/obex/obexsend.cpp | 29 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 41 |
12 files changed, 417 insertions, 406 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 1ad8b55..3a6ad27 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,424 +1,420 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.cpp | 2 | * cardmon.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "cardmon.h" | 19 | #include "cardmon.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/odebug.h> | ||
22 | #include <opie2/odevice.h> | 23 | #include <opie2/odevice.h> |
23 | #include <opie2/otaskbarapplet.h> | 24 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | using namespace Opie::Core; | ||
28 | using namespace Opie::Ui; | ||
26 | 29 | ||
27 | /* QT */ | 30 | /* QT */ |
28 | #include <qcopchannel_qws.h> | 31 | #include <qcopchannel_qws.h> |
29 | #include <qpainter.h> | 32 | #include <qpainter.h> |
30 | #include <qfile.h> | 33 | #include <qfile.h> |
31 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
32 | #include <qsound.h> | 35 | #include <qsound.h> |
33 | #include <qtimer.h> | 36 | #include <qtimer.h> |
34 | 37 | ||
35 | /* STD */ | 38 | /* STD */ |
36 | #include <stdio.h> | 39 | #include <stdio.h> |
37 | #include <unistd.h> | 40 | #include <unistd.h> |
38 | #include <stdlib.h> | 41 | #include <stdlib.h> |
39 | #include <string.h> | 42 | #include <string.h> |
40 | #include <fcntl.h> | 43 | #include <fcntl.h> |
41 | |||
42 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 44 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
43 | #include <sys/vfs.h> | 45 | #include <sys/vfs.h> |
44 | #include <mntent.h> | 46 | #include <mntent.h> |
45 | #endif | 47 | #endif |
46 | 48 | ||
47 | using namespace Opie; | ||
48 | |||
49 | using namespace Opie::Ui; | ||
50 | using namespace Opie::Ui; | ||
51 | using namespace Opie::Core; | ||
52 | |||
53 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), | 49 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), |
54 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) | 50 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) |
55 | { | 51 | { |
56 | 52 | ||
57 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 53 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
58 | connect( pcmciaChannel, | 54 | connect( pcmciaChannel, |
59 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 55 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
60 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 56 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
61 | 57 | ||
62 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); | 58 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); |
63 | connect( sdChannel, | 59 | connect( sdChannel, |
64 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 60 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
65 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 61 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
66 | 62 | ||
67 | cardInPcmcia0 = FALSE; | 63 | cardInPcmcia0 = FALSE; |
68 | cardInPcmcia1 = FALSE; | 64 | cardInPcmcia1 = FALSE; |
69 | cardInSd = FALSE; | 65 | cardInSd = FALSE; |
70 | 66 | ||
71 | setFocusPolicy( NoFocus ); | 67 | setFocusPolicy( NoFocus ); |
72 | 68 | ||
73 | setFixedWidth ( AppLnk::smallIconSize() ); | 69 | setFixedWidth ( AppLnk::smallIconSize() ); |
74 | setFixedHeight ( AppLnk::smallIconSize() ); | 70 | setFixedHeight ( AppLnk::smallIconSize() ); |
75 | 71 | ||
76 | getStatusPcmcia( TRUE ); | 72 | getStatusPcmcia( TRUE ); |
77 | getStatusSd( TRUE ); | 73 | getStatusSd( TRUE ); |
78 | repaint( FALSE ); | 74 | repaint( FALSE ); |
79 | popupMenu = 0; | 75 | popupMenu = 0; |
80 | } | 76 | } |
81 | 77 | ||
82 | CardMonitor::~CardMonitor() | 78 | CardMonitor::~CardMonitor() |
83 | { | 79 | { |
84 | if ( popupMenu ) | 80 | if ( popupMenu ) |
85 | { | 81 | { |
86 | delete popupMenu; | 82 | delete popupMenu; |
87 | } | 83 | } |
88 | } | 84 | } |
89 | 85 | ||
90 | void CardMonitor::popUp( QString message, QString icon ) | 86 | void CardMonitor::popUp( QString message, QString icon ) |
91 | { | 87 | { |
92 | if ( !popupMenu ) | 88 | if ( !popupMenu ) |
93 | { | 89 | { |
94 | popupMenu = new QPopupMenu( this ); | 90 | popupMenu = new QPopupMenu( this ); |
95 | } | 91 | } |
96 | 92 | ||
97 | popupMenu->clear(); | 93 | popupMenu->clear(); |
98 | if ( icon.isEmpty() ) | 94 | if ( icon.isEmpty() ) |
99 | { | 95 | { |
100 | popupMenu->insertItem( message, 0 ); | 96 | popupMenu->insertItem( message, 0 ); |
101 | } | 97 | } |
102 | else | 98 | else |
103 | { | 99 | { |
104 | popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), | 100 | popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), |
105 | message, 0 ); | 101 | message, 0 ); |
106 | } | 102 | } |
107 | 103 | ||
108 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 104 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
109 | QSize s = popupMenu->sizeHint(); | 105 | QSize s = popupMenu->sizeHint(); |
110 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 106 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
111 | p.y() - s.height() ), 0 ); | 107 | p.y() - s.height() ), 0 ); |
112 | 108 | ||
113 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 109 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
114 | } | 110 | } |
115 | 111 | ||
116 | void CardMonitor::popupTimeout() | 112 | void CardMonitor::popupTimeout() |
117 | { | 113 | { |
118 | popupMenu->hide(); | 114 | popupMenu->hide(); |
119 | } | 115 | } |
120 | 116 | ||
121 | void CardMonitor::mousePressEvent( QMouseEvent * ) | 117 | void CardMonitor::mousePressEvent( QMouseEvent * ) |
122 | { | 118 | { |
123 | QPopupMenu * menu = new QPopupMenu( this ); | 119 | QPopupMenu * menu = new QPopupMenu( this ); |
124 | QString cmd; | 120 | QString cmd; |
125 | int err = 0; | 121 | int err = 0; |
126 | 122 | ||
127 | if ( cardInSd ) | 123 | if ( cardInSd ) |
128 | { | 124 | { |
129 | menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), | 125 | menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), |
130 | tr( "Eject SD/MMC card" ), 0 ); | 126 | tr( "Eject SD/MMC card" ), 0 ); |
131 | } | 127 | } |
132 | 128 | ||
133 | if ( cardInPcmcia0 ) | 129 | if ( cardInPcmcia0 ) |
134 | { | 130 | { |
135 | menu-> | 131 | menu-> |
136 | insertItem( QIconSet | 132 | insertItem( QIconSet |
137 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), | 133 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), |
138 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | 134 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); |
139 | } | 135 | } |
140 | 136 | ||
141 | if ( cardInPcmcia1 ) | 137 | if ( cardInPcmcia1 ) |
142 | { | 138 | { |
143 | menu-> | 139 | menu-> |
144 | insertItem( QIconSet | 140 | insertItem( QIconSet |
145 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), | 141 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), |
146 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 142 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); |
147 | } | 143 | } |
148 | 144 | ||
149 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 145 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
150 | QSize s = menu->sizeHint(); | 146 | QSize s = menu->sizeHint(); |
151 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 147 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
152 | p.y() - s.height() ), 0 ); | 148 | p.y() - s.height() ), 0 ); |
153 | 149 | ||
154 | if ( opt == 1 ) | 150 | if ( opt == 1 ) |
155 | { | 151 | { |
156 | cmd = "/sbin/cardctl eject 0"; | 152 | cmd = "/sbin/cardctl eject 0"; |
157 | err = system( ( const char * ) cmd ); | 153 | err = system( ( const char * ) cmd ); |
158 | if ( err != 0 ) | 154 | if ( err != 0 ) |
159 | { | 155 | { |
160 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", | 156 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", |
161 | err ); | 157 | err ); |
162 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 158 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
163 | } | 159 | } |
164 | } | 160 | } |
165 | else if ( opt == 0 ) | 161 | else if ( opt == 0 ) |
166 | { | 162 | { |
167 | if ( ODevice::inst() ->system() == System_Familiar ) | 163 | if ( ODevice::inst() ->system() == System_Familiar ) |
168 | { | 164 | { |
169 | cmd = "umount /dev/mmc/part1"; | 165 | cmd = "umount /dev/mmc/part1"; |
170 | } | 166 | } |
171 | else | 167 | else |
172 | { | 168 | { |
173 | cmd = "umount /dev/mmcda1"; | 169 | cmd = "umount /dev/mmcda1"; |
174 | } | 170 | } |
175 | err = system( ( const char * ) cmd ); | 171 | err = system( ( const char * ) cmd ); |
176 | if ( err != 0 ) | 172 | if ( err != 0 ) |
177 | { | 173 | { |
178 | popUp( tr( "SD/MMC card eject failed!" ) ); | 174 | popUp( tr( "SD/MMC card eject failed!" ) ); |
179 | } | 175 | } |
180 | } | 176 | } |
181 | else if ( opt == 2 ) | 177 | else if ( opt == 2 ) |
182 | { | 178 | { |
183 | cmd = "/sbin/cardctl eject 1"; | 179 | cmd = "/sbin/cardctl eject 1"; |
184 | err = system( ( const char * ) cmd ); | 180 | err = system( ( const char * ) cmd ); |
185 | if ( err != 0 ) | 181 | if ( err != 0 ) |
186 | { | 182 | { |
187 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", | 183 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", |
188 | err ); | 184 | err ); |
189 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 185 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
190 | } | 186 | } |
191 | } | 187 | } |
192 | delete menu; | 188 | delete menu; |
193 | } | 189 | } |
194 | 190 | ||
195 | 191 | ||
196 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) | 192 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) |
197 | { | 193 | { |
198 | if ( msg == "stabChanged()" ) | 194 | if ( msg == "stabChanged()" ) |
199 | { | 195 | { |
200 | // qDebug("Pcmcia: stabchanged"); | 196 | // odebug << "Pcmcia: stabchanged" << oendl; |
201 | getStatusPcmcia(); | 197 | getStatusPcmcia(); |
202 | } | 198 | } |
203 | else if ( msg == "mtabChanged()" ) | 199 | else if ( msg == "mtabChanged()" ) |
204 | { | 200 | { |
205 | // qDebug("CARDMONAPPLET: mtabchanged"); | 201 | // odebug << "CARDMONAPPLET: mtabchanged" << oendl; |
206 | getStatusSd(); | 202 | getStatusSd(); |
207 | } | 203 | } |
208 | } | 204 | } |
209 | 205 | ||
210 | bool CardMonitor::getStatusPcmcia( int showPopUp ) | 206 | bool CardMonitor::getStatusPcmcia( int showPopUp ) |
211 | { | 207 | { |
212 | 208 | ||
213 | bool cardWas0 = cardInPcmcia0;// remember last state | 209 | bool cardWas0 = cardInPcmcia0; // remember last state |
214 | bool cardWas1 = cardInPcmcia1; | 210 | bool cardWas1 = cardInPcmcia1; |
215 | 211 | ||
216 | QString fileName; | 212 | QString fileName; |
217 | 213 | ||
218 | // one of these 3 files should exist | 214 | // one of these 3 files should exist |
219 | if ( QFile::exists( "/var/run/stab" ) ) | 215 | if ( QFile::exists( "/var/run/stab" ) ) |
220 | { | 216 | { |
221 | fileName = "/var/run/stab"; | 217 | fileName = "/var/run/stab"; |
222 | } | 218 | } |
223 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) | 219 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) |
224 | { | 220 | { |
225 | fileName = "/var/state/pcmcia/stab"; | 221 | fileName = "/var/state/pcmcia/stab"; |
226 | } | 222 | } |
227 | else | 223 | else |
228 | { | 224 | { |
229 | fileName = "/var/lib/pcmcia/stab"; | 225 | fileName = "/var/lib/pcmcia/stab"; |
230 | } | 226 | } |
231 | 227 | ||
232 | QFile f( fileName ); | 228 | QFile f( fileName ); |
233 | 229 | ||
234 | if ( f.open( IO_ReadOnly ) ) | 230 | if ( f.open( IO_ReadOnly ) ) |
235 | { | 231 | { |
236 | QStringList list; | 232 | QStringList list; |
237 | QTextStream stream( &f ); | 233 | QTextStream stream( &f ); |
238 | QString streamIn; | 234 | QString streamIn; |
239 | streamIn = stream.read(); | 235 | streamIn = stream.read(); |
240 | list = QStringList::split( "\n", streamIn ); | 236 | list = QStringList::split( "\n", streamIn ); |
241 | for ( QStringList::Iterator line = list.begin(); line != list.end(); | 237 | for ( QStringList::Iterator line = list.begin(); line != list.end(); |
242 | line++ ) | 238 | line++ ) |
243 | { | 239 | { |
244 | if ( ( *line ).startsWith( "Socket 0:" ) ) | 240 | if ( ( *line ).startsWith( "Socket 0:" ) ) |
245 | { | 241 | { |
246 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) | 242 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) |
247 | { | 243 | { |
248 | cardInPcmcia0 = FALSE; | 244 | cardInPcmcia0 = FALSE; |
249 | } | 245 | } |
250 | else if ( !( *line ).startsWith( "Socket 0: empty" ) | 246 | else if ( !( *line ).startsWith( "Socket 0: empty" ) |
251 | && !cardInPcmcia0 ) | 247 | && !cardInPcmcia0 ) |
252 | { | 248 | { |
253 | cardInPcmcia0Name = | 249 | cardInPcmcia0Name = |
254 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 250 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
255 | ( *line ).length() - 9 ); | 251 | ( *line ).length() - 9 ); |
256 | cardInPcmcia0Name.stripWhiteSpace(); | 252 | cardInPcmcia0Name.stripWhiteSpace(); |
257 | cardInPcmcia0 = TRUE; | 253 | cardInPcmcia0 = TRUE; |
258 | show(); | 254 | show(); |
259 | line++; | 255 | line++; |
260 | int pos = ( *line ).find( '\t' ) + 1; | 256 | int pos = ( *line ).find( '\t' ) + 1; |
261 | cardInPcmcia0Type = | 257 | cardInPcmcia0Type = |
262 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | 258 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); |
263 | } | 259 | } |
264 | } | 260 | } |
265 | else if ( ( *line ).startsWith( "Socket 1:" ) ) | 261 | else if ( ( *line ).startsWith( "Socket 1:" ) ) |
266 | { | 262 | { |
267 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) | 263 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) |
268 | { | 264 | { |
269 | cardInPcmcia1 = FALSE; | 265 | cardInPcmcia1 = FALSE; |
270 | } | 266 | } |
271 | else if ( !( *line ).startsWith( "Socket 1: empty" ) | 267 | else if ( !( *line ).startsWith( "Socket 1: empty" ) |
272 | && !cardInPcmcia1 ) | 268 | && !cardInPcmcia1 ) |
273 | { | 269 | { |
274 | cardInPcmcia1Name = | 270 | cardInPcmcia1Name = |
275 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 271 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
276 | ( *line ).length() - 9 ); | 272 | ( *line ).length() - 9 ); |
277 | cardInPcmcia1Name.stripWhiteSpace(); | 273 | cardInPcmcia1Name.stripWhiteSpace(); |
278 | cardInPcmcia1 = TRUE; | 274 | cardInPcmcia1 = TRUE; |
279 | show(); | 275 | show(); |
280 | line++; | 276 | line++; |
281 | int pos = ( *line ).find( '\t' ) + 1; | 277 | int pos = ( *line ).find( '\t' ) + 1; |
282 | cardInPcmcia1Type = | 278 | cardInPcmcia1Type = |
283 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | 279 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); |
284 | } | 280 | } |
285 | } | 281 | } |
286 | } | 282 | } |
287 | f.close(); | 283 | f.close(); |
288 | 284 | ||
289 | if ( !showPopUp | 285 | if ( !showPopUp |
290 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) | 286 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) |
291 | { | 287 | { |
292 | QString text = QString::null; | 288 | QString text = QString::null; |
293 | QString what = QString::null; | 289 | QString what = QString::null; |
294 | if ( cardWas0 != cardInPcmcia0 ) | 290 | if ( cardWas0 != cardInPcmcia0 ) |
295 | { | 291 | { |
296 | if ( cardInPcmcia0 ) | 292 | if ( cardInPcmcia0 ) |
297 | { | 293 | { |
298 | text += tr( "New card: " ); | 294 | text += tr( "New card: " ); |
299 | what = "on"; | 295 | what = "on"; |
300 | } | 296 | } |
301 | else | 297 | else |
302 | { | 298 | { |
303 | text += tr( "Ejected: " ); | 299 | text += tr( "Ejected: " ); |
304 | what = "off"; | 300 | what = "off"; |
305 | } | 301 | } |
306 | text += cardInPcmcia0Name; | 302 | text += cardInPcmcia0Name; |
307 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | 303 | popUp( text, "cardmon/" + cardInPcmcia0Type ); |
308 | } | 304 | } |
309 | 305 | ||
310 | if ( cardWas1 != cardInPcmcia1 ) | 306 | if ( cardWas1 != cardInPcmcia1 ) |
311 | { | 307 | { |
312 | if ( cardInPcmcia1 ) | 308 | if ( cardInPcmcia1 ) |
313 | { | 309 | { |
314 | text += tr( "New card: " ); | 310 | text += tr( "New card: " ); |
315 | what = "on"; | 311 | what = "on"; |
316 | } | 312 | } |
317 | else | 313 | else |
318 | { | 314 | { |
319 | text += tr( "Ejected: " ); | 315 | text += tr( "Ejected: " ); |
320 | what = "off"; | 316 | what = "off"; |
321 | } | 317 | } |
322 | text += cardInPcmcia1Name; | 318 | text += cardInPcmcia1Name; |
323 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | 319 | popUp( text, "cardmon/" + cardInPcmcia1Type ); |
324 | } | 320 | } |
325 | #ifndef QT_NO_SOUND | 321 | #ifndef QT_NO_SOUND |
326 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 322 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
327 | #endif | 323 | #endif |
328 | 324 | ||
329 | } | 325 | } |
330 | } | 326 | } |
331 | else | 327 | else |
332 | { | 328 | { |
333 | // no file found | 329 | // no file found |
334 | qDebug( "no file found" ); | 330 | odebug << "no file found" << oendl; |
335 | cardInPcmcia0 = FALSE; | 331 | cardInPcmcia0 = FALSE; |
336 | cardInPcmcia1 = FALSE; | 332 | cardInPcmcia1 = FALSE; |
337 | } | 333 | } |
338 | repaint( FALSE ); | 334 | repaint( FALSE ); |
339 | return ( ( cardWas0 == cardInPcmcia0 | 335 | return ( ( cardWas0 == cardInPcmcia0 |
340 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | 336 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); |
341 | 337 | ||
342 | } | 338 | } |
343 | 339 | ||
344 | 340 | ||
345 | bool CardMonitor::getStatusSd( int showPopUp ) | 341 | bool CardMonitor::getStatusSd( int showPopUp ) |
346 | { | 342 | { |
347 | 343 | ||
348 | bool cardWas = cardInSd;// remember last state | 344 | bool cardWas = cardInSd; // remember last state |
349 | cardInSd = FALSE; | 345 | cardInSd = FALSE; |
350 | 346 | ||
351 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 347 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
352 | struct mntent *me; | 348 | struct mntent *me; |
353 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 349 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
354 | 350 | ||
355 | if ( mntfp ) | 351 | if ( mntfp ) |
356 | { | 352 | { |
357 | while ( ( me = getmntent( mntfp ) ) != 0 ) | 353 | while ( ( me = getmntent( mntfp ) ) != 0 ) |
358 | { | 354 | { |
359 | QString fs = me->mnt_fsname; | 355 | QString fs = me->mnt_fsname; |
360 | //qDebug( fs ); | 356 | //odebug << fs << oendl; |
361 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" | 357 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" |
362 | || fs.left( 9 ) == "/dev/mmcd" ) | 358 | || fs.left( 9 ) == "/dev/mmcd" ) |
363 | { | 359 | { |
364 | cardInSd = TRUE; | 360 | cardInSd = TRUE; |
365 | show(); | 361 | show(); |
366 | } | 362 | } |
367 | // else { | 363 | // else { |
368 | // cardInSd = FALSE; | 364 | // cardInSd = FALSE; |
369 | // } | 365 | // } |
370 | } | 366 | } |
371 | endmntent( mntfp ); | 367 | endmntent( mntfp ); |
372 | } | 368 | } |
373 | 369 | ||
374 | if ( !showPopUp && cardWas != cardInSd ) | 370 | if ( !showPopUp && cardWas != cardInSd ) |
375 | { | 371 | { |
376 | QString text = QString::null; | 372 | QString text = QString::null; |
377 | QString what = QString::null; | 373 | QString what = QString::null; |
378 | if ( cardInSd ) | 374 | if ( cardInSd ) |
379 | { | 375 | { |
380 | text += "New card: SD/MMC"; | 376 | text += "New card: SD/MMC"; |
381 | what = "on"; | 377 | what = "on"; |
382 | } | 378 | } |
383 | else | 379 | else |
384 | { | 380 | { |
385 | text += "Ejected: SD/MMC"; | 381 | text += "Ejected: SD/MMC"; |
386 | what = "off"; | 382 | what = "off"; |
387 | } | 383 | } |
388 | //qDebug("TEXT: " + text ); | 384 | //odebug << "TEXT: " + text << oendl; |
389 | #ifndef QT_NO_SOUND | 385 | #ifndef QT_NO_SOUND |
390 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 386 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
391 | #endif | 387 | #endif |
392 | popUp( text, "cardmon/ide" );// XX add SD pic | 388 | popUp( text, "cardmon/ide" ); // XX add SD pic |
393 | } | 389 | } |
394 | #else | 390 | #else |
395 | #error "Not on Linux" | 391 | #error "Not on Linux" |
396 | #endif | 392 | #endif |
397 | repaint( FALSE ); | 393 | repaint( FALSE ); |
398 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); | 394 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); |
399 | } | 395 | } |
400 | 396 | ||
401 | void CardMonitor::paintEvent( QPaintEvent * ) | 397 | void CardMonitor::paintEvent( QPaintEvent * ) |
402 | { | 398 | { |
403 | 399 | ||
404 | QPainter p( this ); | 400 | QPainter p( this ); |
405 | 401 | ||
406 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) | 402 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) |
407 | { | 403 | { |
408 | p.drawPixmap( 0, 0, pm ); | 404 | p.drawPixmap( 0, 0, pm ); |
409 | show(); | 405 | show(); |
410 | } | 406 | } |
411 | else | 407 | else |
412 | { | 408 | { |
413 | //p.eraseRect(rect()); | 409 | //p.eraseRect(rect()); |
414 | hide(); | 410 | hide(); |
415 | } | 411 | } |
416 | } | 412 | } |
417 | 413 | ||
418 | int CardMonitor::position() | 414 | int CardMonitor::position() |
419 | { | 415 | { |
420 | return 7; | 416 | return 7; |
421 | } | 417 | } |
422 | 418 | ||
423 | EXPORT_OPIE_APPLET_v1( CardMonitor ) | 419 | EXPORT_OPIE_APPLET_v1( CardMonitor ) |
424 | 420 | ||
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp index 3b13d74..7d396e7 100644 --- a/core/applets/clockapplet/clock.cpp +++ b/core/applets/clockapplet/clock.cpp | |||
@@ -1,120 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "clock.h" | 21 | #include "clock.h" |
22 | 22 | ||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
23 | #include <opie2/otaskbarapplet.h> | 25 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
27 | 29 | ||
30 | using namespace Opie::Core; | ||
28 | using namespace Opie::Ui; | 31 | using namespace Opie::Ui; |
32 | |||
29 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) | 33 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) |
30 | { | 34 | { |
31 | // If you want a sunken border around the clock do this: | 35 | // If you want a sunken border around the clock do this: |
32 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 36 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
33 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); | 37 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); |
34 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) ); | 38 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) ); |
35 | connect( qApp, SIGNAL( clockChanged(bool) ), | 39 | connect( qApp, SIGNAL( clockChanged(bool) ), |
36 | this, SLOT( slotClockChanged(bool) ) ); | 40 | this, SLOT( slotClockChanged(bool) ) ); |
37 | readConfig(); | 41 | readConfig(); |
38 | timerId = 0; | 42 | timerId = 0; |
39 | timerEvent( 0 ); | 43 | timerEvent( 0 ); |
40 | show(); | 44 | show(); |
41 | } | 45 | } |
42 | 46 | ||
43 | int LauncherClock::position() | 47 | int LauncherClock::position() |
44 | { | 48 | { |
45 | return 10; | 49 | return 10; |
46 | } | 50 | } |
47 | 51 | ||
48 | void LauncherClock::readConfig() { | 52 | void LauncherClock::readConfig() { |
49 | Config config( "qpe" ); | 53 | Config config( "qpe" ); |
50 | config.setGroup( "Time" ); | 54 | config.setGroup( "Time" ); |
51 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); | 55 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); |
52 | config.setGroup( "Date" ); | 56 | config.setGroup( "Date" ); |
53 | format = config.readNumEntry("ClockApplet",0); | 57 | format = config.readNumEntry("ClockApplet",0); |
54 | } | 58 | } |
55 | 59 | ||
56 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) | 60 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) |
57 | { | 61 | { |
58 | QCString setTimeApp; | 62 | QCString setTimeApp; |
59 | setTimeApp="systemtime"; | 63 | setTimeApp="systemtime"; |
60 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); | 64 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); |
61 | } | 65 | } |
62 | 66 | ||
63 | 67 | ||
64 | void LauncherClock::timerEvent( QTimerEvent *e ) | 68 | void LauncherClock::timerEvent( QTimerEvent *e ) |
65 | { | 69 | { |
66 | if ( !e || e->timerId() == timerId ) { | 70 | if ( !e || e->timerId() == timerId ) { |
67 | killTimer( timerId ); | 71 | killTimer( timerId ); |
68 | changeTime(); | 72 | changeTime(); |
69 | QTime t = QTime::currentTime(); | 73 | QTime t = QTime::currentTime(); |
70 | int ms = (60 - t.second())*1000 - t.msec(); | 74 | int ms = (60 - t.second())*1000 - t.msec(); |
71 | timerId = startTimer( ms ); | 75 | timerId = startTimer( ms ); |
72 | } else { | 76 | } else { |
73 | QLabel::timerEvent( e ); | 77 | QLabel::timerEvent( e ); |
74 | } | 78 | } |
75 | } | 79 | } |
76 | 80 | ||
77 | void LauncherClock::updateTime( void ) | 81 | void LauncherClock::updateTime( void ) |
78 | { | 82 | { |
79 | changeTime(); | 83 | changeTime(); |
80 | } | 84 | } |
81 | 85 | ||
82 | void LauncherClock::changeTime( void ) | 86 | void LauncherClock::changeTime( void ) |
83 | { | 87 | { |
84 | QTime tm = QDateTime::currentDateTime().time(); | 88 | QTime tm = QDateTime::currentDateTime().time(); |
85 | QString s; | 89 | QString s; |
86 | if( ampmFormat ) { | 90 | if( ampmFormat ) { |
87 | int hour = tm.hour(); | 91 | int hour = tm.hour(); |
88 | if (hour == 0) | 92 | if (hour == 0) |
89 | hour = 12; | 93 | hour = 12; |
90 | if (hour > 12) | 94 | if (hour > 12) |
91 | hour -= 12; | 95 | hour -= 12; |
92 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 96 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
93 | (tm.hour() >= 12) ? "PM" : "AM" ); | 97 | (tm.hour() >= 12) ? "PM" : "AM" ); |
94 | } else | 98 | } else |
95 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 99 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
96 | 100 | ||
97 | if (format==1) { | 101 | if (format==1) { |
98 | QDate dm = QDate::currentDate(); | 102 | QDate dm = QDate::currentDate(); |
99 | QString d; | 103 | QString d; |
100 | d.sprintf("%d/%d ", dm.day(), dm.month()); | 104 | d.sprintf("%d/%d ", dm.day(), dm.month()); |
101 | setText( d+s ); | 105 | setText( d+s ); |
102 | } else if (format==2) { | 106 | } else if (format==2) { |
103 | QDate dm = QDate::currentDate(); | 107 | QDate dm = QDate::currentDate(); |
104 | QString d; | 108 | QString d; |
105 | d.sprintf("%d/%d ", dm.month(), dm.day()); | 109 | d.sprintf("%d/%d ", dm.month(), dm.day()); |
106 | setText( d+s ); | 110 | setText( d+s ); |
107 | } else { | 111 | } else { |
108 | setText( s ); | 112 | setText( s ); |
109 | } | 113 | } |
110 | } | 114 | } |
111 | 115 | ||
112 | void LauncherClock::slotClockChanged( bool pm ) | 116 | void LauncherClock::slotClockChanged( bool pm ) |
113 | { | 117 | { |
114 | readConfig(); | 118 | readConfig(); |
115 | updateTime(); | 119 | updateTime(); |
116 | } | 120 | } |
117 | 121 | ||
118 | 122 | ||
119 | EXPORT_OPIE_APPLET_v1( LauncherClock ) | 123 | EXPORT_OPIE_APPLET_v1( LauncherClock ) |
120 | 124 | ||
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index 2196d18..7122b40 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -1,363 +1,363 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> | 2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> |
3 | ** Max Reiss <harlekin@handhelds.org> [trivial stuff] | 3 | ** Max Reiss <harlekin@handhelds.org> [trivial stuff] |
4 | ** Robert Griebl <sandman@handhelds.org> | 4 | ** Robert Griebl <sandman@handhelds.org> |
5 | ** Holger Freyther <zecke@handhelds.org> QCOP Interface | 5 | ** Holger Freyther <zecke@handhelds.org> QCOP Interface |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "irda.h" | 17 | #include "irda.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <net/if.h> | 32 | #include <net/if.h> |
33 | #include <netinet/in.h> | 33 | #include <netinet/in.h> |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> |
36 | #include <sys/ioctl.h> | 36 | #include <sys/ioctl.h> |
37 | 37 | ||
38 | //=========================================================================== | 38 | //=========================================================================== |
39 | 39 | ||
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) | 41 | IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) |
42 | : QWidget ( parent, name ) | 42 | : QWidget ( parent, name ) |
43 | { | 43 | { |
44 | setFixedHeight ( 18 ); | 44 | setFixedHeight ( 18 ); |
45 | setFixedWidth ( 14 ); | 45 | setFixedWidth ( 14 ); |
46 | 46 | ||
47 | m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); | 47 | m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); |
48 | 48 | ||
49 | m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); | 49 | m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); |
50 | m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); | 50 | m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); |
51 | m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); | 51 | m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); |
52 | m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); | 52 | m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); |
53 | 53 | ||
54 | m_irda_active = false; | 54 | m_irda_active = false; |
55 | m_irda_discovery_active = false; | 55 | m_irda_discovery_active = false; |
56 | m_receive_active = false; | 56 | m_receive_active = false; |
57 | m_receive_state_changed = false; | 57 | m_receive_state_changed = false; |
58 | m_popup = 0; | 58 | m_popup = 0; |
59 | m_wasOn = false; | 59 | m_wasOn = false; |
60 | m_wasDiscover = false; | 60 | m_wasDiscover = false; |
61 | 61 | ||
62 | QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); | 62 | QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); |
63 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 63 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
64 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | 64 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
65 | } | 65 | } |
66 | 66 | ||
67 | int IrdaApplet::position() | 67 | int IrdaApplet::position() |
68 | { | 68 | { |
69 | return 6; | 69 | return 6; |
70 | } | 70 | } |
71 | 71 | ||
72 | void IrdaApplet::show() | 72 | void IrdaApplet::show() |
73 | { | 73 | { |
74 | QWidget::show ( ); | 74 | QWidget::show ( ); |
75 | startTimer ( 2000 ); | 75 | startTimer ( 2000 ); |
76 | } | 76 | } |
77 | 77 | ||
78 | IrdaApplet::~IrdaApplet() | 78 | IrdaApplet::~IrdaApplet() |
79 | { | 79 | { |
80 | if ( m_sockfd >= 0 ) | 80 | if ( m_sockfd >= 0 ) |
81 | ::close ( m_sockfd ); | 81 | ::close ( m_sockfd ); |
82 | } | 82 | } |
83 | 83 | ||
84 | void IrdaApplet::popup ( QString message, QString icon ) | 84 | void IrdaApplet::popup ( QString message, QString icon ) |
85 | { | 85 | { |
86 | if ( !m_popup ) | 86 | if ( !m_popup ) |
87 | m_popup = new QPopupMenu ( this ); | 87 | m_popup = new QPopupMenu ( this ); |
88 | 88 | ||
89 | m_popup-> clear ( ); | 89 | m_popup-> clear ( ); |
90 | 90 | ||
91 | if ( icon. isEmpty ( )) | 91 | if ( icon. isEmpty ( )) |
92 | m_popup-> insertItem ( message, 0 ); | 92 | m_popup-> insertItem ( message, 0 ); |
93 | else | 93 | else |
94 | m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); | 94 | m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); |
95 | 95 | ||
96 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 96 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
97 | QSize s = m_popup-> sizeHint ( ); | 97 | QSize s = m_popup-> sizeHint ( ); |
98 | m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 98 | m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
99 | p. y ( ) - s. height ( ))); | 99 | p. y ( ) - s. height ( ))); |
100 | 100 | ||
101 | QTimer::singleShot ( 2000, this, SLOT( popupTimeout())); | 101 | QTimer::singleShot ( 2000, this, SLOT( popupTimeout())); |
102 | } | 102 | } |
103 | 103 | ||
104 | void IrdaApplet::popupTimeout ( ) | 104 | void IrdaApplet::popupTimeout ( ) |
105 | { | 105 | { |
106 | m_popup-> hide ( ); | 106 | m_popup-> hide ( ); |
107 | } | 107 | } |
108 | 108 | ||
109 | bool IrdaApplet::checkIrdaStatus ( ) | 109 | bool IrdaApplet::checkIrdaStatus ( ) |
110 | { | 110 | { |
111 | struct ifreq ifr; | 111 | struct ifreq ifr; |
112 | strcpy ( ifr. ifr_name, "irda0" ); | 112 | strcpy ( ifr. ifr_name, "irda0" ); |
113 | 113 | ||
114 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) | 114 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) |
115 | return false; | 115 | return false; |
116 | 116 | ||
117 | return ( ifr. ifr_flags & IFF_UP ); | 117 | return ( ifr. ifr_flags & IFF_UP ); |
118 | } | 118 | } |
119 | 119 | ||
120 | bool IrdaApplet::setIrdaStatus ( bool b ) | 120 | bool IrdaApplet::setIrdaStatus ( bool b ) |
121 | { | 121 | { |
122 | struct ifreq ifr; | 122 | struct ifreq ifr; |
123 | strcpy ( ifr. ifr_name, "irda0" ); | 123 | strcpy ( ifr. ifr_name, "irda0" ); |
124 | 124 | ||
125 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) | 125 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) |
126 | return false; | 126 | return false; |
127 | 127 | ||
128 | if ( b ) { | 128 | if ( b ) { |
129 | ifr. ifr_flags |= IFF_UP; | 129 | ifr. ifr_flags |= IFF_UP; |
130 | } | 130 | } |
131 | else { | 131 | else { |
132 | setIrdaDiscoveryStatus ( 0 ); | 132 | setIrdaDiscoveryStatus ( 0 ); |
133 | setIrdaReceiveStatus ( 0 ); | 133 | setIrdaReceiveStatus ( 0 ); |
134 | ifr. ifr_flags &= ~IFF_UP; | 134 | ifr. ifr_flags &= ~IFF_UP; |
135 | } | 135 | } |
136 | 136 | ||
137 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) | 137 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) |
138 | return false; | 138 | return false; |
139 | 139 | ||
140 | return true; | 140 | return true; |
141 | } | 141 | } |
142 | 142 | ||
143 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) | 143 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) |
144 | { | 144 | { |
145 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 145 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
146 | 146 | ||
147 | QString streamIn = "0"; | 147 | QString streamIn = "0"; |
148 | 148 | ||
149 | if ( discovery. open ( IO_ReadOnly )) { | 149 | if ( discovery. open ( IO_ReadOnly )) { |
150 | QTextStream stream ( &discovery ); | 150 | QTextStream stream ( &discovery ); |
151 | streamIn = stream. read ( ); | 151 | streamIn = stream. read ( ); |
152 | } | 152 | } |
153 | 153 | ||
154 | return streamIn. toInt ( ) > 0; | 154 | return streamIn. toInt ( ) > 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) | 158 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) |
159 | { | 159 | { |
160 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 160 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
161 | 161 | ||
162 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { | 162 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { |
163 | discovery.putch ( d ? '1' : '0' ); | 163 | discovery.putch ( d ? '1' : '0' ); |
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | return false; | 166 | return false; |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) | 170 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) |
171 | { | 171 | { |
172 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); | 172 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); |
173 | e << ( d ? 1 : 0 ); | 173 | e << ( d ? 1 : 0 ); |
174 | 174 | ||
175 | m_receive_active = d; | 175 | m_receive_active = d; |
176 | m_receive_state_changed = true; | 176 | m_receive_state_changed = true; |
177 | 177 | ||
178 | return true; | 178 | return true; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | void IrdaApplet::showDiscovered ( ) | 182 | void IrdaApplet::showDiscovered ( ) |
183 | { | 183 | { |
184 | //static Sound snd_found ( "irdaapplet/irdaon" ); | 184 | //static Sound snd_found ( "irdaapplet/irdaon" ); |
185 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); | 185 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); |
186 | 186 | ||
187 | QFile discovery ( "/proc/net/irda/discovery" ); | 187 | QFile discovery ( "/proc/net/irda/discovery" ); |
188 | 188 | ||
189 | if ( discovery. open ( IO_ReadOnly )) { | 189 | if ( discovery. open ( IO_ReadOnly )) { |
190 | bool qcopsend = false; | 190 | bool qcopsend = false; |
191 | 191 | ||
192 | QString discoveredDevice; | 192 | QString discoveredDevice; |
193 | QString deviceAddr; | 193 | QString deviceAddr; |
194 | 194 | ||
195 | // since it is /proc we _must_ use QTextStream | 195 | // since it is /proc we _must_ use QTextStream |
196 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); | 196 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); |
197 | 197 | ||
198 | QMap <QString, QString>::Iterator it; | 198 | QMap <QString, QString>::Iterator it; |
199 | 199 | ||
200 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 200 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
201 | it. data ( ). prepend ( "+++" ); | 201 | it. data ( ). prepend ( "+++" ); |
202 | 202 | ||
203 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { | 203 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { |
204 | const QString &line = *lit; | 204 | const QString &line = *lit; |
205 | 205 | ||
206 | if ( line. startsWith ( "nickname:" )) { | 206 | if ( line. startsWith ( "nickname:" )) { |
207 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); | 207 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); |
208 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); | 208 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); |
209 | 209 | ||
210 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); | 210 | // odebug << discoveredDevice + "(" + deviceAddr + ")" << oendl; |
211 | 211 | ||
212 | if ( !m_devices. contains ( deviceAddr )) { | 212 | if ( !m_devices. contains ( deviceAddr )) { |
213 | popup ( tr( "Found:" ) + " " + discoveredDevice ); | 213 | popup ( tr( "Found:" ) + " " + discoveredDevice ); |
214 | //snd_found. play ( ); | 214 | //snd_found. play ( ); |
215 | qcopsend = true; | 215 | qcopsend = true; |
216 | } | 216 | } |
217 | m_devices. replace ( deviceAddr, discoveredDevice ); | 217 | m_devices. replace ( deviceAddr, discoveredDevice ); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { | 221 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { |
222 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); | 222 | // odebug << "IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?" << oendl; |
223 | 223 | ||
224 | if ( it. data ( ). left ( 3 ) == "+++" ) { | 224 | if ( it. data ( ). left ( 3 ) == "+++" ) { |
225 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); | 225 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); |
226 | //snd_lost. play ( ); | 226 | //snd_lost. play ( ); |
227 | 227 | ||
228 | QMap <QString, QString>::Iterator tmp = it; | 228 | QMap <QString, QString>::Iterator tmp = it; |
229 | tmp++; | 229 | tmp++; |
230 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator | 230 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator |
231 | it = tmp; | 231 | it = tmp; |
232 | 232 | ||
233 | qcopsend = true; | 233 | qcopsend = true; |
234 | } | 234 | } |
235 | else | 235 | else |
236 | it++; | 236 | it++; |
237 | } | 237 | } |
238 | // XXX if( qcopsend ) { | 238 | // XXX if( qcopsend ) { |
239 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); | 239 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); |
240 | e << ( m_devices. count ( ) > 0 ); | 240 | e << ( m_devices. count ( ) > 0 ); |
241 | // } | 241 | // } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) | 245 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) |
246 | { | 246 | { |
247 | QPopupMenu *menu = new QPopupMenu ( this ); | 247 | QPopupMenu *menu = new QPopupMenu ( this ); |
248 | QString cmd; | 248 | QString cmd; |
249 | 249 | ||
250 | /* Refresh active state */ | 250 | /* Refresh active state */ |
251 | timerEvent ( 0 ); | 251 | timerEvent ( 0 ); |
252 | 252 | ||
253 | //menu->insertItem( tr("More..."), 4 ); | 253 | //menu->insertItem( tr("More..."), 4 ); |
254 | 254 | ||
255 | if ( m_irda_active && !m_devices. isEmpty ( )) { | 255 | if ( m_irda_active && !m_devices. isEmpty ( )) { |
256 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); | 256 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); |
257 | 257 | ||
258 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 258 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
259 | menu-> insertItem ( *it ); | 259 | menu-> insertItem ( *it ); |
260 | 260 | ||
261 | menu-> insertSeparator ( ); | 261 | menu-> insertSeparator ( ); |
262 | } | 262 | } |
263 | 263 | ||
264 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); | 264 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); |
265 | 265 | ||
266 | if ( m_irda_active ) { | 266 | if ( m_irda_active ) { |
267 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); | 267 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); |
268 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); | 268 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); |
269 | } | 269 | } |
270 | 270 | ||
271 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 271 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); |
272 | QSize s = menu-> sizeHint ( ); | 272 | QSize s = menu-> sizeHint ( ); |
273 | 273 | ||
274 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); | 274 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); |
275 | 275 | ||
276 | switch ( menu-> exec ( p )) { | 276 | switch ( menu-> exec ( p )) { |
277 | case 0: | 277 | case 0: |
278 | setIrdaStatus ( !m_irda_active ); | 278 | setIrdaStatus ( !m_irda_active ); |
279 | timerEvent ( 0 ); | 279 | timerEvent ( 0 ); |
280 | break; | 280 | break; |
281 | case 1: | 281 | case 1: |
282 | setIrdaDiscoveryStatus ( !m_irda_discovery_active ); | 282 | setIrdaDiscoveryStatus ( !m_irda_discovery_active ); |
283 | timerEvent ( 0 ); | 283 | timerEvent ( 0 ); |
284 | break; | 284 | break; |
285 | case 2: | 285 | case 2: |
286 | setIrdaReceiveStatus ( !m_receive_active ); | 286 | setIrdaReceiveStatus ( !m_receive_active ); |
287 | timerEvent( 0 ); | 287 | timerEvent( 0 ); |
288 | break; | 288 | break; |
289 | } | 289 | } |
290 | 290 | ||
291 | delete menu; | 291 | delete menu; |
292 | } | 292 | } |
293 | 293 | ||
294 | void IrdaApplet::timerEvent ( QTimerEvent * ) | 294 | void IrdaApplet::timerEvent ( QTimerEvent * ) |
295 | { | 295 | { |
296 | bool oldactive = m_irda_active; | 296 | bool oldactive = m_irda_active; |
297 | bool olddiscovery = m_irda_discovery_active; | 297 | bool olddiscovery = m_irda_discovery_active; |
298 | bool receiveUpdate = false; | 298 | bool receiveUpdate = false; |
299 | 299 | ||
300 | if ( m_receive_state_changed ) { | 300 | if ( m_receive_state_changed ) { |
301 | receiveUpdate = true; | 301 | receiveUpdate = true; |
302 | m_receive_state_changed = false; | 302 | m_receive_state_changed = false; |
303 | } | 303 | } |
304 | 304 | ||
305 | m_irda_active = checkIrdaStatus ( ); | 305 | m_irda_active = checkIrdaStatus ( ); |
306 | m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); | 306 | m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); |
307 | 307 | ||
308 | if ( m_irda_discovery_active ) | 308 | if ( m_irda_discovery_active ) |
309 | showDiscovered ( ); | 309 | showDiscovered ( ); |
310 | 310 | ||
311 | if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) | 311 | if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) |
312 | update ( ); | 312 | update ( ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void IrdaApplet::paintEvent ( QPaintEvent * ) | 315 | void IrdaApplet::paintEvent ( QPaintEvent * ) |
316 | { | 316 | { |
317 | QPainter p ( this ); | 317 | QPainter p ( this ); |
318 | 318 | ||
319 | p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); | 319 | p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); |
320 | 320 | ||
321 | if ( m_irda_discovery_active ) | 321 | if ( m_irda_discovery_active ) |
322 | p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); | 322 | p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); |
323 | 323 | ||
324 | if ( m_receive_active ) | 324 | if ( m_receive_active ) |
325 | p. drawPixmap( 0, 1, m_receiveActivePixmap ); | 325 | p. drawPixmap( 0, 1, m_receiveActivePixmap ); |
326 | } | 326 | } |
327 | /* | 327 | /* |
328 | * We know 3 calls | 328 | * We know 3 calls |
329 | * a) enable | 329 | * a) enable |
330 | * b) disable | 330 | * b) disable |
331 | * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on | 331 | * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on |
332 | * c) listDevices: We will return a list of known devices | 332 | * c) listDevices: We will return a list of known devices |
333 | */ | 333 | */ |
334 | void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) { | 334 | void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) { |
335 | if ( str == "enableIrda()") { | 335 | if ( str == "enableIrda()") { |
336 | m_wasOn = checkIrdaStatus(); | 336 | m_wasOn = checkIrdaStatus(); |
337 | m_wasDiscover = checkIrdaDiscoveryStatus(); | 337 | m_wasDiscover = checkIrdaDiscoveryStatus(); |
338 | if (!m_wasOn) { | 338 | if (!m_wasOn) { |
339 | setIrdaStatus( true ); | 339 | setIrdaStatus( true ); |
340 | } | 340 | } |
341 | if ( !m_wasDiscover ) { | 341 | if ( !m_wasDiscover ) { |
342 | setIrdaDiscoveryStatus ( true ); | 342 | setIrdaDiscoveryStatus ( true ); |
343 | } | 343 | } |
344 | } else if ( str == "disableIrda()") { | 344 | } else if ( str == "disableIrda()") { |
345 | if (!m_wasOn) { | 345 | if (!m_wasOn) { |
346 | setIrdaStatus( false ); | 346 | setIrdaStatus( false ); |
347 | } | 347 | } |
348 | if ( !m_wasDiscover ) { | 348 | if ( !m_wasDiscover ) { |
349 | setIrdaDiscoveryStatus ( false ); | 349 | setIrdaDiscoveryStatus ( false ); |
350 | } | 350 | } |
351 | } else if ( str == "listDevices()") { | 351 | } else if ( str == "listDevices()") { |
352 | QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); | 352 | QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); |
353 | 353 | ||
354 | QStringList list; | 354 | QStringList list; |
355 | QMap<QString, QString>::Iterator it; | 355 | QMap<QString, QString>::Iterator it; |
356 | for (it = m_devices.begin(); it != m_devices.end(); ++it ) | 356 | for (it = m_devices.begin(); it != m_devices.end(); ++it ) |
357 | list << (*it); | 357 | list << (*it); |
358 | 358 | ||
359 | e << list; | 359 | e << list; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | EXPORT_OPIE_APPLET_v1( IrdaApplet ) | 363 | EXPORT_OPIE_APPLET_v1( IrdaApplet ) |
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index 195ada5..195d8a4 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp | |||
@@ -1,142 +1,142 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru | 2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "multikey.h" | 15 | #include "multikey.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/otaskbarapplet.h> | 18 | #include <opie2/otaskbarapplet.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | 21 | ||
22 | /* QT */ | 22 | /* QT */ |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | 24 | ||
25 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
26 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") | 26 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") |
27 | { | 27 | { |
28 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); | 28 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); |
29 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 29 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
30 | this, SLOT(message(const QCString&,const QByteArray&))); | 30 | this, SLOT(message(const QCString&,const QByteArray&))); |
31 | 31 | ||
32 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); | 32 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); |
33 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); | 33 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); |
34 | lang = 0; | 34 | lang = 0; |
35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); | 35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); |
36 | setText("EN"); | 36 | setText("EN"); |
37 | popupMenu.insertItem("EN", 0); | 37 | popupMenu.insertItem("EN", 0); |
38 | show(); | 38 | show(); |
39 | } | 39 | } |
40 | 40 | ||
41 | void Multikey::mousePressEvent(QMouseEvent *ev) | 41 | void Multikey::mousePressEvent(QMouseEvent *ev) |
42 | { | 42 | { |
43 | if (!sw_maps.count()) | 43 | if (!sw_maps.count()) |
44 | return; | 44 | return; |
45 | 45 | ||
46 | if (ev->button() == RightButton) { | 46 | if (ev->button() == RightButton) { |
47 | 47 | ||
48 | QPoint p = mapToGlobal(QPoint(0, 0)); | 48 | QPoint p = mapToGlobal(QPoint(0, 0)); |
49 | QSize s = popupMenu.sizeHint(); | 49 | QSize s = popupMenu.sizeHint(); |
50 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 50 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
51 | p.y() - s.height()), 0); | 51 | p.y() - s.height()), 0); |
52 | 52 | ||
53 | if (opt == -1) | 53 | if (opt == -1) |
54 | return; | 54 | return; |
55 | lang = opt; | 55 | lang = opt; |
56 | 56 | ||
57 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 57 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
58 | e << sw_maps[lang]; | 58 | e << sw_maps[lang]; |
59 | setText(labels[lang]); | 59 | setText(labels[lang]); |
60 | } | 60 | } |
61 | QWidget::mousePressEvent(ev); | 61 | QWidget::mousePressEvent(ev); |
62 | } | 62 | } |
63 | 63 | ||
64 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) | 64 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) |
65 | { | 65 | { |
66 | if (!sw_maps.count()) | 66 | if (!sw_maps.count()) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; | 69 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; |
70 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 70 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
71 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); | 71 | //odebug << "Lang=" << lang << ", count=" << sw_maps.count() << ", lab=" << labels[lang].ascii() << "" << oendl; |
72 | e << sw_maps[lang]; | 72 | e << sw_maps[lang]; |
73 | setText(labels[lang]); | 73 | setText(labels[lang]); |
74 | } | 74 | } |
75 | 75 | ||
76 | void Multikey::message(const QCString &message, const QByteArray &data) | 76 | void Multikey::message(const QCString &message, const QByteArray &data) |
77 | { | 77 | { |
78 | if ( message == "setsw(QString,QString)" ) { | 78 | if ( message == "setsw(QString,QString)" ) { |
79 | 79 | ||
80 | QDataStream stream(data, IO_ReadOnly); | 80 | QDataStream stream(data, IO_ReadOnly); |
81 | QString maps, current_map; | 81 | QString maps, current_map; |
82 | stream >> maps >> current_map; | 82 | stream >> maps >> current_map; |
83 | QStringList sw = QStringList::split(QChar('|'), maps); | 83 | QStringList sw = QStringList::split(QChar('|'), maps); |
84 | sw.append(current_map); | 84 | sw.append(current_map); |
85 | 85 | ||
86 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); | 86 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); |
87 | lang = 0; | 87 | lang = 0; |
88 | labels.clear(); | 88 | labels.clear(); |
89 | sw_maps.clear(); | 89 | sw_maps.clear(); |
90 | popupMenu.clear(); | 90 | popupMenu.clear(); |
91 | 91 | ||
92 | for (uint i = 0; i < sw.count(); ++i) { | 92 | for (uint i = 0; i < sw.count(); ++i) { |
93 | QString keymap_map; | 93 | QString keymap_map; |
94 | if (sw[i][0] != '/') { | 94 | if (sw[i][0] != '/') { |
95 | 95 | ||
96 | keymap_map = map_dir.absPath() + "/" + sw[i]; | 96 | keymap_map = map_dir.absPath() + "/" + sw[i]; |
97 | } else { | 97 | } else { |
98 | 98 | ||
99 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) | 99 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) |
100 | && i != sw.count()-1) || !QFile::exists(sw[i])) { | 100 | && i != sw.count()-1) || !QFile::exists(sw[i])) { |
101 | continue; | 101 | continue; |
102 | } | 102 | } |
103 | keymap_map = sw[i]; | 103 | keymap_map = sw[i]; |
104 | } | 104 | } |
105 | 105 | ||
106 | QFile map(keymap_map); | 106 | QFile map(keymap_map); |
107 | if (map.open(IO_ReadOnly)) { | 107 | if (map.open(IO_ReadOnly)) { |
108 | QString line; | 108 | QString line; |
109 | 109 | ||
110 | map.readLine(line, 1024); | 110 | map.readLine(line, 1024); |
111 | while (!map.atEnd()) { | 111 | while (!map.atEnd()) { |
112 | 112 | ||
113 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { | 113 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { |
114 | 114 | ||
115 | if (i != sw.count()-1) { | 115 | if (i != sw.count()-1) { |
116 | if (keymap_map == current_map) { | 116 | if (keymap_map == current_map) { |
117 | lang = i; | 117 | lang = i; |
118 | } | 118 | } |
119 | sw_maps.append(keymap_map); | 119 | sw_maps.append(keymap_map); |
120 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 120 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
121 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); | 121 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); |
122 | } else { | 122 | } else { |
123 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); | 123 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); |
124 | } | 124 | } |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | map.readLine(line, 1024); | 127 | map.readLine(line, 1024); |
128 | } | 128 | } |
129 | map.close(); | 129 | map.close(); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | setText(current); | 133 | setText(current); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | int Multikey::position() | 137 | int Multikey::position() |
138 | { | 138 | { |
139 | return 10; | 139 | return 10; |
140 | } | 140 | } |
141 | 141 | ||
142 | EXPORT_OPIE_APPLET_v1( Multikey ) | 142 | EXPORT_OPIE_APPLET_v1( Multikey ) |
diff --git a/core/applets/restartapplet/restart.cpp b/core/applets/restartapplet/restart.cpp index 226c2a8..2e17608 100644 --- a/core/applets/restartapplet/restart.cpp +++ b/core/applets/restartapplet/restart.cpp | |||
@@ -1,72 +1,70 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | 2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "restart.h" | 15 | #include "restart.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
19 | #include <qpainter.h> | 19 | #include <qpainter.h> |
20 | 20 | ||
21 | 21 | ||
22 | /* XPM */ | 22 | /* XPM */ |
23 | static char *restart_xpm[] = { | 23 | static char *restart_xpm[] = { |
24 | "16 16 11 1", | 24 | "16 16 11 1", |
25 | " c None", | 25 | " c None", |
26 | ". c #000000", | 26 | ". c #000000", |
27 | "+ c #DCDCDC", | 27 | "+ c #DCDCDC", |
28 | "@ c #A0A0A0", | 28 | "@ c #A0A0A0", |
29 | "# c #C3C3C3", | 29 | "# c #C3C3C3", |
30 | "$ c #808080", | 30 | "$ c #808080", |
31 | "% c #FFA858", | 31 | "% c #FFA858", |
32 | "& c #FFDCA8", | 32 | "& c #FFDCA8", |
33 | "* c #FFFFC0", | 33 | "* c #FFFFC0", |
34 | "= c #FFFFFF", | 34 | "= c #FFFFFF", |
35 | "- c #585858", | 35 | "- c #585858", |
36 | " .. ", | 36 | " .. ", |
37 | " .. .++. .. ", | 37 | " .. .++. .. ", |
38 | " .+@.@##@.@+. ", | 38 | " .+@.@##@.@+. ", |
39 | " .@+$@%%@$+@. ", | 39 | " .@+$@%%@$+@. ", |
40 | " .$%%&%&%$. ", | 40 | " .$%%&%&%$. ", |
41 | " ..+@%&$$%&@+.. ", | 41 | " ..+@%&$$%&@+.. ", |
42 | ".+#@%&%@@&*%@#+.", | 42 | ".+#@%&%@@&*%@#+.", |
43 | ".$@+$&*&&=*$+@$.", | 43 | ".$@+$&*&&=*$+@$.", |
44 | " .--+$&*=&$+--. ", | 44 | " .--+$&*=&$+--. ", |
45 | " .$#++$$++#$. ", | 45 | " .$#++$$++#$. ", |
46 | " .@=$-$++$-$=@. ", | 46 | " .@=$-$++$-$=@. ", |
47 | " .+@-..@@..-@+. ", | 47 | " .+@-..@@..-@+. ", |
48 | " ... .+=. ... ", | 48 | " ... .+=. ... ", |
49 | " .-$. ", | 49 | " .-$. ", |
50 | " .. ", | 50 | " .. ", |
51 | " "}; | 51 | " "}; |
52 | RestartApplet::RestartApplet( QWidget *parent, const char *name ) | 52 | RestartApplet::RestartApplet( QWidget *parent, const char *name ) |
53 | : QWidget( parent, name ) { | 53 | : QWidget( parent, name ) { |
54 | setFixedHeight( 18 ); | 54 | setFixedHeight( 18 ); |
55 | setFixedWidth( 16 ); | 55 | setFixedWidth( 16 ); |
56 | qDebug("new restartapplet"); | ||
57 | show(); | 56 | show(); |
58 | } | 57 | } |
59 | 58 | ||
60 | RestartApplet::~RestartApplet() { | 59 | RestartApplet::~RestartApplet() { |
61 | } | 60 | } |
62 | 61 | ||
63 | void RestartApplet::mousePressEvent( QMouseEvent *) { | 62 | void RestartApplet::mousePressEvent( QMouseEvent *) { |
64 | QCopEnvelope e("QPE/System", "restart()"); | 63 | QCopEnvelope e("QPE/System", "restart()"); |
65 | } | 64 | } |
66 | 65 | ||
67 | void RestartApplet::paintEvent( QPaintEvent* ) { | 66 | void RestartApplet::paintEvent( QPaintEvent* ) { |
68 | QPainter p(this); | 67 | QPainter p(this); |
69 | qDebug("paint RESTART pixmap"); | ||
70 | p.drawPixmap( 0, 1, ( const char** ) restart_xpm ); | 68 | p.drawPixmap( 0, 1, ( const char** ) restart_xpm ); |
71 | } | 69 | } |
72 | 70 | ||
diff --git a/core/applets/restartapplet/restartappletimpl.cpp b/core/applets/restartapplet/restartappletimpl.cpp index d8e10d3..3adc80c 100644 --- a/core/applets/restartapplet/restartappletimpl.cpp +++ b/core/applets/restartapplet/restartappletimpl.cpp | |||
@@ -1,67 +1,66 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "restart.h" | 20 | #include "restart.h" |
21 | #include "restartappletimpl.h" | 21 | #include "restartappletimpl.h" |
22 | 22 | ||
23 | 23 | ||
24 | RestartAppletImpl::RestartAppletImpl() | 24 | RestartAppletImpl::RestartAppletImpl() |
25 | : restart(0) | 25 | : restart(0) |
26 | { | 26 | { |
27 | } | 27 | } |
28 | 28 | ||
29 | RestartAppletImpl::~RestartAppletImpl() | 29 | RestartAppletImpl::~RestartAppletImpl() |
30 | { | 30 | { |
31 | delete restart; | 31 | delete restart; |
32 | } | 32 | } |
33 | 33 | ||
34 | QWidget *RestartAppletImpl::applet( QWidget *parent ) | 34 | QWidget *RestartAppletImpl::applet( QWidget *parent ) |
35 | { | 35 | { |
36 | qDebug("restart applet"); | ||
37 | if ( !restart ) | 36 | if ( !restart ) |
38 | restart = new RestartApplet( parent ); | 37 | restart = new RestartApplet( parent ); |
39 | return restart; | 38 | return restart; |
40 | } | 39 | } |
41 | 40 | ||
42 | int RestartAppletImpl::position() const | 41 | int RestartAppletImpl::position() const |
43 | { | 42 | { |
44 | return 6; | 43 | return 6; |
45 | } | 44 | } |
46 | 45 | ||
47 | QRESULT RestartAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 46 | QRESULT RestartAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
48 | { | 47 | { |
49 | *iface = 0; | 48 | *iface = 0; |
50 | if ( uuid == IID_QUnknown ) | 49 | if ( uuid == IID_QUnknown ) |
51 | *iface = this; | 50 | *iface = this; |
52 | else if ( uuid == IID_TaskbarApplet ) | 51 | else if ( uuid == IID_TaskbarApplet ) |
53 | *iface = this; | 52 | *iface = this; |
54 | else | 53 | else |
55 | return QS_FALSE; | 54 | return QS_FALSE; |
56 | 55 | ||
57 | if ( *iface ) | 56 | if ( *iface ) |
58 | (*iface)->addRef(); | 57 | (*iface)->addRef(); |
59 | return QS_OK; | 58 | return QS_OK; |
60 | } | 59 | } |
61 | 60 | ||
62 | Q_EXPORT_INTERFACE() | 61 | Q_EXPORT_INTERFACE() |
63 | { | 62 | { |
64 | Q_CREATE_INSTANCE( RestartAppletImpl ) | 63 | Q_CREATE_INSTANCE( RestartAppletImpl ) |
65 | } | 64 | } |
66 | 65 | ||
67 | 66 | ||
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index f621aa9..f23423d 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,252 +1,253 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> | 4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> |
5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> | 5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This library is free software; you can | 8 | _;:, .> :=|. This library is free software; you can |
9 | .> <, > . <= redistribute it and/or modify it under | 9 | .> <, > . <= redistribute it and/or modify it under |
10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%+i> _;_. | 14 | .%+i> _;_. |
15 | .i_,=:_. -<s. This library is distributed in the hope that | 15 | .i_,=:_. -<s. This library is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. . .: details. | 21 | ++= -. . .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-= this library; see the file COPYING.LIB. | 25 | -- :-= this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "rotate.h" | 31 | #include "rotate.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | ||
34 | #include <opie2/odevice.h> | 35 | #include <opie2/odevice.h> |
35 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
36 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
39 | using namespace Opie::Core; | 40 | using namespace Opie::Core; |
40 | 41 | ||
41 | /* QT */ | 42 | /* QT */ |
42 | 43 | ||
43 | #include <time.h> | 44 | #include <time.h> |
44 | 45 | ||
45 | RotateApplet::RotateApplet() | 46 | RotateApplet::RotateApplet() |
46 | :QObject( 0, "RotateApplet" ), m_flipped( false ) | 47 | :QObject( 0, "RotateApplet" ), m_flipped( false ) |
47 | { | 48 | { |
48 | 49 | ||
49 | #if !defined(QT_NO_COP) | 50 | #if !defined(QT_NO_COP) |
50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); | 51 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); |
51 | connect ( rotateChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 52 | connect ( rotateChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
52 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); | 53 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
53 | #endif | 54 | #endif |
54 | 55 | ||
55 | } | 56 | } |
56 | 57 | ||
57 | RotateApplet::~RotateApplet ( ) | 58 | RotateApplet::~RotateApplet ( ) |
58 | {} | 59 | {} |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * Qcop receive method. | 62 | * Qcop receive method. |
62 | */ | 63 | */ |
63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) | 64 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) |
64 | { | 65 | { |
65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); | 66 | odebug << "RotateApplet::channelReceived( '" << msg << "' )" << oendl; |
66 | 67 | ||
67 | if ( ODevice::inst()->hasHingeSensor() ) | 68 | if ( ODevice::inst()->hasHingeSensor() ) |
68 | { | 69 | { |
69 | struct timespec interval; | 70 | struct timespec interval; |
70 | struct timespec remain; | 71 | struct timespec remain; |
71 | interval.tv_sec = 0; | 72 | interval.tv_sec = 0; |
72 | interval.tv_nsec = 600000; | 73 | interval.tv_nsec = 600000; |
73 | ::nanosleep( &interval, &remain ); | 74 | ::nanosleep( &interval, &remain ); |
74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); | 75 | OHingeStatus status = ODevice::inst()->readHingeSensor(); |
75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); | 76 | odebug << "RotateApplet::readHingeSensor = " << (int) status << "" << oendl; |
76 | 77 | ||
77 | Config cfg( "apm" ); | 78 | Config cfg( "apm" ); |
78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); | 79 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); |
79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); | 80 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); |
80 | 81 | ||
81 | if ( status == CASE_CLOSED ) | 82 | if ( status == CASE_CLOSED ) |
82 | { | 83 | { |
83 | switch ( action ) | 84 | switch ( action ) |
84 | { | 85 | { |
85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; | 86 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; |
86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; | 87 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; |
87 | default: /* IGNORE */ break; | 88 | default: /* IGNORE */ break; |
88 | } | 89 | } |
89 | } | 90 | } |
90 | else /* status != CASE_CLOSED */ | 91 | else /* status != CASE_CLOSED */ |
91 | { | 92 | { |
92 | switch ( action ) | 93 | switch ( action ) |
93 | { | 94 | { |
94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; | 95 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; |
95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; | 96 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; |
96 | default: /* IGNORE */ break; | 97 | default: /* IGNORE */ break; |
97 | } | 98 | } |
98 | } | 99 | } |
99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); | 100 | odebug << "RotateApplet::switchAction " << cfg.readNumEntry( "CloseHingeAction" ) << " performed." << oendl; |
100 | } | 101 | } |
101 | 102 | ||
102 | QDataStream stream( data, IO_ReadOnly ); | 103 | QDataStream stream( data, IO_ReadOnly ); |
103 | if ( msg == "flip()" ) | 104 | if ( msg == "flip()" ) |
104 | { | 105 | { |
105 | activated ( ); | 106 | activated ( ); |
106 | } | 107 | } |
107 | else if ( msg == "rotateDefault()") | 108 | else if ( msg == "rotateDefault()") |
108 | { | 109 | { |
109 | rotateDefault(); | 110 | rotateDefault(); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | 113 | ||
113 | int RotateApplet::position() const | 114 | int RotateApplet::position() const |
114 | { | 115 | { |
115 | return 3; | 116 | return 3; |
116 | } | 117 | } |
117 | 118 | ||
118 | QString RotateApplet::name() const | 119 | QString RotateApplet::name() const |
119 | { | 120 | { |
120 | return tr( "Rotate shortcut" ); | 121 | return tr( "Rotate shortcut" ); |
121 | } | 122 | } |
122 | 123 | ||
123 | QString RotateApplet::text() const | 124 | QString RotateApplet::text() const |
124 | { | 125 | { |
125 | return tr( "Rotate" ); | 126 | return tr( "Rotate" ); |
126 | } | 127 | } |
127 | 128 | ||
128 | /*QString RotateApplet::tr( const char* s ) const | 129 | /*QString RotateApplet::tr( const char* s ) const |
129 | { | 130 | { |
130 | return qApp->translate( "RotateApplet", s, 0 ); | 131 | return qApp->translate( "RotateApplet", s, 0 ); |
131 | } | 132 | } |
132 | 133 | ||
133 | QString RotateApplet::tr( const char* s, const char* p ) const | 134 | QString RotateApplet::tr( const char* s, const char* p ) const |
134 | { | 135 | { |
135 | return qApp->translate( "RotateApplet", s, p ); | 136 | return qApp->translate( "RotateApplet", s, p ); |
136 | } | 137 | } |
137 | */ | 138 | */ |
138 | 139 | ||
139 | QIconSet RotateApplet::icon() const | 140 | QIconSet RotateApplet::icon() const |
140 | { | 141 | { |
141 | QPixmap pix; | 142 | QPixmap pix; |
142 | QImage img = Resource::loadImage( "Rotation" ); | 143 | QImage img = Resource::loadImage( "Rotation" ); |
143 | if ( !img.isNull() ) | 144 | if ( !img.isNull() ) |
144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); | 145 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); |
145 | return pix; | 146 | return pix; |
146 | } | 147 | } |
147 | 148 | ||
148 | QPopupMenu* RotateApplet::popup(QWidget*) const | 149 | QPopupMenu* RotateApplet::popup(QWidget*) const |
149 | { | 150 | { |
150 | return 0; | 151 | return 0; |
151 | } | 152 | } |
152 | 153 | ||
153 | void RotateApplet::rotateDefault() | 154 | void RotateApplet::rotateDefault() |
154 | { | 155 | { |
155 | int rot = ODevice::inst()->rotation(); | 156 | int rot = ODevice::inst()->rotation(); |
156 | 157 | ||
157 | switch (rot) | 158 | switch (rot) |
158 | { | 159 | { |
159 | case Rot0: rot=0; break; | 160 | case Rot0: rot=0; break; |
160 | case Rot90: rot=90; break; | 161 | case Rot90: rot=90; break; |
161 | case Rot180: rot=180; break; | 162 | case Rot180: rot=180; break; |
162 | case Rot270: rot=270; break; | 163 | case Rot270: rot=270; break; |
163 | default: rot=0; break; | 164 | default: rot=0; break; |
164 | } | 165 | } |
165 | 166 | ||
166 | Config cfg( "qpe" ); | 167 | Config cfg( "qpe" ); |
167 | cfg.setGroup( "Appearance" ); | 168 | cfg.setGroup( "Appearance" ); |
168 | 169 | ||
169 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); | 170 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); |
170 | 171 | ||
171 | if ( !rotateEnabled) return; | 172 | if ( !rotateEnabled) return; |
172 | 173 | ||
173 | // hide inputs methods before rotation | 174 | // hide inputs methods before rotation |
174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 175 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
175 | 176 | ||
176 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 177 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
177 | env << rot; | 178 | env << rot; |
178 | 179 | ||
179 | m_flipped = false; | 180 | m_flipped = false; |
180 | 181 | ||
181 | } | 182 | } |
182 | void RotateApplet::activated() | 183 | void RotateApplet::activated() |
183 | { | 184 | { |
184 | int defaultRotation = QPEApplication::defaultRotation(); | 185 | int defaultRotation = QPEApplication::defaultRotation(); |
185 | int newRotation = defaultRotation; | 186 | int newRotation = defaultRotation; |
186 | 187 | ||
187 | Config cfg( "qpe" ); | 188 | Config cfg( "qpe" ); |
188 | cfg.setGroup( "Appearance" ); | 189 | cfg.setGroup( "Appearance" ); |
189 | 190 | ||
190 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 191 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
191 | ODirection rot = CW; | 192 | ODirection rot = CW; |
192 | 193 | ||
193 | if (rotDirection == -1) | 194 | if (rotDirection == -1) |
194 | { | 195 | { |
195 | rot = ODevice::inst()->direction(); | 196 | rot = ODevice::inst()->direction(); |
196 | } | 197 | } |
197 | else | 198 | else |
198 | { | 199 | { |
199 | rot = (ODirection) rotDirection; | 200 | rot = (ODirection) rotDirection; |
200 | } | 201 | } |
201 | 202 | ||
202 | // hide inputs methods before rotation | 203 | // hide inputs methods before rotation |
203 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 204 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
204 | 205 | ||
205 | if ( m_flipped ) | 206 | if ( m_flipped ) |
206 | { | 207 | { |
207 | // if flipped, flip back to the original state, | 208 | // if flipped, flip back to the original state, |
208 | // regardless of rotation direction | 209 | // regardless of rotation direction |
209 | newRotation = defaultRotation; | 210 | newRotation = defaultRotation; |
210 | } | 211 | } |
211 | else | 212 | else |
212 | { | 213 | { |
213 | if ( rot == CCW ) | 214 | if ( rot == CCW ) |
214 | { | 215 | { |
215 | newRotation = ( defaultRotation + 90 ) % 360; | 216 | newRotation = ( defaultRotation + 90 ) % 360; |
216 | } | 217 | } |
217 | else if ( rot == CW ) | 218 | else if ( rot == CW ) |
218 | { | 219 | { |
219 | newRotation = ( defaultRotation + 270 ) % 360; | 220 | newRotation = ( defaultRotation + 270 ) % 360; |
220 | } | 221 | } |
221 | else if ( rot == Flip ) | 222 | else if ( rot == Flip ) |
222 | { | 223 | { |
223 | newRotation = ( defaultRotation + 180 ) % 360; | 224 | newRotation = ( defaultRotation + 180 ) % 360; |
224 | } | 225 | } |
225 | } | 226 | } |
226 | 227 | ||
227 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 228 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
228 | env << newRotation; | 229 | env << newRotation; |
229 | 230 | ||
230 | m_flipped = !m_flipped; | 231 | m_flipped = !m_flipped; |
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
234 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 235 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
235 | { | 236 | { |
236 | *iface = 0; | 237 | *iface = 0; |
237 | if ( uuid == IID_QUnknown ) | 238 | if ( uuid == IID_QUnknown ) |
238 | *iface = this; | 239 | *iface = this; |
239 | else if ( uuid == IID_MenuApplet ) | 240 | else if ( uuid == IID_MenuApplet ) |
240 | *iface = this; | 241 | *iface = this; |
241 | else | 242 | else |
242 | return QS_FALSE; | 243 | return QS_FALSE; |
243 | 244 | ||
244 | if ( *iface ) | 245 | if ( *iface ) |
245 | (*iface)->addRef(); | 246 | (*iface)->addRef(); |
246 | return QS_OK; | 247 | return QS_OK; |
247 | } | 248 | } |
248 | 249 | ||
249 | Q_EXPORT_INTERFACE() | 250 | Q_EXPORT_INTERFACE() |
250 | { | 251 | { |
251 | Q_CREATE_INSTANCE( RotateApplet ) | 252 | Q_CREATE_INSTANCE( RotateApplet ) |
252 | } | 253 | } |
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 9aa012a..938ea0c 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -1,542 +1,544 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | 2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "screenshot.h" | 15 | #include "screenshot.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/odebug.h> | ||
19 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
20 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | using namespace Opie::Core; | ||
24 | using namespace Opie::Ui; | ||
22 | 25 | ||
23 | /* QT */ | 26 | /* QT */ |
24 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
25 | #include <qdir.h> | 28 | #include <qdir.h> |
26 | #include <qlabel.h> | 29 | #include <qlabel.h> |
27 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
28 | #include <qpainter.h> | 31 | #include <qpainter.h> |
29 | #include <qspinbox.h> | 32 | #include <qspinbox.h> |
30 | #include <qlayout.h> | 33 | #include <qlayout.h> |
31 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
32 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
33 | 36 | ||
34 | /* STD */ | 37 | /* STD */ |
35 | #include <stdlib.h> | 38 | #include <stdlib.h> |
36 | #include <sys/socket.h> | 39 | #include <sys/socket.h> |
37 | #include <netinet/in.h> | 40 | #include <netinet/in.h> |
38 | #include <netdb.h> | 41 | #include <netdb.h> |
39 | #include <unistd.h> | 42 | #include <unistd.h> |
40 | 43 | ||
41 | /* XPM */ | 44 | /* XPM */ |
42 | using namespace Opie::Ui; | ||
43 | static char * snapshot_xpm[] = { | 45 | static char * snapshot_xpm[] = { |
44 | "32 32 177 2", | 46 | "32 32 177 2", |
45 | " c None", | 47 | " c None", |
46 | ". c #042045", | 48 | ". c #042045", |
47 | "+ c #0D2B47", | 49 | "+ c #0D2B47", |
48 | "@ c #0E325E", | 50 | "@ c #0E325E", |
49 | "# c #0D2E50", | 51 | "# c #0D2E50", |
50 | "$ c #0A1C32", | 52 | "$ c #0A1C32", |
51 | "% c #0F3A69", | 53 | "% c #0F3A69", |
52 | "& c #164680", | 54 | "& c #164680", |
53 | "* c #165EAE", | 55 | "* c #165EAE", |
54 | "= c #134D89", | 56 | "= c #134D89", |
55 | "- c #0A3A6E", | 57 | "- c #0A3A6E", |
56 | "; c #031024", | 58 | "; c #031024", |
57 | "> c #031B36", | 59 | "> c #031B36", |
58 | ", c #1A5EA3", | 60 | ", c #1A5EA3", |
59 | "' c #1862B1", | 61 | "' c #1862B1", |
60 | ") c #1866B9", | 62 | ") c #1866B9", |
61 | "! c #0F5AAC", | 63 | "! c #0F5AAC", |
62 | "~ c #0F56A8", | 64 | "~ c #0F56A8", |
63 | "{ c #0C4C96", | 65 | "{ c #0C4C96", |
64 | "] c #030918", | 66 | "] c #030918", |
65 | "^ c #060206", | 67 | "^ c #060206", |
66 | "/ c #20242C", | 68 | "/ c #20242C", |
67 | "( c #3E3B3B", | 69 | "( c #3E3B3B", |
68 | "_ c #186ABD", | 70 | "_ c #186ABD", |
69 | ": c #115EB3", | 71 | ": c #115EB3", |
70 | "< c #082644", | 72 | "< c #082644", |
71 | "[ c #222C38", | 73 | "[ c #222C38", |
72 | "} c #5A5859", | 74 | "} c #5A5859", |
73 | "| c #091921", | 75 | "| c #091921", |
74 | "1 c #1E7EDE", | 76 | "1 c #1E7EDE", |
75 | "2 c #1A7ADA", | 77 | "2 c #1A7ADA", |
76 | "3 c #1970CD", | 78 | "3 c #1970CD", |
77 | "4 c #1758A1", | 79 | "4 c #1758A1", |
78 | "5 c #0E529A", | 80 | "5 c #0E529A", |
79 | "6 c #094388", | 81 | "6 c #094388", |
80 | "7 c #22364E", | 82 | "7 c #22364E", |
81 | "8 c #384454", | 83 | "8 c #384454", |
82 | "9 c #04162C", | 84 | "9 c #04162C", |
83 | "0 c #123451", | 85 | "0 c #123451", |
84 | "a c #3296B4", | 86 | "a c #3296B4", |
85 | "b c #298AB1", | 87 | "b c #298AB1", |
86 | "c c #2484AC", | 88 | "c c #2484AC", |
87 | "d c #033D86", | 89 | "d c #033D86", |
88 | "e c #033677", | 90 | "e c #033677", |
89 | "f c #072C58", | 91 | "f c #072C58", |
90 | "g c #525862", | 92 | "g c #525862", |
91 | "h c #5E5E5E", | 93 | "h c #5E5E5E", |
92 | "i c #23492A", | 94 | "i c #23492A", |
93 | "j c #4FBD3F", | 95 | "j c #4FBD3F", |
94 | "k c #50B24C", | 96 | "k c #50B24C", |
95 | "l c #51C72E", | 97 | "l c #51C72E", |
96 | "m c #42C64A", | 98 | "m c #42C64A", |
97 | "n c #2686CA", | 99 | "n c #2686CA", |
98 | "o c #0B52A4", | 100 | "o c #0B52A4", |
99 | "p c #054A9A", | 101 | "p c #054A9A", |
100 | "q c #053B7C", | 102 | "q c #053B7C", |
101 | "r c #2B2325", | 103 | "r c #2B2325", |
102 | "s c #6E7070", | 104 | "s c #6E7070", |
103 | "t c #0D240E", | 105 | "t c #0D240E", |
104 | "u c #1E423E", | 106 | "u c #1E423E", |
105 | "v c #468ABE", | 107 | "v c #468ABE", |
106 | "w c #6A8AC2", | 108 | "w c #6A8AC2", |
107 | "x c #7EAA8E", | 109 | "x c #7EAA8E", |
108 | "y c #84BE4E", | 110 | "y c #84BE4E", |
109 | "z c #65C639", | 111 | "z c #65C639", |
110 | "A c #064EA0", | 112 | "A c #064EA0", |
111 | "B c #0A4DA0", | 113 | "B c #0A4DA0", |
112 | "C c #4E5242", | 114 | "C c #4E5242", |
113 | "D c #62362E", | 115 | "D c #62362E", |
114 | "E c #721A1A", | 116 | "E c #721A1A", |
115 | "F c #6E0A0A", | 117 | "F c #6E0A0A", |
116 | "G c #3E0E0E", | 118 | "G c #3E0E0E", |
117 | "H c #6AB85E", | 119 | "H c #6AB85E", |
118 | "I c #7E8ECA", | 120 | "I c #7E8ECA", |
119 | "J c #929CD4", | 121 | "J c #929CD4", |
120 | "K c #9EAECA", | 122 | "K c #9EAECA", |
121 | "L c #9EBEAE", | 123 | "L c #9EBEAE", |
122 | "M c #8EC26A", | 124 | "M c #8EC26A", |
123 | "N c #32A276", | 125 | "N c #32A276", |
124 | "O c #20518C", | 126 | "O c #20518C", |
125 | "P c #46566E", | 127 | "P c #46566E", |
126 | "Q c #614A51", | 128 | "Q c #614A51", |
127 | "R c #AE2A26", | 129 | "R c #AE2A26", |
128 | "S c #C41C1A", | 130 | "S c #C41C1A", |
129 | "T c #CE0A0A", | 131 | "T c #CE0A0A", |
130 | "U c #A60606", | 132 | "U c #A60606", |
131 | "V c #921616", | 133 | "V c #921616", |
132 | "W c #863735", | 134 | "W c #863735", |
133 | "X c #866A66", | 135 | "X c #866A66", |
134 | "Y c #9E9EA2", | 136 | "Y c #9E9EA2", |
135 | "Z c #1E5212", | 137 | "Z c #1E5212", |
136 | "` c #7EC652", | 138 | "` c #7EC652", |
137 | " .c #B2B2F2", | 139 | " . c #B2B2F2", |
138 | "..c #CACAF6", | 140 | ".. c #CACAF6", |
139 | "+.c #AECEC6", | 141 | "+. c #AECEC6", |
140 | "@.c #92CE72", | 142 | "@. c #92CE72", |
141 | "#.c #42AA86", | 143 | "#. c #42AA86", |
142 | "$.c #365E96", | 144 | "$. c #365E96", |
143 | "%.c #B82420", | 145 | "%. c #B82420", |
144 | "&.c #E20E0E", | 146 | "&. c #E20E0E", |
145 | "*.c #EF0E0B", | 147 | "*. c #EF0E0B", |
146 | "=.c #566A86", | 148 | "=. c #566A86", |
147 | "-.c #92929A", | 149 | "-. c #92929A", |
148 | ";.c #16260E", | 150 | ";. c #16260E", |
149 | ">.c #2E571A", | 151 | ">. c #2E571A", |
150 | ",.c #7ED64E", | 152 | ",. c #7ED64E", |
151 | "'.c #9ECEB2", | 153 | "'. c #9ECEB2", |
152 | ").c #C6D5EF", | 154 | "). c #C6D5EF", |
153 | "!.c #E2E0FE", | 155 | "!. c #E2E0FE", |
154 | "~.c #A2DE8A", | 156 | "~. c #A2DE8A", |
155 | "{.c #4AAA5B", | 157 | "{. c #4AAA5B", |
156 | "].c #2A6AB2", | 158 | "]. c #2A6AB2", |
157 | "^.c #9A7A6E", | 159 | "^. c #9A7A6E", |
158 | "/.c #D25A52", | 160 | "/. c #D25A52", |
159 | "(.c #F62626", | 161 | "(. c #F62626", |
160 | "_.c #FA0206", | 162 | "_. c #FA0206", |
161 | ":.c #DE1E16", | 163 | ":. c #DE1E16", |
162 | "<.c #B63A26", | 164 | "<. c #B63A26", |
163 | "[.c #865A2E", | 165 | "[. c #865A2E", |
164 | "}.c #26568E", | 166 | "}. c #26568E", |
165 | "|.c #435F7D", | 167 | "|. c #435F7D", |
166 | "1.c #7AE246", | 168 | "1. c #7AE246", |
167 | "2.c #96EA6E", | 169 | "2. c #96EA6E", |
168 | "3.c #BEEAAE", | 170 | "3. c #BEEAAE", |
169 | "4.c #D0EADC", | 171 | "4. c #D0EADC", |
170 | "5.c #B6CEFE", | 172 | "5. c #B6CEFE", |
171 | "6.c #9ADE8A", | 173 | "6. c #9ADE8A", |
172 | "7.c #2A609A", | 174 | "7. c #2A609A", |
173 | "8.c #7E623E", | 175 | "8. c #7E623E", |
174 | "9.c #CA7A72", | 176 | "9. c #CA7A72", |
175 | "0.c #F26E6E", | 177 | "0. c #F26E6E", |
176 | "a.c #FE5252", | 178 | "a. c #FE5252", |
177 | "b.c #FA3638", | 179 | "b. c #FA3638", |
178 | "c.c #DA2E28", | 180 | "c. c #DA2E28", |
179 | "d.c #9E3E3A", | 181 | "d. c #9E3E3A", |
180 | "e.c #3E7656", | 182 | "e. c #3E7656", |
181 | "f.c #76CB3A", | 183 | "f. c #76CB3A", |
182 | "g.c #90DE44", | 184 | "g. c #90DE44", |
183 | "h.c #A2EE6A", | 185 | "h. c #A2EE6A", |
184 | "i.c #9EEA9A", | 186 | "i. c #9EEA9A", |
185 | "j.c #92BEDE", | 187 | "j. c #92BEDE", |
186 | "k.c #7ADA7E", | 188 | "k. c #7ADA7E", |
187 | "l.c #5ECE52", | 189 | "l. c #5ECE52", |
188 | "m.c #6A5E52", | 190 | "m. c #6A5E52", |
189 | "n.c #A83238", | 191 | "n. c #A83238", |
190 | "o.c #FA5656", | 192 | "o. c #FA5656", |
191 | "p.c #F29A92", | 193 | "p. c #F29A92", |
192 | "q.c #D29E92", | 194 | "q. c #D29E92", |
193 | "r.c #8A7A62", | 195 | "r. c #8A7A62", |
194 | "s.c #05336B", | 196 | "s. c #05336B", |
195 | "t.c #59C631", | 197 | "t. c #59C631", |
196 | "u.c #8AD23A", | 198 | "u. c #8AD23A", |
197 | "v.c #66E242", | 199 | "v. c #66E242", |
198 | "w.c #1D6FC1", | 200 | "w. c #1D6FC1", |
199 | "x.c #E61212", | 201 | "x. c #E61212", |
200 | "y.c #CA261E", | 202 | "y. c #CA261E", |
201 | "z.c #5A763E", | 203 | "z. c #5A763E", |
202 | "A.c #1E6E9A", | 204 | "A. c #1E6E9A", |
203 | "B.c #023272", | 205 | "B. c #023272", |
204 | "C.c #329696", | 206 | "C. c #329696", |
205 | "D.c #2074B6", | 207 | "D. c #2074B6", |
206 | "E.c #3E4E76", | 208 | "E. c #3E4E76", |
207 | "F.c #5A525E", | 209 | "F. c #5A525E", |
208 | "G.c #425868", | 210 | "G. c #425868", |
209 | "H.c #04448E", | 211 | "H. c #04448E", |
210 | "I.c #28828A", | 212 | "I. c #28828A", |
211 | "J.c #2D8593", | 213 | "J. c #2D8593", |
212 | "K.c #12427A", | 214 | "K. c #12427A", |
213 | "L.c #054696", | 215 | "L. c #054696", |
214 | "M.c #042B5E", | 216 | "M. c #042B5E", |
215 | "N.c #134F95", | 217 | "N. c #134F95", |
216 | "O.c #1E6ABB", | 218 | "O. c #1E6ABB", |
217 | "P.c #1A5E96", | 219 | "P. c #1A5E96", |
218 | "Q.c #022E67", | 220 | "Q. c #022E67", |
219 | "R.c #0C3E7C", | 221 | "R. c #0C3E7C", |
220 | "S.c #023E8A", | 222 | "S. c #023E8A", |
221 | "T.c #021A3E", | 223 | "T. c #021A3E", |
222 | " ", | 224 | " ", |
223 | " ", | 225 | " ", |
224 | " ", | 226 | " ", |
225 | " . + @ # + ", | 227 | " . + @ # + ", |
226 | " $ # % & * * = - # $ ", | 228 | " $ # % & * * = - # $ ", |
227 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | 229 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", |
228 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | 230 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", |
229 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", | 231 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", |
230 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", | 232 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", |
231 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", | 233 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", |
232 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", | 234 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", |
233 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", | 235 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", |
234 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", | 236 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", |
235 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", | 237 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", |
236 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", | 238 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", |
237 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", | 239 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", |
238 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", | 240 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", |
239 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", | 241 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", |
240 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", | 242 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", |
241 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", | 243 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", |
242 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", | 244 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", |
243 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", | 245 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", |
244 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", | 246 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", |
245 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", | 247 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", |
246 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", | 248 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", |
247 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", | 249 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", |
248 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", | 250 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", |
249 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", | 251 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", |
250 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", | 252 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", |
251 | " | > e L.d L.H.e M.. ; ] ] ", | 253 | " | > e L.d L.H.e M.. ; ] ] ", |
252 | " > 9 . S.Q.. ; ] ", | 254 | " > 9 . S.Q.. ; ] ", |
253 | " T.; ] "}; | 255 | " T.; ] "}; |
254 | 256 | ||
255 | static const char *SCAP_hostname = "www.handhelds.org"; | 257 | static const char *SCAP_hostname = "www.handhelds.org"; |
256 | static const int SCAP_port = 80; | 258 | static const int SCAP_port = 80; |
257 | 259 | ||
258 | 260 | ||
259 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 261 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
260 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 262 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
261 | { | 263 | { |
262 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 264 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
263 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 265 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
264 | QHBoxLayout *hbox; | 266 | QHBoxLayout *hbox; |
265 | 267 | ||
266 | hbox = new QHBoxLayout ( vbox ); | 268 | hbox = new QHBoxLayout ( vbox ); |
267 | 269 | ||
268 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 270 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
269 | hbox-> addWidget ( l ); | 271 | hbox-> addWidget ( l ); |
270 | 272 | ||
271 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 273 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
272 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 274 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
273 | delaySpin-> setSuffix ( tr( "sec" )); | 275 | delaySpin-> setSuffix ( tr( "sec" )); |
274 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 276 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
275 | delaySpin-> setValue ( 1 ); | 277 | delaySpin-> setValue ( 1 ); |
276 | hbox-> addWidget ( delaySpin ); | 278 | hbox-> addWidget ( delaySpin ); |
277 | 279 | ||
278 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 280 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
279 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 281 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
280 | vbox->addWidget( saveNamedCheck); | 282 | vbox->addWidget( saveNamedCheck); |
281 | 283 | ||
282 | vbox-> addSpacing ( 3 ); | 284 | vbox-> addSpacing ( 3 ); |
283 | 285 | ||
284 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 286 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
285 | vbox-> addWidget ( l, AlignCenter ); | 287 | vbox-> addWidget ( l, AlignCenter ); |
286 | 288 | ||
287 | hbox = new QHBoxLayout ( vbox ); | 289 | hbox = new QHBoxLayout ( vbox ); |
288 | 290 | ||
289 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 291 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
290 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 292 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
291 | hbox-> addWidget ( grabItButton ); | 293 | hbox-> addWidget ( grabItButton ); |
292 | 294 | ||
293 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 295 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
294 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 296 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
295 | hbox-> addWidget ( scapButton ); | 297 | hbox-> addWidget ( scapButton ); |
296 | 298 | ||
297 | setFixedSize ( sizeHint ( )); | 299 | setFixedSize ( sizeHint ( )); |
298 | setFocusPolicy ( QWidget::NoFocus ); | 300 | setFocusPolicy ( QWidget::NoFocus ); |
299 | 301 | ||
300 | 302 | ||
301 | grabTimer = new QTimer ( this, "grab timer"); | 303 | grabTimer = new QTimer ( this, "grab timer"); |
302 | 304 | ||
303 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); | 305 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
304 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); | 306 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
305 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); | 307 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
306 | } | 308 | } |
307 | 309 | ||
308 | void ScreenshotControl::slotGrab() | 310 | void ScreenshotControl::slotGrab() |
309 | { | 311 | { |
310 | buttonPushed = 1; | 312 | buttonPushed = 1; |
311 | hide(); | 313 | hide(); |
312 | 314 | ||
313 | setFileName = FALSE; | 315 | setFileName = FALSE; |
314 | if ( saveNamedCheck->isChecked()) { | 316 | if ( saveNamedCheck->isChecked()) { |
315 | setFileName = TRUE; | 317 | setFileName = TRUE; |
316 | InputDialog *fileDlg; | 318 | InputDialog *fileDlg; |
317 | 319 | ||
318 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 320 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
319 | fileDlg->exec(); | 321 | fileDlg->exec(); |
320 | fileDlg->raise(); | 322 | fileDlg->raise(); |
321 | QString fileName, list; | 323 | QString fileName, list; |
322 | if ( fileDlg->result() == 1 ) { | 324 | if ( fileDlg->result() == 1 ) { |
323 | fileName = fileDlg->LineEdit1->text(); | 325 | fileName = fileDlg->LineEdit1->text(); |
324 | 326 | ||
325 | if (fileName.find("/", 0, TRUE) == -1) | 327 | if (fileName.find("/", 0, TRUE) == -1) |
326 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 328 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
327 | else | 329 | else |
328 | FileNamePath = fileName; | 330 | FileNamePath = fileName; |
329 | 331 | ||
330 | } | 332 | } |
331 | delete fileDlg; | 333 | delete fileDlg; |
332 | } | 334 | } |
333 | 335 | ||
334 | if ( delaySpin->value() ) | 336 | if ( delaySpin->value() ) |
335 | grabTimer->start( delaySpin->value() * 1000, true ); | 337 | grabTimer->start( delaySpin->value() * 1000, true ); |
336 | else | 338 | else |
337 | show(); | 339 | show(); |
338 | } | 340 | } |
339 | 341 | ||
340 | void ScreenshotControl::slotScap() | 342 | void ScreenshotControl::slotScap() |
341 | { | 343 | { |
342 | buttonPushed = 2; | 344 | buttonPushed = 2; |
343 | hide(); | 345 | hide(); |
344 | 346 | ||
345 | if ( delaySpin->value() ) | 347 | if ( delaySpin->value() ) |
346 | grabTimer->start( delaySpin->value() * 1000, true ); | 348 | grabTimer->start( delaySpin->value() * 1000, true ); |
347 | else | 349 | else |
348 | show(); | 350 | show(); |
349 | } | 351 | } |
350 | 352 | ||
351 | 353 | ||
352 | void ScreenshotControl::savePixmap() | 354 | void ScreenshotControl::savePixmap() |
353 | { | 355 | { |
354 | DocLnk lnk; | 356 | DocLnk lnk; |
355 | QString fileName; | 357 | QString fileName; |
356 | 358 | ||
357 | if ( setFileName) { | 359 | if ( setFileName) { |
358 | fileName = FileNamePath; | 360 | fileName = FileNamePath; |
359 | //not sure why this is needed here, but it forgets fileName | 361 | //not sure why this is needed here, but it forgets fileName |
360 | // if this is below the braces | 362 | // if this is below the braces |
361 | 363 | ||
362 | if (fileName.right(3) != "png") | 364 | if (fileName.right(3) != "png") |
363 | fileName = fileName + ".png"; | 365 | fileName = fileName + ".png"; |
364 | lnk.setFile(fileName); //sets File property | 366 | lnk.setFile(fileName); //sets File property |
365 | qDebug("saving file " + fileName); | 367 | odebug << "saving file " + fileName << oendl; |
366 | snapshot.save( fileName, "PNG"); | 368 | snapshot.save( fileName, "PNG"); |
367 | QFileInfo fi( fileName); | 369 | QFileInfo fi( fileName); |
368 | lnk.setName( fi.fileName()); //sets file name | 370 | lnk.setName( fi.fileName()); //sets file name |
369 | 371 | ||
370 | if (!lnk.writeLink()) | 372 | if (!lnk.writeLink()) |
371 | qDebug("Writing doclink did not work"); | 373 | odebug << "Writing doclink did not work" << oendl; |
372 | } | 374 | } |
373 | else { | 375 | else { |
374 | 376 | ||
375 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 377 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
376 | fileName.replace(QRegExp("'"), ""); | 378 | fileName.replace(QRegExp("'"), ""); |
377 | fileName.replace(QRegExp(" "), "_"); | 379 | fileName.replace(QRegExp(" "), "_"); |
378 | fileName.replace(QRegExp(":"), "."); | 380 | fileName.replace(QRegExp(":"), "."); |
379 | fileName.replace(QRegExp(","), ""); | 381 | fileName.replace(QRegExp(","), ""); |
380 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 382 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
381 | 383 | ||
382 | if ( !QDir( dirName).exists() ) { | 384 | if ( !QDir( dirName).exists() ) { |
383 | qDebug("making dir " + dirName); | 385 | odebug << "making dir " + dirName << oendl; |
384 | QString msg = "mkdir -p " + dirName; | 386 | QString msg = "mkdir -p " + dirName; |
385 | system(msg.latin1()); | 387 | system(msg.latin1()); |
386 | } | 388 | } |
387 | fileName = dirName + fileName; | 389 | fileName = dirName + fileName; |
388 | if (fileName.right(3) != "png") | 390 | if (fileName.right(3) != "png") |
389 | fileName = fileName + ".png"; | 391 | fileName = fileName + ".png"; |
390 | lnk.setFile(fileName); //sets File property | 392 | lnk.setFile(fileName); //sets File property |
391 | qDebug("saving file " + fileName); | 393 | odebug << "saving file " + fileName << oendl; |
392 | snapshot.save( fileName, "PNG"); | 394 | snapshot.save( fileName, "PNG"); |
393 | QFileInfo fi( fileName); | 395 | QFileInfo fi( fileName); |
394 | lnk.setName( fi.fileName()); //sets file name | 396 | lnk.setName( fi.fileName()); //sets file name |
395 | 397 | ||
396 | if (!lnk.writeLink()) | 398 | if (!lnk.writeLink()) |
397 | qDebug("Writing doclink did not work"); | 399 | odebug << "Writing doclink did not work" << oendl; |
398 | 400 | ||
399 | } | 401 | } |
400 | 402 | ||
401 | QPEApplication::beep(); | 403 | QPEApplication::beep(); |
402 | } | 404 | } |
403 | 405 | ||
404 | void ScreenshotControl::performGrab() | 406 | void ScreenshotControl::performGrab() |
405 | { | 407 | { |
406 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 408 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
407 | 409 | ||
408 | if (buttonPushed == 1) { | 410 | if (buttonPushed == 1) { |
409 | qDebug("grabbing screen"); | 411 | odebug << "grabbing screen" << oendl; |
410 | grabTimer->stop(); | 412 | grabTimer->stop(); |
411 | show(); | 413 | show(); |
412 | qApp->processEvents(); | 414 | qApp->processEvents(); |
413 | savePixmap(); | 415 | savePixmap(); |
414 | } else { | 416 | } else { |
415 | grabTimer->stop(); | 417 | grabTimer->stop(); |
416 | 418 | ||
417 | struct sockaddr_in raddr; | 419 | struct sockaddr_in raddr; |
418 | struct hostent *rhost_info; | 420 | struct hostent *rhost_info; |
419 | int sock = -1; | 421 | int sock = -1; |
420 | bool ok = false; | 422 | bool ok = false; |
421 | 423 | ||
422 | QString displayEnv = getenv("QWS_DISPLAY"); | 424 | QString displayEnv = getenv("QWS_DISPLAY"); |
423 | qDebug(displayEnv); | 425 | odebug << displayEnv << oendl; |
424 | 426 | ||
425 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 427 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
426 | 428 | ||
427 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 429 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
428 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 430 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
429 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 431 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
430 | raddr. sin_family = rhost_info-> h_addrtype; | 432 | raddr. sin_family = rhost_info-> h_addrtype; |
431 | raddr. sin_port = htons ( SCAP_port ); | 433 | raddr. sin_port = htons ( SCAP_port ); |
432 | 434 | ||
433 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 435 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
434 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 436 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
435 | 437 | ||
436 | QString header; | 438 | QString header; |
437 | 439 | ||
438 | QPixmap pix; | 440 | QPixmap pix; |
439 | 441 | ||
440 | QString SCAP_model=""; | 442 | QString SCAP_model=""; |
441 | #warning FIXME: model string should be filled with actual device model | 443 | #warning FIXME: model string should be filled with actual device model |
442 | if( snapshot.width() > 320) | 444 | if( snapshot.width() > 320) |
443 | SCAP_model ="Corgi"; | 445 | SCAP_model ="Corgi"; |
444 | 446 | ||
445 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 447 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
446 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 448 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
447 | } else | 449 | } else |
448 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 450 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
449 | 451 | ||
450 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 452 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
451 | 453 | ||
452 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 454 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
453 | "Content-length: %3\n" // 3: content length | 455 | "Content-length: %3\n" // 3: content length |
454 | "Content-Type: image/png\n" | 456 | "Content-Type: image/png\n" |
455 | "Host: %4\n" // 4: scap host | 457 | "Host: %4\n" // 4: scap host |
456 | "\n"; | 458 | "\n"; |
457 | 459 | ||
458 | 460 | ||
459 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 461 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
460 | qDebug(header); | 462 | odebug << header << oendl; |
461 | 463 | ||
462 | if ( !pix.isNull() ) { | 464 | if ( !pix.isNull() ) { |
463 | const char *ascii = header.latin1( ); | 465 | const char *ascii = header.latin1( ); |
464 | uint ascii_len = ::strlen( ascii ); | 466 | uint ascii_len = ::strlen( ascii ); |
465 | ::write ( sock, ascii, ascii_len ); | 467 | ::write ( sock, ascii, ascii_len ); |
466 | ::write ( sock, img.bits(), img.numBytes() ); | 468 | ::write ( sock, img.bits(), img.numBytes() ); |
467 | 469 | ||
468 | ok = true; | 470 | ok = true; |
469 | } | 471 | } |
470 | } | 472 | } |
471 | ::close ( sock ); | 473 | ::close ( sock ); |
472 | } | 474 | } |
473 | } | 475 | } |
474 | if ( ok ) { | 476 | if ( ok ) { |
475 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 477 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
476 | } else { | 478 | } else { |
477 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 479 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
478 | } | 480 | } |
479 | } else { | 481 | } else { |
480 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 482 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
481 | } | 483 | } |
482 | } | 484 | } |
483 | 485 | ||
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | 489 | ||
488 | //=========================================================================== | 490 | //=========================================================================== |
489 | 491 | ||
490 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 492 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
491 | : QWidget( parent, name ) | 493 | : QWidget( parent, name ) |
492 | { | 494 | { |
493 | setFixedWidth( AppLnk::smallIconSize()); | 495 | setFixedWidth( AppLnk::smallIconSize()); |
494 | 496 | ||
495 | QImage img = (const char **)snapshot_xpm; | 497 | QImage img = (const char **)snapshot_xpm; |
496 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 498 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
497 | m_icon.convertFromImage(img); | 499 | m_icon.convertFromImage(img); |
498 | } | 500 | } |
499 | 501 | ||
500 | ScreenshotApplet::~ScreenshotApplet() | 502 | ScreenshotApplet::~ScreenshotApplet() |
501 | { | 503 | { |
502 | } | 504 | } |
503 | 505 | ||
504 | int ScreenshotApplet::position() | 506 | int ScreenshotApplet::position() |
505 | { | 507 | { |
506 | return 6; | 508 | return 6; |
507 | } | 509 | } |
508 | 510 | ||
509 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 511 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
510 | { | 512 | { |
511 | ScreenshotControl *sc = new ScreenshotControl ( ); | 513 | ScreenshotControl *sc = new ScreenshotControl ( ); |
512 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); | 514 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); |
513 | 515 | ||
514 | // windowPosX is the windows position centered above the applets icon. | 516 | // windowPosX is the windows position centered above the applets icon. |
515 | // If the icon is near the edge of the screen, the window would leave the visible area | 517 | // If the icon is near the edge of the screen, the window would leave the visible area |
516 | // so we check the position against the screen width and correct the difference if needed | 518 | // so we check the position against the screen width and correct the difference if needed |
517 | 519 | ||
518 | int screenWidth = qApp->desktop()->width(); | 520 | int screenWidth = qApp->desktop()->width(); |
519 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | 521 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; |
520 | int ZwindowPosX, XwindowPosX; | 522 | int ZwindowPosX, XwindowPosX; |
521 | 523 | ||
522 | // the window would be placed beyond the screen wich doesn't look tooo good | 524 | // the window would be placed beyond the screen wich doesn't look tooo good |
523 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | 525 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { |
524 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | 526 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; |
525 | ZwindowPosX = windowPosX - XwindowPosX - 1; | 527 | ZwindowPosX = windowPosX - XwindowPosX - 1; |
526 | } else { | 528 | } else { |
527 | ZwindowPosX = windowPosX; | 529 | ZwindowPosX = windowPosX; |
528 | } | 530 | } |
529 | 531 | ||
530 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | 532 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); |
531 | sc-> show ( ); | 533 | sc-> show ( ); |
532 | } | 534 | } |
533 | 535 | ||
534 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 536 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
535 | { | 537 | { |
536 | QPainter p ( this ); | 538 | QPainter p ( this ); |
537 | p.drawPixmap( 0,0, m_icon ); | 539 | p.drawPixmap( 0,0, m_icon ); |
538 | } | 540 | } |
539 | 541 | ||
540 | 542 | ||
541 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) | 543 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) |
542 | 544 | ||
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 7dd5b4b..622b1df 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -1,644 +1,648 @@ | |||
1 | /************************************************************************************ | 1 | /************************************************************************************ |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | ************************************************************************************/ | 11 | ************************************************************************************/ |
12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> | 12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> |
13 | // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> | 13 | // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> |
14 | 14 | ||
15 | /* OPIE */ | ||
16 | #include <opie2/odebug.h> | ||
17 | using namespace Opie::Core; | ||
18 | |||
15 | extern "C" { | 19 | extern "C" { |
16 | #include "adpcm.h" | 20 | #include "adpcm.h" |
17 | } | 21 | } |
18 | 22 | ||
19 | #include <unistd.h> | 23 | #include <unistd.h> |
20 | #include <stdio.h> | 24 | #include <stdio.h> |
21 | #include <fcntl.h> | 25 | #include <fcntl.h> |
22 | #include <sys/ioctl.h> | 26 | #include <sys/ioctl.h> |
23 | #include <linux/soundcard.h> | 27 | #include <linux/soundcard.h> |
24 | 28 | ||
25 | #include <errno.h> | 29 | #include <errno.h> |
26 | 30 | ||
27 | typedef struct _waveheader { | 31 | typedef struct _waveheader { |
28 | u_long main_chunk; /* 'RIFF' */ | 32 | u_long main_chunk; /* 'RIFF' */ |
29 | u_long length; /* filelen */ | 33 | u_long length; /* filelen */ |
30 | u_long chunk_type; /* 'WAVE' */ | 34 | u_long chunk_type; /* 'WAVE' */ |
31 | u_long sub_chunk; /* 'fmt ' */ | 35 | u_long sub_chunk; /* 'fmt ' */ |
32 | u_long sc_len; /* length of sub_chunk, =16 | 36 | u_long sc_len; /* length of sub_chunk, =16 |
33 | (chunckSize) format len */ | 37 | (chunckSize) format len */ |
34 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 38 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
35 | 39 | ||
36 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
37 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
38 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
39 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
40 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
41 | 45 | ||
42 | u_long data_chunk; /* 'data' */ | 46 | u_long data_chunk; /* 'data' */ |
43 | 47 | ||
44 | u_long data_length;/* samplecount */ | 48 | u_long data_length;/* samplecount */ |
45 | } WaveHeader; | 49 | } WaveHeader; |
46 | 50 | ||
47 | #define RIFF 0x46464952 | 51 | #define RIFF 0x46464952 |
48 | #define WAVE 0x45564157 | 52 | #define WAVE 0x45564157 |
49 | #define FMT 0x20746D66 | 53 | #define FMT 0x20746D66 |
50 | #define DATA 0x61746164 | 54 | #define DATA 0x61746164 |
51 | #define PCM_CODE 1 | 55 | #define PCM_CODE 1 |
52 | #define WAVE_MONO 1 | 56 | #define WAVE_MONO 1 |
53 | #define WAVE_STEREO 2 | 57 | #define WAVE_STEREO 2 |
54 | 58 | ||
55 | struct adpcm_state encoder_state; | 59 | struct adpcm_state encoder_state; |
56 | //struct adpcm_state decoder_state; | 60 | //struct adpcm_state decoder_state; |
57 | 61 | ||
58 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | 62 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) |
59 | #define WAVE_FORMAT_PCM (0x0001) | 63 | #define WAVE_FORMAT_PCM (0x0001) |
60 | 64 | ||
61 | 65 | ||
62 | #include "vmemo.h" | 66 | #include "vmemo.h" |
63 | 67 | ||
64 | #include <opie2/otaskbarapplet.h> | 68 | #include <opie2/otaskbarapplet.h> |
65 | #include <qpe/qpeapplication.h> | 69 | #include <qpe/qpeapplication.h> |
66 | #include <qpe/config.h> | 70 | #include <qpe/config.h> |
67 | 71 | ||
68 | #include <qpainter.h> | 72 | #include <qpainter.h> |
69 | #include <qmessagebox.h> | 73 | #include <qmessagebox.h> |
70 | 74 | ||
71 | int seq = 0; | 75 | int seq = 0; |
72 | 76 | ||
73 | /* XPM */ | 77 | /* XPM */ |
74 | static char * vmemo_xpm[] = { | 78 | static char * vmemo_xpm[] = { |
75 | "16 16 102 2", | 79 | "16 16 102 2", |
76 | " c None", | 80 | " c None", |
77 | ". c #60636A", | 81 | ". c #60636A", |
78 | "+ c #6E6E72", | 82 | "+ c #6E6E72", |
79 | "@ c #68696E", | 83 | "@ c #68696E", |
80 | "# c #4D525C", | 84 | "# c #4D525C", |
81 | "$ c #6B6C70", | 85 | "$ c #6B6C70", |
82 | "% c #E3E3E8", | 86 | "% c #E3E3E8", |
83 | "& c #EEEEF2", | 87 | "& c #EEEEF2", |
84 | "* c #EAEAEF", | 88 | "* c #EAEAEF", |
85 | "= c #CACAD0", | 89 | "= c #CACAD0", |
86 | "- c #474A51", | 90 | "- c #474A51", |
87 | "; c #171819", | 91 | "; c #171819", |
88 | "> c #9B9B9F", | 92 | "> c #9B9B9F", |
89 | ", c #EBEBF0", | 93 | ", c #EBEBF0", |
90 | "' c #F4F4F7", | 94 | "' c #F4F4F7", |
91 | ") c #F1F1F5", | 95 | ") c #F1F1F5", |
92 | "! c #DEDEE4", | 96 | "! c #DEDEE4", |
93 | "~ c #57575C", | 97 | "~ c #57575C", |
94 | "{ c #010101", | 98 | "{ c #010101", |
95 | "] c #A2A2A6", | 99 | "] c #A2A2A6", |
96 | "^ c #747477", | 100 | "^ c #747477", |
97 | "/ c #B5B5B8", | 101 | "/ c #B5B5B8", |
98 | "( c #AEAEB2", | 102 | "( c #AEAEB2", |
99 | "_ c #69696D", | 103 | "_ c #69696D", |
100 | ": c #525256", | 104 | ": c #525256", |
101 | "< c #181C24", | 105 | "< c #181C24", |
102 | "[ c #97979B", | 106 | "[ c #97979B", |
103 | "} c #A7A7AC", | 107 | "} c #A7A7AC", |
104 | "| c #B0B0B4", | 108 | "| c #B0B0B4", |
105 | "1 c #C8C8D1", | 109 | "1 c #C8C8D1", |
106 | "2 c #75757B", | 110 | "2 c #75757B", |
107 | "3 c #46464A", | 111 | "3 c #46464A", |
108 | "4 c #494A4F", | 112 | "4 c #494A4F", |
109 | "5 c #323234", | 113 | "5 c #323234", |
110 | "6 c #909095", | 114 | "6 c #909095", |
111 | "7 c #39393B", | 115 | "7 c #39393B", |
112 | "8 c #757578", | 116 | "8 c #757578", |
113 | "9 c #87878E", | 117 | "9 c #87878E", |
114 | "0 c #222224", | 118 | "0 c #222224", |
115 | "a c #414144", | 119 | "a c #414144", |
116 | "b c #6A6A6E", | 120 | "b c #6A6A6E", |
117 | "c c #020C16", | 121 | "c c #020C16", |
118 | "d c #6B6B6F", | 122 | "d c #6B6B6F", |
119 | "e c #68686D", | 123 | "e c #68686D", |
120 | "f c #5B5B60", | 124 | "f c #5B5B60", |
121 | "g c #8A8A8F", | 125 | "g c #8A8A8F", |
122 | "h c #6B6B6E", | 126 | "h c #6B6B6E", |
123 | "i c #ADADB2", | 127 | "i c #ADADB2", |
124 | "j c #828289", | 128 | "j c #828289", |
125 | "k c #3E3E41", | 129 | "k c #3E3E41", |
126 | "l c #CFCFD7", | 130 | "l c #CFCFD7", |
127 | "m c #4C4C50", | 131 | "m c #4C4C50", |
128 | "n c #000000", | 132 | "n c #000000", |
129 | "o c #66666A", | 133 | "o c #66666A", |
130 | "p c #505054", | 134 | "p c #505054", |
131 | "q c #838388", | 135 | "q c #838388", |
132 | "r c #A1A1A7", | 136 | "r c #A1A1A7", |
133 | "s c #A9A9AE", | 137 | "s c #A9A9AE", |
134 | "t c #A8A8B0", | 138 | "t c #A8A8B0", |
135 | "u c #5E5E63", | 139 | "u c #5E5E63", |
136 | "v c #3A3A3E", | 140 | "v c #3A3A3E", |
137 | "w c #BDBDC6", | 141 | "w c #BDBDC6", |
138 | "x c #59595E", | 142 | "x c #59595E", |
139 | "y c #76767C", | 143 | "y c #76767C", |
140 | "z c #373738", | 144 | "z c #373738", |
141 | "A c #717174", | 145 | "A c #717174", |
142 | "B c #727278", | 146 | "B c #727278", |
143 | "C c #1C1C1E", | 147 | "C c #1C1C1E", |
144 | "D c #3C3C3F", | 148 | "D c #3C3C3F", |
145 | "E c #ADADB6", | 149 | "E c #ADADB6", |
146 | "F c #54555A", | 150 | "F c #54555A", |
147 | "G c #8B8C94", | 151 | "G c #8B8C94", |
148 | "H c #5A5A5F", | 152 | "H c #5A5A5F", |
149 | "I c #BBBBC3", | 153 | "I c #BBBBC3", |
150 | "J c #C4C4CB", | 154 | "J c #C4C4CB", |
151 | "K c #909098", | 155 | "K c #909098", |
152 | "L c #737379", | 156 | "L c #737379", |
153 | "M c #343437", | 157 | "M c #343437", |
154 | "N c #8F8F98", | 158 | "N c #8F8F98", |
155 | "O c #000407", | 159 | "O c #000407", |
156 | "P c #2D3137", | 160 | "P c #2D3137", |
157 | "Q c #B0B1BC", | 161 | "Q c #B0B1BC", |
158 | "R c #3B3C40", | 162 | "R c #3B3C40", |
159 | "S c #6E6E74", | 163 | "S c #6E6E74", |
160 | "T c #95959C", | 164 | "T c #95959C", |
161 | "U c #74747A", | 165 | "U c #74747A", |
162 | "V c #1D1D1E", | 166 | "V c #1D1D1E", |
163 | "W c #91929A", | 167 | "W c #91929A", |
164 | "X c #42444A", | 168 | "X c #42444A", |
165 | "Y c #22282E", | 169 | "Y c #22282E", |
166 | "Z c #B0B2BC", | 170 | "Z c #B0B2BC", |
167 | "` c #898A90", | 171 | "` c #898A90", |
168 | " . c #65656A", | 172 | " . c #65656A", |
169 | ".. c #999AA2", | 173 | ".. c #999AA2", |
170 | "+. c #52535A", | 174 | "+. c #52535A", |
171 | "@. c #151B21", | 175 | "@. c #151B21", |
172 | "#. c #515257", | 176 | "#. c #515257", |
173 | "$. c #B5B5BE", | 177 | "$. c #B5B5BE", |
174 | "%. c #616167", | 178 | "%. c #616167", |
175 | "&. c #1A1D22", | 179 | "&. c #1A1D22", |
176 | "*. c #000713", | 180 | "*. c #000713", |
177 | "=. c #1F1F21", | 181 | "=. c #1F1F21", |
178 | " ", | 182 | " ", |
179 | " . + @ # ", | 183 | " . + @ # ", |
180 | " $ % & * = - ", | 184 | " $ % & * = - ", |
181 | " ; > , ' ) ! ~ ", | 185 | " ; > , ' ) ! ~ ", |
182 | " { ] ^ / ( _ : ", | 186 | " { ] ^ / ( _ : ", |
183 | " < [ } | 1 2 3 ", | 187 | " < [ } | 1 2 3 ", |
184 | " 4 5 6 7 8 9 0 a b c ", | 188 | " 4 5 6 7 8 9 0 a b c ", |
185 | " d e f g h i j 3 k l m n ", | 189 | " d e f g h i j 3 k l m n ", |
186 | " o p q r s t u v w n ", | 190 | " o p q r s t u v w n ", |
187 | " o x y z A B C D E n ", | 191 | " o x y z A B C D E n ", |
188 | " F G H I J K L M N O ", | 192 | " F G H I J K L M N O ", |
189 | " P Q R S T U V W X ", | 193 | " P Q R S T U V W X ", |
190 | " Y Z ` b ...+. ", | 194 | " Y Z ` b ...+. ", |
191 | " @.#.$.%.&. ", | 195 | " @.#.$.%.&. ", |
192 | " *.B =. ", | 196 | " *.B =. ", |
193 | " n n n n n n n n n "}; | 197 | " n n n n n n n n n "}; |
194 | 198 | ||
195 | 199 | ||
196 | using namespace Opie::Ui; | 200 | using namespace Opie::Ui; |
197 | VMemo::VMemo( QWidget *parent, const char *_name ) | 201 | VMemo::VMemo( QWidget *parent, const char *_name ) |
198 | : QWidget( parent, _name ) { | 202 | : QWidget( parent, _name ) { |
199 | setFixedHeight( 18 ); | 203 | setFixedHeight( 18 ); |
200 | setFixedWidth( 14 ); | 204 | setFixedWidth( 14 ); |
201 | 205 | ||
202 | t_timer = new QTimer( this ); | 206 | t_timer = new QTimer( this ); |
203 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
204 | 208 | ||
205 | Config vmCfg("Vmemo"); | 209 | Config vmCfg("Vmemo"); |
206 | vmCfg.setGroup("Defaults"); | 210 | vmCfg.setGroup("Defaults"); |
207 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
208 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
209 | 213 | ||
210 | qDebug("toggleKey %d", toggleKey); | 214 | odebug << "toggleKey " << toggleKey << "" << oendl; |
211 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 215 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
212 | systemZaurus=TRUE; | 216 | systemZaurus=TRUE; |
213 | else | 217 | else |
214 | systemZaurus=FALSE; | 218 | systemZaurus=FALSE; |
215 | 219 | ||
216 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 220 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
217 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 221 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
218 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 222 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
219 | 223 | ||
220 | if( toggleKey != -1 ) { | 224 | if( toggleKey != -1 ) { |
221 | // keyRegister(key, channel, message) | 225 | // keyRegister(key, channel, message) |
222 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 226 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
223 | // e << 4096; // Key_Escape | 227 | // e << 4096; // Key_Escape |
224 | // e << Key_F5; //4148 | 228 | // e << Key_F5; //4148 |
225 | e << toggleKey; | 229 | e << toggleKey; |
226 | e << QString("QPE/VMemo"); | 230 | e << QString("QPE/VMemo"); |
227 | e << QString("toggleRecord()"); | 231 | e << QString("toggleRecord()"); |
228 | } | 232 | } |
229 | if(toggleKey == 1) | 233 | if(toggleKey == 1) |
230 | usingIcon=TRUE; | 234 | usingIcon=TRUE; |
231 | else | 235 | else |
232 | usingIcon=FALSE; | 236 | usingIcon=FALSE; |
233 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 237 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
234 | hide(); | 238 | hide(); |
235 | recording = FALSE; | 239 | recording = FALSE; |
236 | // } | 240 | // } |
237 | } | 241 | } |
238 | 242 | ||
239 | VMemo::~VMemo() { | 243 | VMemo::~VMemo() { |
240 | } | 244 | } |
241 | 245 | ||
242 | int VMemo::position() | 246 | int VMemo::position() |
243 | { | 247 | { |
244 | return 6; | 248 | return 6; |
245 | } | 249 | } |
246 | 250 | ||
247 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 251 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
248 | qDebug("receive"); | 252 | odebug << "receive" << oendl; |
249 | QDataStream stream( data, IO_ReadOnly ); | 253 | QDataStream stream( data, IO_ReadOnly ); |
250 | 254 | ||
251 | if (msg == "toggleRecord()") { | 255 | if (msg == "toggleRecord()") { |
252 | if (recording) { | 256 | if (recording) { |
253 | fromToggle = TRUE; | 257 | fromToggle = TRUE; |
254 | stopRecording(); | 258 | stopRecording(); |
255 | } else { | 259 | } else { |
256 | fromToggle = TRUE; | 260 | fromToggle = TRUE; |
257 | startRecording(); | 261 | startRecording(); |
258 | } | 262 | } |
259 | } | 263 | } |
260 | } | 264 | } |
261 | 265 | ||
262 | void VMemo::paintEvent( QPaintEvent* ) { | 266 | void VMemo::paintEvent( QPaintEvent* ) { |
263 | QPainter p(this); | 267 | QPainter p(this); |
264 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 268 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
265 | } | 269 | } |
266 | 270 | ||
267 | void VMemo::mousePressEvent( QMouseEvent * me) { | 271 | void VMemo::mousePressEvent( QMouseEvent * me) { |
268 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 272 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
269 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 273 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
270 | 274 | ||
271 | // if (!systemZaurus && me != NULL) | 275 | // if (!systemZaurus && me != NULL) |
272 | // return; | 276 | // return; |
273 | // } | 277 | // } |
274 | 278 | ||
275 | if(!recording) | 279 | if(!recording) |
276 | startRecording(); | 280 | startRecording(); |
277 | else | 281 | else |
278 | stopRecording(); | 282 | stopRecording(); |
279 | } | 283 | } |
280 | 284 | ||
281 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 285 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
282 | } | 286 | } |
283 | 287 | ||
284 | bool VMemo::startRecording() { | 288 | bool VMemo::startRecording() { |
285 | Config config( "Vmemo" ); | 289 | Config config( "Vmemo" ); |
286 | config.setGroup( "System" ); | 290 | config.setGroup( "System" ); |
287 | 291 | ||
288 | useAlerts = config.readBoolEntry("Alert",1); | 292 | useAlerts = config.readBoolEntry("Alert",1); |
289 | if(useAlerts) { | 293 | if(useAlerts) { |
290 | 294 | ||
291 | msgLabel = new QLabel( 0, "alertLabel" ); | 295 | msgLabel = new QLabel( 0, "alertLabel" ); |
292 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 296 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
293 | msgLabel->show(); | 297 | msgLabel->show(); |
294 | } | 298 | } |
295 | 299 | ||
296 | qDebug("Start recording engines"); | 300 | odebug << "Start recording engines" << oendl; |
297 | recording = TRUE; | 301 | recording = TRUE; |
298 | 302 | ||
299 | if (openDSP() == -1) { | 303 | if (openDSP() == -1) { |
300 | recording = FALSE; | 304 | recording = FALSE; |
301 | return FALSE; | 305 | return FALSE; |
302 | } | 306 | } |
303 | 307 | ||
304 | config.setGroup("Defaults"); | 308 | config.setGroup("Defaults"); |
305 | 309 | ||
306 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 310 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
307 | date.replace(QRegExp("'"),""); | 311 | date.replace(QRegExp("'"),""); |
308 | date.replace(QRegExp(" "),"_"); | 312 | date.replace(QRegExp(" "),"_"); |
309 | date.replace(QRegExp(":"),"."); | 313 | date.replace(QRegExp(":"),"."); |
310 | date.replace(QRegExp(","),""); | 314 | date.replace(QRegExp(","),""); |
311 | 315 | ||
312 | QString fName; | 316 | QString fName; |
313 | config.setGroup( "System" ); | 317 | config.setGroup( "System" ); |
314 | fName = QPEApplication::documentDir() ; | 318 | fName = QPEApplication::documentDir() ; |
315 | fileName = config.readEntry("RecLocation", fName); | 319 | fileName = config.readEntry("RecLocation", fName); |
316 | 320 | ||
317 | int s; | 321 | int s; |
318 | s=fileName.find(':'); | 322 | s=fileName.find(':'); |
319 | if(s) | 323 | if(s) |
320 | fileName=fileName.right(fileName.length()-s-2); | 324 | fileName=fileName.right(fileName.length()-s-2); |
321 | qDebug("pathname will be "+fileName); | 325 | odebug << "pathname will be "+fileName << oendl; |
322 | 326 | ||
323 | if( fileName.left(1).find('/') == -1) | 327 | if( fileName.left(1).find('/') == -1) |
324 | fileName="/"+fileName; | 328 | fileName="/"+fileName; |
325 | if( fileName.right(1).find('/') == -1) | 329 | if( fileName.right(1).find('/') == -1) |
326 | fileName+="/"; | 330 | fileName+="/"; |
327 | fName = "vm_"+ date+ ".wav"; | 331 | fName = "vm_"+ date+ ".wav"; |
328 | 332 | ||
329 | fileName+=fName; | 333 | fileName+=fName; |
330 | qDebug("filename is "+fileName); | 334 | odebug << "filename is "+fileName << oendl; |
331 | // open tmp file here | 335 | // open tmp file here |
332 | char *pointer; | 336 | char *pointer; |
333 | pointer=tmpnam(NULL); | 337 | pointer=tmpnam(NULL); |
334 | qDebug("Opening tmp file %s",pointer); | 338 | odebug << "Opening tmp file " << pointer << "" << oendl; |
335 | 339 | ||
336 | if(openWAV(pointer ) == -1) { | 340 | if(openWAV(pointer ) == -1) { |
337 | 341 | ||
338 | QString err("Could not open the temp file\n"); | 342 | QString err("Could not open the temp file\n"); |
339 | err += fileName; | 343 | err += fileName; |
340 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 344 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
341 | ::close(dsp); | 345 | ::close(dsp); |
342 | return FALSE; | 346 | return FALSE; |
343 | } | 347 | } |
344 | if( record() ) { | 348 | if( record() ) { |
345 | 349 | ||
346 | QString cmd; | 350 | QString cmd; |
347 | if( fileName.find(".wav",0,TRUE) == -1) | 351 | if( fileName.find(".wav",0,TRUE) == -1) |
348 | fileName += ".wav"; | 352 | fileName += ".wav"; |
349 | 353 | ||
350 | cmd.sprintf("mv %s "+fileName, pointer); | 354 | cmd.sprintf("mv %s "+fileName, pointer); |
351 | // move tmp file to regular file here | 355 | // move tmp file to regular file here |
352 | 356 | ||
353 | system(cmd.latin1()); | 357 | system(cmd.latin1()); |
354 | 358 | ||
355 | QArray<int> cats(1); | 359 | QArray<int> cats(1); |
356 | cats[0] = config.readNumEntry("Category", 0); | 360 | cats[0] = config.readNumEntry("Category", 0); |
357 | 361 | ||
358 | QString dlName("vm_"); | 362 | QString dlName("vm_"); |
359 | dlName += date; | 363 | dlName += date; |
360 | DocLnk l; | 364 | DocLnk l; |
361 | l.setFile(fileName); | 365 | l.setFile(fileName); |
362 | l.setName(dlName); | 366 | l.setName(dlName); |
363 | l.setType("audio/x-wav"); | 367 | l.setType("audio/x-wav"); |
364 | l.setCategories(cats); | 368 | l.setCategories(cats); |
365 | l.writeLink(); | 369 | l.writeLink(); |
366 | return TRUE; | 370 | return TRUE; |
367 | } else | 371 | } else |
368 | return FALSE; | 372 | return FALSE; |
369 | 373 | ||
370 | } | 374 | } |
371 | 375 | ||
372 | void VMemo::stopRecording() { | 376 | void VMemo::stopRecording() { |
373 | show(); | 377 | show(); |
374 | qDebug("Stopped recording"); | 378 | odebug << "Stopped recording" << oendl; |
375 | recording = FALSE; | 379 | recording = FALSE; |
376 | if(useAlerts) { | 380 | if(useAlerts) { |
377 | msgLabel->close(); | 381 | msgLabel->close(); |
378 | msgLabel=0; | 382 | msgLabel=0; |
379 | delete msgLabel; | 383 | delete msgLabel; |
380 | } | 384 | } |
381 | t_timer->stop(); | 385 | t_timer->stop(); |
382 | Config cfg("Vmemo"); | 386 | Config cfg("Vmemo"); |
383 | cfg.setGroup("Defaults"); | 387 | cfg.setGroup("Defaults"); |
384 | if( cfg.readNumEntry("hideIcon",0) == 1 ) | 388 | if( cfg.readNumEntry("hideIcon",0) == 1 ) |
385 | hide(); | 389 | hide(); |
386 | } | 390 | } |
387 | 391 | ||
388 | int VMemo::openDSP() { | 392 | int VMemo::openDSP() { |
389 | Config cfg("Vmemo"); | 393 | Config cfg("Vmemo"); |
390 | cfg.setGroup("Record"); | 394 | cfg.setGroup("Record"); |
391 | 395 | ||
392 | speed = cfg.readNumEntry("SampleRate", 22050); | 396 | speed = cfg.readNumEntry("SampleRate", 22050); |
393 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 397 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
394 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 398 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
395 | format = AFMT_S16_LE; | 399 | format = AFMT_S16_LE; |
396 | resolution = 16; | 400 | resolution = 16; |
397 | } else { | 401 | } else { |
398 | format = AFMT_U8; | 402 | format = AFMT_U8; |
399 | resolution = 8; | 403 | resolution = 8; |
400 | } | 404 | } |
401 | 405 | ||
402 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 406 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
403 | 407 | ||
404 | if(systemZaurus) { | 408 | if(systemZaurus) { |
405 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 409 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
406 | channels=1; //zaurus has one input channel | 410 | channels=1; //zaurus has one input channel |
407 | } else { | 411 | } else { |
408 | dsp = open("/dev/dsp", O_RDONLY); | 412 | dsp = open("/dev/dsp", O_RDONLY); |
409 | } | 413 | } |
410 | 414 | ||
411 | if(dsp == -1) { | 415 | if(dsp == -1) { |
412 | msgLabel->close(); | 416 | msgLabel->close(); |
413 | msgLabel=0; | 417 | msgLabel=0; |
414 | delete msgLabel; | 418 | delete msgLabel; |
415 | 419 | ||
416 | perror("open(\"/dev/dsp\")"); | 420 | perror("open(\"/dev/dsp\")"); |
417 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 421 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
418 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 422 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
419 | return -1; | 423 | return -1; |
420 | } | 424 | } |
421 | 425 | ||
422 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 426 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
423 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 427 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
424 | return -1; | 428 | return -1; |
425 | } | 429 | } |
426 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 430 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
427 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 431 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
428 | return -1; | 432 | return -1; |
429 | } | 433 | } |
430 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 434 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
431 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 435 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
432 | return -1; | 436 | return -1; |
433 | } | 437 | } |
434 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 438 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
435 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 439 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
436 | return -1; | 440 | return -1; |
437 | } | 441 | } |
438 | 442 | ||
439 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 443 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
440 | 444 | ||
441 | return 1; | 445 | return 1; |
442 | } | 446 | } |
443 | 447 | ||
444 | int VMemo::openWAV(const char *filename) { | 448 | int VMemo::openWAV(const char *filename) { |
445 | track.setName(filename); | 449 | track.setName(filename); |
446 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 450 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
447 | errorMsg=filename; | 451 | errorMsg=filename; |
448 | return -1; | 452 | return -1; |
449 | } | 453 | } |
450 | 454 | ||
451 | wav=track.handle(); | 455 | wav=track.handle(); |
452 | Config vmCfg("Vmemo"); | 456 | Config vmCfg("Vmemo"); |
453 | vmCfg.setGroup("Defaults"); | 457 | vmCfg.setGroup("Defaults"); |
454 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 458 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
455 | 459 | ||
456 | WaveHeader wh; | 460 | WaveHeader wh; |
457 | 461 | ||
458 | wh.main_chunk = RIFF; | 462 | wh.main_chunk = RIFF; |
459 | wh.length=0; | 463 | wh.length=0; |
460 | wh.chunk_type = WAVE; | 464 | wh.chunk_type = WAVE; |
461 | wh.sub_chunk = FMT; | 465 | wh.sub_chunk = FMT; |
462 | wh.sc_len = 16; | 466 | wh.sc_len = 16; |
463 | if(useADPCM) | 467 | if(useADPCM) |
464 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | 468 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; |
465 | else | 469 | else |
466 | wh.format = PCM_CODE; | 470 | wh.format = PCM_CODE; |
467 | wh.modus = channels; | 471 | wh.modus = channels; |
468 | wh.sample_fq = speed; | 472 | wh.sample_fq = speed; |
469 | wh.byte_p_sec = speed * channels * resolution/8; | 473 | wh.byte_p_sec = speed * channels * resolution/8; |
470 | wh.byte_p_spl = channels * (resolution / 8); | 474 | wh.byte_p_spl = channels * (resolution / 8); |
471 | wh.bit_p_spl = resolution; | 475 | wh.bit_p_spl = resolution; |
472 | wh.data_chunk = DATA; | 476 | wh.data_chunk = DATA; |
473 | wh.data_length= 0; | 477 | wh.data_length= 0; |
474 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | 478 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" |
475 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | 479 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); |
476 | write (wav, &wh, sizeof(WaveHeader)); | 480 | write (wav, &wh, sizeof(WaveHeader)); |
477 | 481 | ||
478 | return 1; | 482 | return 1; |
479 | } | 483 | } |
480 | 484 | ||
481 | bool VMemo::record() { | 485 | bool VMemo::record() { |
482 | length=0; | 486 | length=0; |
483 | int result, value; | 487 | int result, value; |
484 | QString msg; | 488 | QString msg; |
485 | msg.sprintf("Recording format %d", format); | 489 | msg.sprintf("Recording format %d", format); |
486 | qDebug(msg); | 490 | odebug << msg << oendl; |
487 | Config config("Vmemo"); | 491 | Config config("Vmemo"); |
488 | config.setGroup("Record"); | 492 | config.setGroup("Record"); |
489 | int sRate=config.readNumEntry("SizeLimit", 30); | 493 | int sRate=config.readNumEntry("SizeLimit", 30); |
490 | if(sRate > 0) | 494 | if(sRate > 0) |
491 | t_timer->start( sRate * 1000+1000, TRUE); | 495 | t_timer->start( sRate * 1000+1000, TRUE); |
492 | 496 | ||
493 | // if(systemZaurus) { | 497 | // if(systemZaurus) { |
494 | // } else { // 16 bit only capabilities | 498 | // } else { // 16 bit only capabilities |
495 | 499 | ||
496 | msg.sprintf("Recording format other"); | 500 | msg.sprintf("Recording format other"); |
497 | qDebug(msg); | 501 | odebug << msg << oendl; |
498 | 502 | ||
499 | int bufsize=1024; | 503 | int bufsize=1024; |
500 | int bytesWritten=0; | 504 | int bytesWritten=0; |
501 | signed short sound[1024], monoBuffer[1024]; | 505 | signed short sound[1024], monoBuffer[1024]; |
502 | char abuf[bufsize/2]; | 506 | char abuf[bufsize/2]; |
503 | short sbuf[bufsize]; | 507 | short sbuf[bufsize]; |
504 | Config vmCfg("Vmemo"); | 508 | Config vmCfg("Vmemo"); |
505 | vmCfg.setGroup("Defaults"); | 509 | vmCfg.setGroup("Defaults"); |
506 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 510 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
507 | 511 | ||
508 | while(recording) { | 512 | while(recording) { |
509 | 513 | ||
510 | if(useADPCM) | 514 | if(useADPCM) |
511 | result = read( dsp, sbuf, bufsize); // 8192 | 515 | result = read( dsp, sbuf, bufsize); // 8192 |
512 | else | 516 | else |
513 | result = read(dsp, sound, 1024); // 8192 | 517 | result = read(dsp, sound, 1024); // 8192 |
514 | if( result <= 0) { | 518 | if( result <= 0) { |
515 | perror("recording error "); | 519 | perror("recording error "); |
516 | // qDebug(currentFileName); | 520 | // odebug << currentFileName << oendl; |
517 | QMessageBox::message(tr("Note"),tr("error recording")); | 521 | QMessageBox::message(tr("Note"),tr("error recording")); |
518 | recording=FALSE; | 522 | recording=FALSE; |
519 | break; | 523 | break; |
520 | return FALSE; | 524 | return FALSE; |
521 | } | 525 | } |
522 | 526 | ||
523 | if(useADPCM) { | 527 | if(useADPCM) { |
524 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); | 528 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
525 | bytesWritten = ::write(wav, abuf, result/4); | 529 | bytesWritten = ::write(wav, abuf, result/4); |
526 | 530 | ||
527 | } else { | 531 | } else { |
528 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 532 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
529 | monoBuffer[i] = sound[i]; | 533 | monoBuffer[i] = sound[i]; |
530 | } | 534 | } |
531 | 535 | ||
532 | length+=write(wav, monoBuffer, result); | 536 | length+=write(wav, monoBuffer, result); |
533 | } | 537 | } |
534 | length +=bytesWritten; | 538 | length +=bytesWritten; |
535 | 539 | ||
536 | if(length<0) { | 540 | if(length<0) { |
537 | recording=false; | 541 | recording=false; |
538 | perror("dev/dsp's is a lookin' messy"); | 542 | perror("dev/dsp's is a lookin' messy"); |
539 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 543 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
540 | break; | 544 | break; |
541 | return FALSE; | 545 | return FALSE; |
542 | } | 546 | } |
543 | // printf("%d\r",length); | 547 | // odebug << "" << length << "\r" << oendl; |
544 | // fflush(stdout); | 548 | // fflush(stdout); |
545 | qApp->processEvents(); | 549 | qApp->processEvents(); |
546 | } | 550 | } |
547 | // qDebug("file has length of %d lasting %d seconds", | 551 | // qDebug("file has length of %d lasting %d seconds", |
548 | // length, (( length / speed) / channels) / 2 ); | 552 | // length, (( length / speed) / channels) / 2 ); |
549 | // } | 553 | // } |
550 | 554 | ||
551 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// | 555 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// |
552 | 556 | ||
553 | value = length+36; | 557 | value = length+36; |
554 | 558 | ||
555 | lseek(wav, 4, SEEK_SET); | 559 | lseek(wav, 4, SEEK_SET); |
556 | write(wav, &value, 4); | 560 | write(wav, &value, 4); |
557 | lseek(wav, 40, SEEK_SET); | 561 | lseek(wav, 40, SEEK_SET); |
558 | 562 | ||
559 | write(wav, &length, 4); | 563 | write(wav, &length, 4); |
560 | 564 | ||
561 | track.close(); | 565 | track.close(); |
562 | qDebug("Track closed"); | 566 | odebug << "Track closed" << oendl; |
563 | 567 | ||
564 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 568 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
565 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 569 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
566 | 570 | ||
567 | ::close(dsp); | 571 | ::close(dsp); |
568 | 572 | ||
569 | Config cfgO("OpieRec"); | 573 | Config cfgO("OpieRec"); |
570 | cfgO.setGroup("Sounds"); | 574 | cfgO.setGroup("Sounds"); |
571 | 575 | ||
572 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); | 576 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); |
573 | 577 | ||
574 | QString currentFileName = fileName; | 578 | QString currentFileName = fileName; |
575 | QString currentFile = "vm_"+ date; | 579 | QString currentFile = "vm_"+ date; |
576 | 580 | ||
577 | float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; | 581 | float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; |
578 | 582 | ||
579 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); | 583 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); |
580 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); | 584 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); |
581 | cfgO.writeEntry( currentFile, currentFileName); | 585 | cfgO.writeEntry( currentFile, currentFileName); |
582 | 586 | ||
583 | QString time; | 587 | QString time; |
584 | time.sprintf("%.2f", numberOfRecordedSeconds); | 588 | time.sprintf("%.2f", numberOfRecordedSeconds); |
585 | cfgO.writeEntry( currentFileName, time ); | 589 | cfgO.writeEntry( currentFileName, time ); |
586 | // qDebug("writing config numberOfRecordedSeconds "+time); | 590 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
587 | 591 | ||
588 | cfgO.write(); | 592 | cfgO.write(); |
589 | 593 | ||
590 | qDebug("done recording "+fileName); | 594 | odebug << "done recording "+fileName << oendl; |
591 | 595 | ||
592 | Config cfg("qpe"); | 596 | Config cfg("qpe"); |
593 | cfg.setGroup("Volume"); | 597 | cfg.setGroup("Volume"); |
594 | QString foo = cfg.readEntry("Mute","TRUE"); | 598 | QString foo = cfg.readEntry("Mute","TRUE"); |
595 | if(foo.find("TRUE",0,TRUE) != -1) | 599 | if(foo.find("TRUE",0,TRUE) != -1) |
596 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 600 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
597 | return TRUE; | 601 | return TRUE; |
598 | } | 602 | } |
599 | 603 | ||
600 | int VMemo::setToggleButton(int tog) { | 604 | int VMemo::setToggleButton(int tog) { |
601 | 605 | ||
602 | for( int i=0; i < 10;i++) { | 606 | for( int i=0; i < 10;i++) { |
603 | switch (tog) { | 607 | switch (tog) { |
604 | case 0: | 608 | case 0: |
605 | return -1; | 609 | return -1; |
606 | break; | 610 | break; |
607 | case 1: | 611 | case 1: |
608 | return 0; | 612 | return 0; |
609 | break; | 613 | break; |
610 | case 2: | 614 | case 2: |
611 | return Key_F24; //was Escape | 615 | return Key_F24; //was Escape |
612 | break; | 616 | break; |
613 | case 3: | 617 | case 3: |
614 | return Key_Space; | 618 | return Key_Space; |
615 | break; | 619 | break; |
616 | case 4: | 620 | case 4: |
617 | return Key_F12; | 621 | return Key_F12; |
618 | break; | 622 | break; |
619 | case 5: | 623 | case 5: |
620 | return Key_F9; | 624 | return Key_F9; |
621 | break; | 625 | break; |
622 | case 6: | 626 | case 6: |
623 | return Key_F10; | 627 | return Key_F10; |
624 | break; | 628 | break; |
625 | case 7: | 629 | case 7: |
626 | return Key_F11; | 630 | return Key_F11; |
627 | break; | 631 | break; |
628 | case 8: | 632 | case 8: |
629 | return Key_F13; | 633 | return Key_F13; |
630 | break; | 634 | break; |
631 | }; | 635 | }; |
632 | } | 636 | } |
633 | return -1; | 637 | return -1; |
634 | } | 638 | } |
635 | 639 | ||
636 | void VMemo::timerBreak() { | 640 | void VMemo::timerBreak() { |
637 | //stop | 641 | //stop |
638 | stopRecording(); | 642 | stopRecording(); |
639 | QMessageBox::message("Vmemo","Vmemo recording has ended"); | 643 | QMessageBox::message("Vmemo","Vmemo recording has ended"); |
640 | } | 644 | } |
641 | 645 | ||
642 | 646 | ||
643 | EXPORT_OPIE_APPLET_v1( VMemo ) | 647 | EXPORT_OPIE_APPLET_v1( VMemo ) |
644 | 648 | ||
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp index bd39093..aec63c3 100644 --- a/core/applets/vtapplet/vt.cpp +++ b/core/applets/vtapplet/vt.cpp | |||
@@ -1,161 +1,164 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
3 | ** | ||
4 | ** Contact me @ mickeyl@handhelds.org | ||
5 | ** | 3 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 7 | ** packaging of this file. |
10 | ** | 8 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 11 | ** |
14 | **********************************************************************/ | 12 | **********************************************************************/ |
15 | 13 | ||
14 | #include "vt.h" | ||
15 | |||
16 | /* OPIE */ | ||
17 | #include <opie2/odebug.h> | ||
16 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | using namespace Opie::Core; | ||
17 | 20 | ||
21 | /* QT */ | ||
18 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
19 | 23 | ||
24 | /* STD */ | ||
20 | #include <fcntl.h> | 25 | #include <fcntl.h> |
21 | #include <unistd.h> | 26 | #include <unistd.h> |
22 | #include <sys/types.h> | 27 | #include <sys/types.h> |
23 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
24 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
25 | #include <linux/vt.h> | 30 | #include <linux/vt.h> |
26 | 31 | ||
27 | #include "vt.h" | ||
28 | |||
29 | VTApplet::VTApplet ( ) | 32 | VTApplet::VTApplet ( ) |
30 | : QObject ( 0, "VTApplet" ) | 33 | : QObject ( 0, "VTApplet" ) |
31 | { | 34 | { |
32 | } | 35 | } |
33 | 36 | ||
34 | VTApplet::~VTApplet ( ) | 37 | VTApplet::~VTApplet ( ) |
35 | { | 38 | { |
36 | } | 39 | } |
37 | 40 | ||
38 | int VTApplet::position ( ) const | 41 | int VTApplet::position ( ) const |
39 | { | 42 | { |
40 | return 2; | 43 | return 2; |
41 | } | 44 | } |
42 | 45 | ||
43 | QString VTApplet::name ( ) const | 46 | QString VTApplet::name ( ) const |
44 | { | 47 | { |
45 | return tr( "VT shortcut" ); | 48 | return tr( "VT shortcut" ); |
46 | } | 49 | } |
47 | 50 | ||
48 | QString VTApplet::text ( ) const | 51 | QString VTApplet::text ( ) const |
49 | { | 52 | { |
50 | return tr( "Terminal" ); | 53 | return tr( "Terminal" ); |
51 | } | 54 | } |
52 | 55 | ||
53 | /* | 56 | /* |
54 | QString VTApplet::tr( const char* s ) const | 57 | QString VTApplet::tr( const char* s ) const |
55 | { | 58 | { |
56 | return qApp->translate( "VTApplet", s, 0 ); | 59 | return qApp->translate( "VTApplet", s, 0 ); |
57 | } | 60 | } |
58 | 61 | ||
59 | QString VTApplet::tr( const char* s, const char* p ) const | 62 | QString VTApplet::tr( const char* s, const char* p ) const |
60 | { | 63 | { |
61 | return qApp->translate( "VTApplet", s, p ); | 64 | return qApp->translate( "VTApplet", s, p ); |
62 | } | 65 | } |
63 | */ | 66 | */ |
64 | 67 | ||
65 | QIconSet VTApplet::icon ( ) const | 68 | QIconSet VTApplet::icon ( ) const |
66 | { | 69 | { |
67 | QPixmap pix; | 70 | QPixmap pix; |
68 | QImage img = Resource::loadImage ( "terminal" ); | 71 | QImage img = Resource::loadImage ( "terminal" ); |
69 | 72 | ||
70 | if ( !img. isNull ( )) | 73 | if ( !img. isNull ( )) |
71 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); | 74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); |
72 | return pix; | 75 | return pix; |
73 | } | 76 | } |
74 | 77 | ||
75 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const | 78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const |
76 | { | 79 | { |
77 | qDebug( "VTApplet::popup" ); | 80 | odebug << "VTApplet::popup" << oendl; |
78 | 81 | ||
79 | struct vt_stat vtstat; | 82 | struct vt_stat vtstat; |
80 | int fd = ::open( "/dev/tty0", O_RDWR ); | 83 | int fd = ::open( "/dev/tty0", O_RDWR ); |
81 | if ( fd == -1 ) return 0; | 84 | if ( fd == -1 ) return 0; |
82 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; | 85 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; |
83 | 86 | ||
84 | m_subMenu = new QPopupMenu( parent ); | 87 | m_subMenu = new QPopupMenu( parent ); |
85 | m_subMenu->setCheckable( true ); | 88 | m_subMenu->setCheckable( true ); |
86 | for ( int i = 1; i < 10; ++i ) | 89 | for ( int i = 1; i < 10; ++i ) |
87 | { | 90 | { |
88 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); | 91 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); |
89 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); | 92 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); |
90 | } | 93 | } |
91 | ::close( fd ); | 94 | ::close( fd ); |
92 | 95 | ||
93 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); | 96 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); |
94 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); | 97 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); |
95 | 98 | ||
96 | return m_subMenu; | 99 | return m_subMenu; |
97 | } | 100 | } |
98 | 101 | ||
99 | 102 | ||
100 | void VTApplet::changeVT( int index ) | 103 | void VTApplet::changeVT( int index ) |
101 | { | 104 | { |
102 | //qDebug( "VTApplet::changeVT( %d )", index-500 ); | 105 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; |
103 | 106 | ||
104 | int fd = ::open("/dev/tty0", O_RDWR); | 107 | int fd = ::open("/dev/tty0", O_RDWR); |
105 | if ( fd == -1 ) return; | 108 | if ( fd == -1 ) return; |
106 | ioctl( fd, VT_ACTIVATE, index-500 ); | 109 | ioctl( fd, VT_ACTIVATE, index-500 ); |
107 | } | 110 | } |
108 | 111 | ||
109 | 112 | ||
110 | void VTApplet::updateMenu() | 113 | void VTApplet::updateMenu() |
111 | { | 114 | { |
112 | //qDebug( "VTApplet::updateMenu()" ); | 115 | //odebug << "VTApplet::updateMenu()" << oendl; |
113 | 116 | ||
114 | int fd = ::open( "/dev/console", O_RDONLY ); | 117 | int fd = ::open( "/dev/console", O_RDONLY ); |
115 | if ( fd == -1 ) return; | 118 | if ( fd == -1 ) return; |
116 | 119 | ||
117 | for ( int i = 1; i < 10; ++i ) | 120 | for ( int i = 1; i < 10; ++i ) |
118 | { | 121 | { |
119 | int result = ioctl( fd, VT_DISALLOCATE, i ); | 122 | int result = ioctl( fd, VT_DISALLOCATE, i ); |
120 | 123 | ||
121 | /* | 124 | /* |
122 | if ( result == -1 ) | 125 | if ( result == -1 ) |
123 | qDebug( "VT %d disallocated == free", i ); | 126 | odebug << "VT " << i << " disallocated == free" << oendl; |
124 | else | 127 | else |
125 | qDebug( "VT %d _not_ disallocated == busy", i ); | 128 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; |
126 | */ | 129 | */ |
127 | 130 | ||
128 | m_subMenu->setItemEnabled( 500+i, result == -1 ); | 131 | m_subMenu->setItemEnabled( 500+i, result == -1 ); |
129 | } | 132 | } |
130 | 133 | ||
131 | ::close( fd ); | 134 | ::close( fd ); |
132 | } | 135 | } |
133 | 136 | ||
134 | 137 | ||
135 | void VTApplet::activated() | 138 | void VTApplet::activated() |
136 | { | 139 | { |
137 | qDebug( "VTApplet::activated()" ); | 140 | odebug << "VTApplet::activated()" << oendl; |
138 | } | 141 | } |
139 | 142 | ||
140 | 143 | ||
141 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 144 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
142 | { | 145 | { |
143 | *iface = 0; | 146 | *iface = 0; |
144 | if ( uuid == IID_QUnknown ) | 147 | if ( uuid == IID_QUnknown ) |
145 | *iface = this; | 148 | *iface = this; |
146 | else if ( uuid == IID_MenuApplet ) | 149 | else if ( uuid == IID_MenuApplet ) |
147 | *iface = this; | 150 | *iface = this; |
148 | else | 151 | else |
149 | return QS_FALSE; | 152 | return QS_FALSE; |
150 | 153 | ||
151 | if ( *iface ) | 154 | if ( *iface ) |
152 | (*iface)-> addRef ( ); | 155 | (*iface)-> addRef ( ); |
153 | return QS_OK; | 156 | return QS_OK; |
154 | } | 157 | } |
155 | 158 | ||
156 | Q_EXPORT_INTERFACE( ) | 159 | Q_EXPORT_INTERFACE( ) |
157 | { | 160 | { |
158 | Q_CREATE_INSTANCE( VTApplet ) | 161 | Q_CREATE_INSTANCE( VTApplet ) |
159 | } | 162 | } |
160 | 163 | ||
161 | 164 | ||
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index cd8d58e..f3dd11c 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -1,293 +1,294 @@ | |||
1 | #include "obex.h" | ||
2 | #include "obexsend.h" | ||
3 | using namespace OpieObex; | ||
4 | |||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | #include <qpe/qcopenvelope_qws.h> | ||
8 | using namespace Opie::Core; | ||
9 | |||
10 | /* QT */ | ||
1 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
2 | #include <qlabel.h> | 12 | #include <qlabel.h> |
3 | #include <qlayout.h> | 13 | #include <qlayout.h> |
4 | #include <qtimer.h> | 14 | #include <qtimer.h> |
5 | 15 | ||
6 | |||
7 | #include <qpe/qcopenvelope_qws.h> | ||
8 | |||
9 | #include "obex.h" | ||
10 | #include "obexsend.h" | ||
11 | |||
12 | using namespace OpieObex; | ||
13 | |||
14 | /* TRANSLATOR OpieObex::SendWidget */ | 16 | /* TRANSLATOR OpieObex::SendWidget */ |
15 | 17 | ||
16 | |||
17 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 18 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
18 | : QWidget( parent, name ) { | 19 | : QWidget( parent, name ) { |
19 | initUI(); | 20 | initUI(); |
20 | } | 21 | } |
21 | SendWidget::~SendWidget() { | 22 | SendWidget::~SendWidget() { |
22 | } | 23 | } |
23 | void SendWidget::initUI() { | 24 | void SendWidget::initUI() { |
24 | m_obex = new Obex(this, "obex"); | 25 | m_obex = new Obex(this, "obex"); |
25 | connect(m_obex, SIGNAL(error(int) ), | 26 | connect(m_obex, SIGNAL(error(int) ), |
26 | this, SLOT(slotIrError(int) ) ); | 27 | this, SLOT(slotIrError(int) ) ); |
27 | connect(m_obex, SIGNAL(sent(bool) ), | 28 | connect(m_obex, SIGNAL(sent(bool) ), |
28 | this, SLOT(slotIrSent(bool) ) ); | 29 | this, SLOT(slotIrSent(bool) ) ); |
29 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), | 30 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), |
30 | this, SLOT(slotIrTry(unsigned int) ) ); | 31 | this, SLOT(slotIrTry(unsigned int) ) ); |
31 | 32 | ||
32 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); | 33 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); |
33 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 34 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
34 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); | 35 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); |
35 | 36 | ||
36 | chan = new QCopChannel("QPE/BluetoothBack", this ); | 37 | chan = new QCopChannel("QPE/BluetoothBack", this ); |
37 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 38 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
38 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); | 39 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); |
39 | 40 | ||
40 | QVBoxLayout* lay = new QVBoxLayout(this); | 41 | QVBoxLayout* lay = new QVBoxLayout(this); |
41 | 42 | ||
42 | QHBox* nameBox = new QHBox(this); | 43 | QHBox* nameBox = new QHBox(this); |
43 | QLabel* name = new QLabel(nameBox); | 44 | QLabel* name = new QLabel(nameBox); |
44 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); | 45 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); |
45 | name->setAlignment( AlignLeft | AlignTop ); | 46 | name->setAlignment( AlignLeft | AlignTop ); |
46 | m_lblFile = new QLabel(nameBox); | 47 | m_lblFile = new QLabel(nameBox); |
47 | lay->addWidget(nameBox, 0); | 48 | lay->addWidget(nameBox, 0); |
48 | 49 | ||
49 | QFrame* frame = new QFrame(this); | 50 | QFrame* frame = new QFrame(this); |
50 | frame->setFrameShape( QFrame::HLine ); | 51 | frame->setFrameShape( QFrame::HLine ); |
51 | frame->setFrameShadow( QFrame::Sunken ); | 52 | frame->setFrameShadow( QFrame::Sunken ); |
52 | lay->addWidget(frame, 10); | 53 | lay->addWidget(frame, 10); |
53 | 54 | ||
54 | QLabel* devices = new QLabel(this); | 55 | QLabel* devices = new QLabel(this); |
55 | devices->setText("<qt><b>Devices:</b></qt>"); | 56 | devices->setText("<qt><b>Devices:</b></qt>"); |
56 | devices->setAlignment( AlignLeft | AlignTop ); | 57 | devices->setAlignment( AlignLeft | AlignTop ); |
57 | lay->addWidget( devices,10 ); | 58 | lay->addWidget( devices,10 ); |
58 | 59 | ||
59 | m_devBox = new DeviceBox(this); | 60 | m_devBox = new DeviceBox(this); |
60 | lay->addWidget( m_devBox, 50 ); | 61 | lay->addWidget( m_devBox, 50 ); |
61 | connect(m_devBox, SIGNAL(selectedDevice(int,int) ), | 62 | connect(m_devBox, SIGNAL(selectedDevice(int,int) ), |
62 | this, SLOT(slotSelectedDevice(int,int) ) ); | 63 | this, SLOT(slotSelectedDevice(int,int) ) ); |
63 | 64 | ||
64 | QPushButton *but = new QPushButton(this); | 65 | QPushButton *but = new QPushButton(this); |
65 | but->setText(tr("Done") ); | 66 | but->setText(tr("Done") ); |
66 | connect(but, SIGNAL(clicked() ), | 67 | connect(but, SIGNAL(clicked() ), |
67 | this, SLOT(slotDone() ) ); | 68 | this, SLOT(slotDone() ) ); |
68 | 69 | ||
69 | lay->addWidget( but ); | 70 | lay->addWidget( but ); |
70 | m_lay = lay; | 71 | m_lay = lay; |
71 | 72 | ||
72 | // QT does not like if you add items to an layout which already exits.... | 73 | // QT does not like if you add items to an layout which already exits.... |
73 | // and was layouted invalidate() does not help too | 74 | // and was layouted invalidate() does not help too |
74 | // so we use RichText.... | 75 | // so we use RichText.... |
75 | } | 76 | } |
76 | 77 | ||
77 | /* | 78 | /* |
78 | * in send we'll first set everything up | 79 | * in send we'll first set everything up |
79 | * and then wait for a list of devices. | 80 | * and then wait for a list of devices. |
80 | */ | 81 | */ |
81 | void SendWidget::send( const QString& file, const QString& desc ) { | 82 | void SendWidget::send( const QString& file, const QString& desc ) { |
82 | m_file = file; | 83 | m_file = file; |
83 | m_irDa.clear(); | 84 | m_irDa.clear(); |
84 | m_start = 0; | 85 | m_start = 0; |
85 | m_lblFile->setText(desc.isEmpty() ? file : desc ); | 86 | m_lblFile->setText(desc.isEmpty() ? file : desc ); |
86 | 87 | ||
87 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { | 88 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { |
88 | m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); | 89 | m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); |
89 | m_start++; | 90 | m_start++; |
90 | }else | 91 | }else |
91 | m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); | 92 | m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); |
92 | 93 | ||
93 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { | 94 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { |
94 | m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); | 95 | m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); |
95 | m_start++; | 96 | m_start++; |
96 | }else | 97 | }else |
97 | m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); | 98 | m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); |
98 | 99 | ||
99 | if (m_start != 2 ) { | 100 | if (m_start != 2 ) { |
100 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); | 101 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); |
101 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 102 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
102 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 103 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
103 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 104 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
104 | } | 105 | } |
105 | } | 106 | } |
106 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 107 | void SendWidget::slotIrDaDevices( const QStringList& list) { |
107 | qWarning("slot it irda devices "); | 108 | owarn << "slot it irda devices " << oendl; |
108 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 109 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
109 | int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); | 110 | int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); |
110 | m_irDa.insert( id, (*it) ); | 111 | m_irDa.insert( id, (*it) ); |
111 | } | 112 | } |
112 | m_devBox->removeDevice( m_irDeSearch ); | 113 | m_devBox->removeDevice( m_irDeSearch ); |
113 | m_irDaIt = m_irDa.begin(); | 114 | m_irDaIt = m_irDa.begin(); |
114 | 115 | ||
115 | slotStartIrda(); | 116 | slotStartIrda(); |
116 | } | 117 | } |
117 | 118 | ||
118 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 119 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
119 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { | 120 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { |
120 | int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); | 121 | int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); |
121 | m_bt.insert( id, Pair( it.key(), it.data() ) ); | 122 | m_bt.insert( id, Pair( it.key(), it.data() ) ); |
122 | } | 123 | } |
123 | m_devBox->removeDevice( m_btDeSearch ); | 124 | m_devBox->removeDevice( m_btDeSearch ); |
124 | } | 125 | } |
125 | void SendWidget::slotSelectedDevice( int name, int dev ) { | 126 | void SendWidget::slotSelectedDevice( int name, int dev ) { |
126 | qWarning("Start beam? %d %d", name, dev ); | 127 | owarn << "Start beam? " << name << " " << dev << "" << oendl; |
127 | if ( name == m_irDeSearch ) { | 128 | if ( name == m_irDeSearch ) { |
128 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | 129 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) |
129 | m_devBox->removeDevice( it.key() ); | 130 | m_devBox->removeDevice( it.key() ); |
130 | 131 | ||
131 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 132 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | 135 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { |
135 | qWarning("dispatch irda %s", str.data() ); | 136 | owarn << "dispatch irda " << str.data() << "" << oendl; |
136 | if ( str == "devices(QStringList)" ) { | 137 | if ( str == "devices(QStringList)" ) { |
137 | QDataStream stream( ar, IO_ReadOnly ); | 138 | QDataStream stream( ar, IO_ReadOnly ); |
138 | QStringList list; | 139 | QStringList list; |
139 | stream >> list; | 140 | stream >> list; |
140 | slotIrDaDevices( list ); | 141 | slotIrDaDevices( list ); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { | 144 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { |
144 | 145 | ||
145 | } | 146 | } |
146 | void SendWidget::slotIrError( int ) { | 147 | void SendWidget::slotIrError( int ) { |
147 | 148 | ||
148 | } | 149 | } |
149 | void SendWidget::slotIrSent( bool b) { | 150 | void SendWidget::slotIrSent( bool b) { |
150 | qWarning("irda sent!!"); | 151 | owarn << "irda sent!!" << oendl; |
151 | QString text = b ? tr("Sent") : tr("Failure"); | 152 | QString text = b ? tr("Sent") : tr("Failure"); |
152 | m_devBox->setStatus( m_irDaIt.key(), text ); | 153 | m_devBox->setStatus( m_irDaIt.key(), text ); |
153 | ++m_irDaIt; | 154 | ++m_irDaIt; |
154 | slotStartIrda(); | 155 | slotStartIrda(); |
155 | } | 156 | } |
156 | void SendWidget::slotIrTry(unsigned int trI) { | 157 | void SendWidget::slotIrTry(unsigned int trI) { |
157 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 158 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
158 | } | 159 | } |
159 | void SendWidget::slotStartIrda() { | 160 | void SendWidget::slotStartIrda() { |
160 | if (m_irDaIt == m_irDa.end() ) { | 161 | if (m_irDaIt == m_irDa.end() ) { |
161 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); | 162 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); |
162 | return; | 163 | return; |
163 | } | 164 | } |
164 | m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); | 165 | m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); |
165 | m_obex->send( m_file ); | 166 | m_obex->send( m_file ); |
166 | } | 167 | } |
167 | void SendWidget::closeEvent( QCloseEvent* e) { | 168 | void SendWidget::closeEvent( QCloseEvent* e) { |
168 | e->accept(); // make sure | 169 | e->accept(); // make sure |
169 | QTimer::singleShot(0, this, SLOT(slotDone() ) ); | 170 | QTimer::singleShot(0, this, SLOT(slotDone() ) ); |
170 | } | 171 | } |
171 | void SendWidget::slotDone() { | 172 | void SendWidget::slotDone() { |
172 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); | 173 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); |
173 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); | 174 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); |
174 | emit done(); | 175 | emit done(); |
175 | } | 176 | } |
176 | QString SendWidget::file()const { | 177 | QString SendWidget::file()const { |
177 | return m_file; | 178 | return m_file; |
178 | } | 179 | } |
179 | DeviceBox::DeviceBox( QWidget* parent ) | 180 | DeviceBox::DeviceBox( QWidget* parent ) |
180 | : QTextBrowser( parent ) { | 181 | : QTextBrowser( parent ) { |
181 | 182 | ||
182 | } | 183 | } |
183 | DeviceBox::~DeviceBox() { | 184 | DeviceBox::~DeviceBox() { |
184 | 185 | ||
185 | } | 186 | } |
186 | int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { | 187 | int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { |
187 | /* return a id for a range of devices */ | 188 | /* return a id for a range of devices */ |
188 | int id = idFor ( dev ); | 189 | int id = idFor ( dev ); |
189 | DeviceItem item( name, status, dev,id ); | 190 | DeviceItem item( name, status, dev,id ); |
190 | m_dev.insert( id, item ); | 191 | m_dev.insert( id, item ); |
191 | setText( allText() ); | 192 | setText( allText() ); |
192 | 193 | ||
193 | return id; | 194 | return id; |
194 | } | 195 | } |
195 | void DeviceBox::removeDevice( int id ) { | 196 | void DeviceBox::removeDevice( int id ) { |
196 | if (!m_dev.contains(id) ) return; | 197 | if (!m_dev.contains(id) ) return; |
197 | 198 | ||
198 | m_dev.remove( id ); | 199 | m_dev.remove( id ); |
199 | setText( allText() ); | 200 | setText( allText() ); |
200 | } | 201 | } |
201 | void DeviceBox::setStatus( int id, const QString& status ) { | 202 | void DeviceBox::setStatus( int id, const QString& status ) { |
202 | if ( !m_dev.contains(id) ) return; | 203 | if ( !m_dev.contains(id) ) return; |
203 | m_dev[id].setStatus(status ); | 204 | m_dev[id].setStatus(status ); |
204 | setText( allText() ); | 205 | setText( allText() ); |
205 | } | 206 | } |
206 | void DeviceBox::setSource( const QString& str ) { | 207 | void DeviceBox::setSource( const QString& str ) { |
207 | qWarning("SetSource:%d", str.toInt() ); | 208 | owarn << "SetSource:" << str.toInt() << "" << oendl; |
208 | int id = str.toInt(); | 209 | int id = str.toInt(); |
209 | emit selectedDevice( id, m_dev[id].device() ); | 210 | emit selectedDevice( id, m_dev[id].device() ); |
210 | } | 211 | } |
211 | int DeviceBox::idFor ( int id ) { | 212 | int DeviceBox::idFor ( int id ) { |
212 | static int irId = 1501; | 213 | static int irId = 1501; |
213 | static int irBT = 1001; | 214 | static int irBT = 1001; |
214 | static int irSr = 501; | 215 | static int irSr = 501; |
215 | static int irEr = 0; | 216 | static int irEr = 0; |
216 | 217 | ||
217 | int ret = -1; | 218 | int ret = -1; |
218 | switch(id ) { | 219 | switch(id ) { |
219 | case IrDa: | 220 | case IrDa: |
220 | ret = irId; | 221 | ret = irId; |
221 | irId++; | 222 | irId++; |
222 | break; | 223 | break; |
223 | case BT: | 224 | case BT: |
224 | ret = irBT; | 225 | ret = irBT; |
225 | irBT++; | 226 | irBT++; |
226 | break; | 227 | break; |
227 | case Search: | 228 | case Search: |
228 | ret = irSr; | 229 | ret = irSr; |
229 | irSr++; | 230 | irSr++; |
230 | break; | 231 | break; |
231 | case Error: | 232 | case Error: |
232 | ret = irEr; | 233 | ret = irEr; |
233 | irEr++; | 234 | irEr++; |
234 | break; | 235 | break; |
235 | } | 236 | } |
236 | return ret; | 237 | return ret; |
237 | } | 238 | } |
238 | QString DeviceBox::allText() { | 239 | QString DeviceBox::allText() { |
239 | QString str; | 240 | QString str; |
240 | typedef QMap<int, DeviceItem> DeviceMap; | 241 | typedef QMap<int, DeviceItem> DeviceMap; |
241 | 242 | ||
242 | for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) { | 243 | for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) { |
243 | str += it.data().toString() + "<br>"; | 244 | str += it.data().toString() + "<br>"; |
244 | } | 245 | } |
245 | return str; | 246 | return str; |
246 | } | 247 | } |
247 | 248 | ||
248 | DeviceItem::DeviceItem( const QString& name, | 249 | DeviceItem::DeviceItem( const QString& name, |
249 | const QString& status, int dev, int id) | 250 | const QString& status, int dev, int id) |
250 | { | 251 | { |
251 | m_name = name; | 252 | m_name = name; |
252 | m_status = status; | 253 | m_status = status; |
253 | m_dev = dev; | 254 | m_dev = dev; |
254 | m_id = id; | 255 | m_id = id; |
255 | } | 256 | } |
256 | int DeviceItem::id()const { | 257 | int DeviceItem::id()const { |
257 | return m_id; | 258 | return m_id; |
258 | } | 259 | } |
259 | QString DeviceItem::name()const { | 260 | QString DeviceItem::name()const { |
260 | return m_name; | 261 | return m_name; |
261 | } | 262 | } |
262 | QString DeviceItem::status()const { | 263 | QString DeviceItem::status()const { |
263 | return m_status; | 264 | return m_status; |
264 | } | 265 | } |
265 | int DeviceItem::device()const { | 266 | int DeviceItem::device()const { |
266 | return m_dev; | 267 | return m_dev; |
267 | } | 268 | } |
268 | QString DeviceItem::pixmap()const{ | 269 | QString DeviceItem::pixmap()const{ |
269 | QString str; | 270 | QString str; |
270 | switch(m_dev) { | 271 | switch(m_dev) { |
271 | case DeviceBox::IrDa: | 272 | case DeviceBox::IrDa: |
272 | str ="obex/irda"; | 273 | str ="obex/irda"; |
273 | break; | 274 | break; |
274 | case DeviceBox::BT: | 275 | case DeviceBox::BT: |
275 | str ="obex/bt"; | 276 | str ="obex/bt"; |
276 | break; | 277 | break; |
277 | case DeviceBox::Search: | 278 | case DeviceBox::Search: |
278 | str = "mag"; | 279 | str = "mag"; |
279 | break; | 280 | break; |
280 | case DeviceBox::Error: | 281 | case DeviceBox::Error: |
281 | str = "editdelete"; | 282 | str = "editdelete"; |
282 | break; | 283 | break; |
283 | }; | 284 | }; |
284 | return str; | 285 | return str; |
285 | } | 286 | } |
286 | DeviceItem::~DeviceItem() { | 287 | DeviceItem::~DeviceItem() { |
287 | } | 288 | } |
288 | void DeviceItem::setStatus(const QString& status ) { | 289 | void DeviceItem::setStatus(const QString& status ) { |
289 | m_status = status; | 290 | m_status = status; |
290 | } | 291 | } |
291 | QString DeviceItem::toString()const { | 292 | QString DeviceItem::toString()const { |
292 | return "<p><a href=\""+QString::number(m_id) +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ; | 293 | return "<p><a href=\""+QString::number(m_id) +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ; |
293 | } | 294 | } |
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index ee2668b..8885256 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp | |||
@@ -1,199 +1,202 @@ | |||
1 | #include <sys/types.h> | 1 | #include "obex.h" |
2 | #include <sys/stat.h> | 2 | #include "receiver.h" |
3 | #include <sys/mman.h> | 3 | using namespace OpieObex; |
4 | #include <stdlib.h> // int system | ||
5 | #include <unistd.h> | ||
6 | 4 | ||
7 | #include <fcntl.h> | 5 | /* OPIE */ |
6 | #include <opie2/odebug.h> | ||
7 | #include <qpe/applnk.h> | ||
8 | #include <qpe/qpeapplication.h> | ||
9 | #include <qpe/qcopenvelope_qws.h> | ||
10 | using namespace Opie::Core; | ||
8 | 11 | ||
12 | /* QT */ | ||
9 | #include <qfileinfo.h> | 13 | #include <qfileinfo.h> |
10 | #include <qlabel.h> | 14 | #include <qlabel.h> |
11 | #include <qtextview.h> | 15 | #include <qtextview.h> |
12 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
13 | 17 | ||
14 | #include <qpe/applnk.h> | 18 | /* STD */ |
15 | #include <qpe/qpeapplication.h> | 19 | #include <sys/types.h> |
16 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <sys/stat.h> |
17 | 21 | #include <sys/mman.h> | |
18 | #include "obex.h" | 22 | #include <stdlib.h> // int system |
19 | #include "receiver.h" | 23 | #include <unistd.h> |
20 | 24 | #include <fcntl.h> | |
21 | using namespace OpieObex; | ||
22 | 25 | ||
23 | /* TRANSLATOR OpieObex::Receiver */ | 26 | /* TRANSLATOR OpieObex::Receiver */ |
24 | 27 | ||
25 | Receiver::Receiver() { | 28 | Receiver::Receiver() { |
26 | m_obex = new Obex(this, "Receiver"); | 29 | m_obex = new Obex(this, "Receiver"); |
27 | connect(m_obex, SIGNAL(receivedFile(const QString&) ), | 30 | connect(m_obex, SIGNAL(receivedFile(const QString&) ), |
28 | this, SLOT(slotReceived(const QString&) ) ); | 31 | this, SLOT(slotReceived(const QString&) ) ); |
29 | m_obex->receive(); | 32 | m_obex->receive(); |
30 | } | 33 | } |
31 | Receiver::~Receiver() { | 34 | Receiver::~Receiver() { |
32 | m_obex->setReceiveEnabled( false ); | 35 | m_obex->setReceiveEnabled( false ); |
33 | delete m_obex; | 36 | delete m_obex; |
34 | } | 37 | } |
35 | void Receiver::slotReceived( const QString& _file ) { | 38 | void Receiver::slotReceived( const QString& _file ) { |
36 | QString file = _file; | 39 | QString file = _file; |
37 | int check = checkFile(file); | 40 | int check = checkFile(file); |
38 | if ( check == AddressBook ) | 41 | if ( check == AddressBook ) |
39 | handleAddr( file ); | 42 | handleAddr( file ); |
40 | else if ( check == Datebook ) | 43 | else if ( check == Datebook ) |
41 | handleDateTodo( file ); | 44 | handleDateTodo( file ); |
42 | else | 45 | else |
43 | handleOther( file ); | 46 | handleOther( file ); |
44 | } | 47 | } |
45 | void Receiver::handleAddr( const QString& str ) { | 48 | void Receiver::handleAddr( const QString& str ) { |
46 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); | 49 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); |
47 | e << str; | 50 | e << str; |
48 | } | 51 | } |
49 | /* we can not say for sure if it's a VEevent ot VTodo */ | 52 | /* we can not say for sure if it's a VEevent ot VTodo */ |
50 | void Receiver::handleDateTodo( const QString& str ) { | 53 | void Receiver::handleDateTodo( const QString& str ) { |
51 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); | 54 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); |
52 | e0 << str; | 55 | e0 << str; |
53 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); | 56 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); |
54 | e1 << str; | 57 | e1 << str; |
55 | } | 58 | } |
56 | /* | 59 | /* |
57 | * Handle other asks if it should accept the | 60 | * Handle other asks if it should accept the |
58 | * beamed object and creates a DocLnk | 61 | * beamed object and creates a DocLnk |
59 | */ | 62 | */ |
60 | void Receiver::handleOther( const QString& other ) { | 63 | void Receiver::handleOther( const QString& other ) { |
61 | OtherHandler* hand = new OtherHandler(); | 64 | OtherHandler* hand = new OtherHandler(); |
62 | hand->handle( other ); | 65 | hand->handle( other ); |
63 | } | 66 | } |
64 | void Receiver::tidyUp( QString& _file, const QString& ending) { | 67 | void Receiver::tidyUp( QString& _file, const QString& ending) { |
65 | /* libversit fails on BASE64 encoding we try to sed it away */ | 68 | /* libversit fails on BASE64 encoding we try to sed it away */ |
66 | QString file = _file; | 69 | QString file = _file; |
67 | char foo[24]; // big enough | 70 | char foo[24]; // big enough |
68 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); | 71 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); |
69 | 72 | ||
70 | int fd = ::mkstemp(foo); | 73 | int fd = ::mkstemp(foo); |
71 | 74 | ||
72 | if ( fd == -1 ) | 75 | if ( fd == -1 ) |
73 | return; | 76 | return; |
74 | 77 | ||
75 | (void)::strncat( foo, ending.latin1(), 4 ); | 78 | (void)::strncat( foo, ending.latin1(), 4 ); |
76 | _file = QString::fromLatin1( foo ); | 79 | _file = QString::fromLatin1( foo ); |
77 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); | 80 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); |
78 | qWarning("Executing: %s", cmd.latin1() ); | 81 | owarn << "Executing: " << cmd << "" << oendl; |
79 | (void)::system( cmd.latin1() ); | 82 | (void)::system( cmd.latin1() ); |
80 | 83 | ||
81 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); | 84 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); |
82 | (void)::system( cmd.latin1() ); | 85 | (void)::system( cmd.latin1() ); |
83 | } | 86 | } |
84 | int Receiver::checkFile( QString& file ) { | 87 | int Receiver::checkFile( QString& file ) { |
85 | qWarning("check file!! %s", file.latin1() ); | 88 | owarn << "check file!! " << file << "" << oendl; |
86 | int ret; | 89 | int ret; |
87 | QString ending; | 90 | QString ending; |
88 | 91 | ||
89 | if (file.right(4) == ".vcs" ) { | 92 | if (file.right(4) == ".vcs" ) { |
90 | ret = Datebook; | 93 | ret = Datebook; |
91 | ending = QString::fromLatin1(".vcs"); | 94 | ending = QString::fromLatin1(".vcs"); |
92 | }else if ( file.right(4) == ".vcf") { | 95 | }else if ( file.right(4) == ".vcf") { |
93 | ret = AddressBook; | 96 | ret = AddressBook; |
94 | ending = QString::fromLatin1(".vcf"); | 97 | ending = QString::fromLatin1(".vcf"); |
95 | }else | 98 | }else |
96 | ret = Other; | 99 | ret = Other; |
97 | 100 | ||
98 | 101 | ||
99 | if (ending.isEmpty() ) | 102 | if (ending.isEmpty() ) |
100 | return ret; | 103 | return ret; |
101 | 104 | ||
102 | /** | 105 | /** |
103 | * currently the parser is broken in regard of BASE64 encoding | 106 | * currently the parser is broken in regard of BASE64 encoding |
104 | * and M$ likes to send that. So we will executed a small | 107 | * and M$ likes to send that. So we will executed a small |
105 | * tidy up system sed script | 108 | * tidy up system sed script |
106 | * At this point we can also remove umlaute from the filename | 109 | * At this point we can also remove umlaute from the filename |
107 | */ | 110 | */ |
108 | tidyUp( file, ending ); | 111 | tidyUp( file, ending ); |
109 | 112 | ||
110 | qWarning("check it now %d", ret ); | 113 | owarn << "check it now " << ret << "" << oendl; |
111 | return ret; | 114 | return ret; |
112 | } | 115 | } |
113 | 116 | ||
114 | /* TRANSLATOR OpieObex::OtherHandler */ | 117 | /* TRANSLATOR OpieObex::OtherHandler */ |
115 | 118 | ||
116 | OtherHandler::OtherHandler() | 119 | OtherHandler::OtherHandler() |
117 | : QVBox() | 120 | : QVBox() |
118 | { | 121 | { |
119 | QHBox* box = new QHBox(this); | 122 | QHBox* box = new QHBox(this); |
120 | QLabel* lbl = new QLabel(box); | 123 | QLabel* lbl = new QLabel(box); |
121 | lbl->setText(tr("<qt><b>Received:</b></qt>")); | 124 | lbl->setText(tr("<qt><b>Received:</b></qt>")); |
122 | m_na = new QLabel(box); | 125 | m_na = new QLabel(box); |
123 | 126 | ||
124 | QFrame* frame = new QFrame(this); | 127 | QFrame* frame = new QFrame(this); |
125 | frame->setFrameShape( QFrame::HLine ); | 128 | frame->setFrameShape( QFrame::HLine ); |
126 | frame->setFrameShadow( QFrame::Sunken ); | 129 | frame->setFrameShadow( QFrame::Sunken ); |
127 | 130 | ||
128 | m_view = new QTextView(this); | 131 | m_view = new QTextView(this); |
129 | 132 | ||
130 | box = new QHBox(this); | 133 | box = new QHBox(this); |
131 | QPushButton *but = new QPushButton(box); | 134 | QPushButton *but = new QPushButton(box); |
132 | but->setText(tr("Accept") ); | 135 | but->setText(tr("Accept") ); |
133 | connect(but, SIGNAL(clicked() ), | 136 | connect(but, SIGNAL(clicked() ), |
134 | this, SLOT(accept()) ); | 137 | this, SLOT(accept()) ); |
135 | 138 | ||
136 | but = new QPushButton(box); | 139 | but = new QPushButton(box); |
137 | but->setText(tr("Deny") ); | 140 | but->setText(tr("Deny") ); |
138 | connect(but, SIGNAL(clicked() ), | 141 | connect(but, SIGNAL(clicked() ), |
139 | this, SLOT(deny() ) ); | 142 | this, SLOT(deny() ) ); |
140 | 143 | ||
141 | raise(); | 144 | raise(); |
142 | showMaximized(); | 145 | showMaximized(); |
143 | } | 146 | } |
144 | OtherHandler::~OtherHandler() { | 147 | OtherHandler::~OtherHandler() { |
145 | 148 | ||
146 | } | 149 | } |
147 | void OtherHandler::handle( const QString& file ) { | 150 | void OtherHandler::handle( const QString& file ) { |
148 | m_file = file; | 151 | m_file = file; |
149 | m_na->setText(file); | 152 | m_na->setText(file); |
150 | DocLnk lnk(file); | 153 | DocLnk lnk(file); |
151 | qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() ); | 154 | owarn << " " << lnk.type() << " " << lnk.icon() << "" << oendl; |
152 | 155 | ||
153 | QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); | 156 | QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); |
154 | m_view->setText( str ); | 157 | m_view->setText( str ); |
155 | } | 158 | } |
156 | 159 | ||
157 | /* | 160 | /* |
158 | * hehe evil evil mmap ahead :) | 161 | * hehe evil evil mmap ahead :) |
159 | * we quickly copy the file and then we'll create a DocLnk for it | 162 | * we quickly copy the file and then we'll create a DocLnk for it |
160 | */ | 163 | */ |
161 | void OtherHandler::accept() { | 164 | void OtherHandler::accept() { |
162 | QString na = targetName( m_file ); | 165 | QString na = targetName( m_file ); |
163 | copy(m_file, na ); | 166 | copy(m_file, na ); |
164 | DocLnk lnk(na); | 167 | DocLnk lnk(na); |
165 | lnk.writeLink(); | 168 | lnk.writeLink(); |
166 | QFile::remove(m_file); | 169 | QFile::remove(m_file); |
167 | delete this; | 170 | delete this; |
168 | } | 171 | } |
169 | void OtherHandler::deny() { | 172 | void OtherHandler::deny() { |
170 | QFile::remove( m_file ); | 173 | QFile::remove( m_file ); |
171 | delete this; | 174 | delete this; |
172 | } | 175 | } |
173 | QString OtherHandler::targetName( const QString& file ) { | 176 | QString OtherHandler::targetName( const QString& file ) { |
174 | QFileInfo info( file ); | 177 | QFileInfo info( file ); |
175 | 178 | ||
176 | /* $HOME needs to be set!!!! */ | 179 | /* $HOME needs to be set!!!! */ |
177 | Global::createDocDir(); | 180 | Global::createDocDir(); |
178 | 181 | ||
179 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); | 182 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); |
180 | QString newFileBase = newFile; | 183 | QString newFileBase = newFile; |
181 | 184 | ||
182 | int trie = 0; | 185 | int trie = 0; |
183 | while (QFile::exists(newFile + "."+info.extension() ) ) { | 186 | while (QFile::exists(newFile + "."+info.extension() ) ) { |
184 | newFile = newFileBase + "_"+QString::number(trie) ; | 187 | newFile = newFileBase + "_"+QString::number(trie) ; |
185 | trie++; | 188 | trie++; |
186 | } | 189 | } |
187 | newFile += "." + info.extension(); | 190 | newFile += "." + info.extension(); |
188 | 191 | ||
189 | return newFile; | 192 | return newFile; |
190 | } | 193 | } |
191 | 194 | ||
192 | /* fast cpy */ | 195 | /* fast cpy */ |
193 | void OtherHandler::copy(const QString& src, const QString& file) { | 196 | void OtherHandler::copy(const QString& src, const QString& file) { |
194 | qWarning("src %s, dest %s", src.latin1(),file.latin1() ); | 197 | owarn << "src " << src << ", dest " << file << "" << oendl; |
195 | QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). | 198 | QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). |
196 | arg( Global::shellQuote( file ) ); | 199 | arg( Global::shellQuote( file ) ); |
197 | ::system( cmd.latin1() ); | 200 | ::system( cmd.latin1() ); |
198 | // done | 201 | // done |
199 | } | 202 | } |