author | llornkcor <llornkcor> | 2003-02-17 01:22:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-17 01:22:21 (UTC) |
commit | a5e3911518d00ae327d3fe29871c03354344f086 (patch) (side-by-side diff) | |
tree | 15b4a17d942283a98bd7f482c380ef54220d2fa8 | |
parent | 0c50793d0ef839e90b9b2dea5001c3170971fc06 (diff) | |
download | opie-a5e3911518d00ae327d3fe29871c03354344f086.zip opie-a5e3911518d00ae327d3fe29871c03354344f086.tar.gz opie-a5e3911518d00ae327d3fe29871c03354344f086.tar.bz2 |
attempt to fix bug 586 - new thread and sleep 15 sec for cards to mount for mp3 alarm
-rw-r--r-- | noncore/tools/clock/clock.cpp | 53 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 2 | ||||
-rw-r--r-- | noncore/tools/clock/clock.pro | 2 |
3 files changed, 48 insertions, 9 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 2f81c3a..0937362 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp @@ -47,10 +47,25 @@ #include <qdatetime.h> #include <math.h> +#include <unistd.h> +#include <sys/types.h> + +#include <pthread.h> + const double deg2rad = 0.017453292519943295769; // pi/180 const int sw_prec = 2; +void startPlayer() +{ + Config config( "qpe" ); + config.setGroup( "Time" ); + sleep(15); + QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); + e << config.readEntry( "mp3File", "" ); +} + + static void toggleScreenSaver( bool on ) { QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); @@ -397,6 +412,14 @@ void Clock::alarmOff() setCaption( "Clock" ); } +void Clock::clearTimer() +{ + alarmOffBtn->setText( tr( "Alarm Is Off" ) ); + alarmBool = FALSE; + snoozeBtn->hide(); + setCaption( "Clock" ); +} + void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) { int stopTimer = 0; @@ -406,12 +429,30 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) if ( msg == "alarm(QDateTime,int)" ) { Config config( "qpe" ); config.setGroup( "Time" ); - if ( config.readBoolEntry( "mp3Alarm", 0 ) ) { + if ( config.readBoolEntry( "mp3Alarm", 0 ) ) + { + clearTimer(); +// pid_t pid; +// switch(pid = fork()) +// { +// case -1: +// {//failed +// } +// break; +// case 0: +// {//child +// QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); +// e << config.readEntry( "mp3File", "" ); + pthread_t thread; + pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); +// startPlayer(); +// } +// break; +// }; - QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); - e << config.readEntry( "mp3File", "" ); } - else { + else + { Sound::soundAlarm(); stopTimer = startTimer( timerStay ); @@ -433,9 +474,7 @@ void Clock::timerEvent( QTimerEvent *e ) else { stop = 0; killTimer( e->timerId() ); - alarmOffBtn->setText( tr( "Alarm Is Off" ) ); - alarmBool = FALSE; - snoozeBtn->hide(); + clearTimer(); setCaption( tr( "Clock: Alarm was missed." ) ); } } diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h index 092d84f..23cc143 100644 --- a/noncore/tools/clock/clock.h +++ b/noncore/tools/clock/clock.h @@ -80,7 +80,7 @@ private slots: void slotAdjustTime(); private: void clearClock(); - + void clearTimer(); bool alarmBool; QTimer *t; QLCDNumber *lcd; diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro index 29dd52b..8b92118 100644 --- a/noncore/tools/clock/clock.pro +++ b/noncore/tools/clock/clock.pro @@ -6,7 +6,7 @@ SOURCES = clock.cpp setAlarm.cpp \ main.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopie +LIBS += -lqpe -lopie -lpthread INTERFACES = TARGET = clock |