summaryrefslogtreecommitdiff
path: root/core/applets
authormickeyl <mickeyl>2004-04-05 12:48:49 (UTC)
committer mickeyl <mickeyl>2004-04-05 12:48:49 (UTC)
commitf1708be741dfb73ceaffb633b44093f2cb2b3d57 (patch) (unidiff)
tree0bdcab2ac6c5f0e5cac67eb58807a50bb79d82e0 /core/applets
parent0b481957a2eebf28b05d9803780d05ad4232aa00 (diff)
downloadopie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.zip
opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.gz
opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.bz2
convert core/applets/* to Opie debug framework
Diffstat (limited to 'core/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp26
-rw-r--r--core/applets/clockapplet/clock.cpp10
-rw-r--r--core/applets/irdaapplet/irda.cpp4
-rw-r--r--core/applets/multikeyapplet/multikey.cpp2
-rw-r--r--core/applets/restartapplet/restart.cpp2
-rw-r--r--core/applets/restartapplet/restartappletimpl.cpp5
-rw-r--r--core/applets/rotateapplet/rotate.cpp9
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp522
-rw-r--r--core/applets/vmemo/vmemo.cpp108
-rw-r--r--core/applets/vtapplet/vt.cpp65
10 files changed, 380 insertions, 373 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
@@ -16,16 +16,19 @@
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>
27using namespace Opie::Core;
28using 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>
@@ -35,24 +38,17 @@
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
47using namespace Opie;
48
49using namespace Opie::Ui;
50using namespace Opie::Ui;
51using namespace Opie::Core;
52
53CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), 49CardMonitor::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,
@@ -194,26 +190,26 @@ void CardMonitor::mousePressEvent( QMouseEvent * )
194 190
195 191
196void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) 192void 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
210bool CardMonitor::getStatusPcmcia( int showPopUp ) 206bool 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" ) )
@@ -328,13 +324,13 @@ bool CardMonitor::getStatusPcmcia( int showPopUp )
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 );
@@ -342,25 +338,25 @@ bool CardMonitor::getStatusPcmcia( int showPopUp )
342} 338}
343 339
344 340
345bool CardMonitor::getStatusSd( int showPopUp ) 341bool 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 }
@@ -382,17 +378,17 @@ bool CardMonitor::getStatusSd( int showPopUp )
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 );
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
@@ -17,18 +17,22 @@
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
30using namespace Opie::Core;
28using namespace Opie::Ui; 31using namespace Opie::Ui;
32
29LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) 33LauncherClock::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() ) );
@@ -52,15 +56,15 @@ void LauncherClock::readConfig() {
52 config.setGroup( "Date" ); 56 config.setGroup( "Date" );
53 format = config.readNumEntry("ClockApplet",0); 57 format = config.readNumEntry("ClockApplet",0);
54} 58}
55 59
56void LauncherClock::mouseReleaseEvent( QMouseEvent * ) 60void 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
64void LauncherClock::timerEvent( QTimerEvent *e ) 68void LauncherClock::timerEvent( QTimerEvent *e )
65{ 69{
66 if ( !e || e->timerId() == timerId ) { 70 if ( !e || e->timerId() == timerId ) {
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
@@ -204,25 +204,25 @@ void IrdaApplet::showDiscovered ( )
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;
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
@@ -65,13 +65,13 @@ 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
76void Multikey::message(const QCString &message, const QByteArray &data) 76void Multikey::message(const QCString &message, const QByteArray &data)
77{ 77{
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
@@ -50,23 +50,21 @@ static char *restart_xpm[] = {
50" .. ", 50" .. ",
51" "}; 51" "};
52RestartApplet::RestartApplet( QWidget *parent, const char *name ) 52RestartApplet::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
60RestartApplet::~RestartApplet() { 59RestartApplet::~RestartApplet() {
61} 60}
62 61
63void RestartApplet::mousePressEvent( QMouseEvent *) { 62void RestartApplet::mousePressEvent( QMouseEvent *) {
64 QCopEnvelope e("QPE/System", "restart()"); 63 QCopEnvelope e("QPE/System", "restart()");
65} 64}
66 65
67void RestartApplet::paintEvent( QPaintEvent* ) { 66void 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
@@ -30,13 +30,12 @@ RestartAppletImpl::~RestartAppletImpl()
30{ 30{
31 delete restart; 31 delete restart;
32} 32}
33 33
34QWidget *RestartAppletImpl::applet( QWidget *parent ) 34QWidget *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
42int RestartAppletImpl::position() const 41int RestartAppletImpl::position() const
@@ -49,14 +48,14 @@ QRESULT RestartAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface
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
62Q_EXPORT_INTERFACE() 61Q_EXPORT_INTERFACE()
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
@@ -28,12 +28,13 @@
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>
39using namespace Opie::Core; 40using namespace Opie::Core;
@@ -59,23 +60,23 @@ RotateApplet::~RotateApplet ( )
59 60
60/** 61/**
61 * Qcop receive method. 62 * Qcop receive method.
62 */ 63 */
63void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) 64void 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 )
@@ -93,13 +94,13 @@ void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data
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 ( );
@@ -236,13 +237,13 @@ QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **ifa
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
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
@@ -13,15 +13,18 @@
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>
23using namespace Opie::Core;
24using 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>
@@ -36,192 +39,191 @@
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 */
42using namespace Opie::Ui;
43static char * snapshot_xpm[] = { 45static 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"; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ",
@@ -296,13 +298,13 @@ ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
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
308void ScreenshotControl::slotGrab() 310void ScreenshotControl::slotGrab()
@@ -359,141 +361,141 @@ void ScreenshotControl::savePixmap()
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
404void ScreenshotControl::performGrab() 406void 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
490ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) 492ScreenshotApplet::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
@@ -511,32 +513,32 @@ void ScreenshotApplet::mousePressEvent( QMouseEvent *)
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
534void ScreenshotApplet::paintEvent( QPaintEvent* ) 536void 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
541EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) 543EXPORT_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
@@ -9,12 +9,16 @@
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>
17using namespace Opie::Core;
18
15extern "C" { 19extern "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>
@@ -26,13 +30,13 @@ extern "C" {
26 30
27typedef struct _waveheader { 31typedef 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) */
@@ -195,27 +199,27 @@ static char * vmemo_xpm[] = {
195 199
196using namespace Opie::Ui; 200using namespace Opie::Ui;
197VMemo::VMemo( QWidget *parent, const char *_name ) 201VMemo::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)
@@ -242,13 +246,13 @@ VMemo::~VMemo() {
242int VMemo::position() 246int VMemo::position()
243{ 247{
244 return 6; 248 return 6;
245} 249}
246 250
247void VMemo::receive( const QCString &msg, const QByteArray &data ) { 251void 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();
@@ -264,13 +268,13 @@ void VMemo::paintEvent( QPaintEvent* ) {
264 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 268 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
265} 269}
266 270
267void VMemo::mousePressEvent( QMouseEvent * me) { 271void 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();
@@ -290,20 +294,20 @@ bool VMemo::startRecording() {
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(":"),".");
@@ -315,27 +319,27 @@ bool VMemo::startRecording() {
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);
@@ -346,35 +350,35 @@ bool VMemo::startRecording() {
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
372void VMemo::stopRecording() { 376void 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 }
@@ -385,43 +389,43 @@ void VMemo::stopRecording() {
385 hide(); 389 hide();
386} 390}
387 391
388int VMemo::openDSP() { 392int 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\")");
@@ -434,13 +438,13 @@ int VMemo::openDSP() {
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
444int VMemo::openWAV(const char *filename) { 448int 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)) {
@@ -449,55 +453,55 @@ int VMemo::openWAV(const char *filename) {
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
481bool VMemo::record() { 485bool 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];
@@ -510,13 +514,13 @@ bool VMemo::record() {
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
@@ -537,13 +541,13 @@ bool VMemo::record() {
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 // }
@@ -556,41 +560,41 @@ bool VMemo::record() {
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
@@ -599,38 +603,38 @@ return TRUE;
599 603
600int VMemo::setToggleButton(int tog) { 604int 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
636void VMemo::timerBreak() { 640void VMemo::timerBreak() {
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,36 +1,39 @@
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>
19using 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
29VTApplet::VTApplet ( ) 32VTApplet::VTApplet ( )
30 : QObject ( 0, "VTApplet" ) 33 : QObject ( 0, "VTApplet" )
31{ 34{
32} 35}
33 36
34VTApplet::~VTApplet ( ) 37VTApplet::~VTApplet ( )
35{ 38{
36} 39}
@@ -39,18 +42,18 @@ int VTApplet::position ( ) const
39{ 42{
40 return 2; 43 return 2;
41} 44}
42 45
43QString VTApplet::name ( ) const 46QString VTApplet::name ( ) const
44{ 47{
45 return tr( "VT shortcut" ); 48 return tr( "VT shortcut" );
46} 49}
47 50
48QString VTApplet::text ( ) const 51QString VTApplet::text ( ) const
49{ 52{
50 return tr( "Terminal" ); 53 return tr( "Terminal" );
51} 54}
52 55
53/* 56/*
54QString VTApplet::tr( const char* s ) const 57QString VTApplet::tr( const char* s ) const
55{ 58{
56 return qApp->translate( "VTApplet", s, 0 ); 59 return qApp->translate( "VTApplet", s, 0 );
@@ -61,23 +64,23 @@ QString VTApplet::tr( const char* s, const char* p ) const
61 return qApp->translate( "VTApplet", s, p ); 64 return qApp->translate( "VTApplet", s, p );
62} 65}
63*/ 66*/
64 67
65QIconSet VTApplet::icon ( ) const 68QIconSet 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
75QPopupMenu *VTApplet::popup ( QWidget* parent ) const 78QPopupMenu *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
@@ -96,66 +99,66 @@ QPopupMenu *VTApplet::popup ( QWidget* parent ) const
96 return m_subMenu; 99 return m_subMenu;
97} 100}
98 101
99 102
100void VTApplet::changeVT( int index ) 103void 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
110void VTApplet::updateMenu() 113void 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
135void VTApplet::activated() 138void VTApplet::activated()
136{ 139{
137 qDebug( "VTApplet::activated()" ); 140 odebug << "VTApplet::activated()" << oendl;
138} 141}
139 142
140 143
141QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 144QRESULT 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
156Q_EXPORT_INTERFACE( ) 159Q_EXPORT_INTERFACE( )
157{ 160{
158 Q_CREATE_INSTANCE( VTApplet ) 161 Q_CREATE_INSTANCE( VTApplet )
159} 162}
160 163
161 164