-rw-r--r-- | noncore/tools/clock/clock.cpp | 53 |
1 files changed, 46 insertions, 7 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 @@ -49,2 +49,7 @@ #include <math.h> +#include <unistd.h> +#include <sys/types.h> + +#include <pthread.h> + @@ -53,2 +58,12 @@ 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 ) @@ -399,2 +414,10 @@ void Clock::alarmOff() +void Clock::clearTimer() +{ + alarmOffBtn->setText( tr( "Alarm Is Off" ) ); + alarmBool = FALSE; + snoozeBtn->hide(); + setCaption( "Clock" ); +} + void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) @@ -408,8 +431,26 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) 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 + { @@ -435,5 +476,3 @@ void Clock::timerEvent( QTimerEvent *e ) killTimer( e->timerId() ); - alarmOffBtn->setText( tr( "Alarm Is Off" ) ); - alarmBool = FALSE; - snoozeBtn->hide(); + clearTimer(); setCaption( tr( "Clock: Alarm was missed." ) ); |