-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 20 | ||||
-rw-r--r-- | core/applets/clockapplet/clock.cpp | 4 | ||||
-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 | 1 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 7 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 20 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 34 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 25 |
10 files changed, 63 insertions, 56 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 | |||
@@ -10,55 +10,51 @@ | |||
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, |
@@ -188,30 +184,30 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) | |||
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 | ||
@@ -322,25 +318,25 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) | |||
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 | { |
@@ -348,25 +344,25 @@ bool CardMonitor::getStatusSd( int showPopUp ) | |||
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 | } |
@@ -376,25 +372,25 @@ bool CardMonitor::getStatusSd( int showPopUp ) | |||
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 | ||
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 | |||
@@ -11,30 +11,34 @@ | |||
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(); |
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 | |||
@@ -198,37 +198,37 @@ void IrdaApplet::showDiscovered ( ) | |||
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 | } |
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 | |||
@@ -59,25 +59,25 @@ void Multikey::mousePressEvent(QMouseEvent *ev) | |||
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); |
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 | |||
@@ -44,29 +44,27 @@ static char *restart_xpm[] = { | |||
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 | |||
@@ -24,25 +24,24 @@ | |||
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 | { |
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 | |||
@@ -22,24 +22,25 @@ | |||
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() |
@@ -53,59 +54,59 @@ RotateApplet::RotateApplet() | |||
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 | } |
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 | |||
@@ -7,48 +7,50 @@ | |||
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", |
@@ -353,83 +355,83 @@ 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 | ||
@@ -448,25 +450,25 @@ void ScreenshotControl::performGrab() | |||
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 | } |
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 | |||
@@ -3,24 +3,28 @@ | |||
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 | ||
@@ -198,25 +202,25 @@ 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)"); |
@@ -236,25 +240,25 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
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 | } |
@@ -284,63 +288,63 @@ void VMemo::mouseReleaseEvent( QMouseEvent * ) { | |||
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; |
@@ -362,25 +366,25 @@ bool VMemo::startRecording() { | |||
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 | } |
@@ -390,25 +394,25 @@ int VMemo::openDSP() { | |||
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; |
@@ -474,55 +478,55 @@ int VMemo::openWAV(const char *filename) { | |||
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 |
@@ -531,72 +535,72 @@ bool VMemo::record() { | |||
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++) { |
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,40 +1,43 @@ | |||
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; |
@@ -65,85 +68,85 @@ QString VTApplet::tr( const char* s, const char* p ) const | |||
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; |