-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index eff96eb..2acfacf 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -39,65 +39,69 @@ | |||
39 | #define protected public | 39 | #define protected public |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #undef protected | 41 | #undef protected |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qtopia/qcopenvelope_qws.h> | 43 | #include <qtopia/qcopenvelope_qws.h> |
44 | #include <qtopia/alarmserver.h> | 44 | #include <qtopia/alarmserver.h> |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | 51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) |
52 | : QLabel( parent ) | 52 | : QLabel( parent ) |
53 | { | 53 | { |
54 | mAlarmDialog = new AlarmDialog( 0 ); | 54 | mAlarmDialog = new AlarmDialog( 0 ); |
55 | mPopUp = new QPopupMenu( this ); | 55 | mPopUp = new QPopupMenu( this ); |
56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); | 56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); |
57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); | 57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); |
58 | mPopUp->insertSeparator(); | 58 | mPopUp->insertSeparator(); |
59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); | 59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); |
60 | mPopUp->insertSeparator(); | 60 | mPopUp->insertSeparator(); |
61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); | 61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); |
62 | mPopUp->insertSeparator(); | 62 | mPopUp->insertSeparator(); |
63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); | 63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); |
64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); | 64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); |
65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); | 65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); |
66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); | 66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); |
67 | mPopUp->insertSeparator(); | 67 | mPopUp->insertSeparator(); |
68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); | 68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); |
69 | mTimerPopUp = new QPopupMenu( this ); | 69 | mTimerPopUp = new QPopupMenu( this ); |
70 | QFont fon = mTimerPopUp->font(); | 70 | QFont fon = mTimerPopUp->font(); |
71 | fon.setPointSize( fon.pointSize() *3/2 ); | 71 | int points = 16; |
72 | if ( QApplication::desktop()->width() < 480 ) | ||
73 | points = 12; | ||
74 | fon.setPointSize( points ); | ||
75 | //qDebug("point s %d ", fon.pointSize()); | ||
72 | mTimerPopUp->setFont( fon ); | 76 | mTimerPopUp->setFont( fon ); |
73 | mPopUp->setFont( fon ); | 77 | mPopUp->setFont( fon ); |
74 | mBeepPopUp = new QPopupMenu( this ); | 78 | mBeepPopUp = new QPopupMenu( this ); |
75 | mSoundPopUp = new QPopupMenu( this ); | 79 | mSoundPopUp = new QPopupMenu( this ); |
76 | mPausePopUp = new QPopupMenu( this ); | 80 | mPausePopUp = new QPopupMenu( this ); |
77 | QPopupMenu* savePopUp = new QPopupMenu( this ); | 81 | QPopupMenu* savePopUp = new QPopupMenu( this ); |
78 | savePopUp->insertItem( "Save", 0 ); | 82 | savePopUp->insertItem( "Save", 0 ); |
79 | savePopUp->insertItem( "Load", 1 ); | 83 | savePopUp->insertItem( "Load", 1 ); |
80 | mSoundPopUp->insertItem( "Buzzer", 0 ); | 84 | mSoundPopUp->insertItem( "Buzzer", 0 ); |
81 | mSoundPopUp->insertItem( "Wav file", 1 ); | 85 | mSoundPopUp->insertItem( "Wav file", 1 ); |
82 | mPausePopUp->insertItem( " 1 sec", 1 ); | 86 | mPausePopUp->insertItem( " 1 sec", 1 ); |
83 | mPausePopUp->insertItem( " 2 sec", 2 ); | 87 | mPausePopUp->insertItem( " 2 sec", 2 ); |
84 | mPausePopUp->insertItem( " 3 sec", 3 ); | 88 | mPausePopUp->insertItem( " 3 sec", 3 ); |
85 | mPausePopUp->insertItem( " 5 sec", 5 ); | 89 | mPausePopUp->insertItem( " 5 sec", 5 ); |
86 | mPausePopUp->insertItem( "10 sec", 10 ); | 90 | mPausePopUp->insertItem( "10 sec", 10 ); |
87 | mPausePopUp->insertItem( "30 sec", 30 ); | 91 | mPausePopUp->insertItem( "30 sec", 30 ); |
88 | mPausePopUp->insertItem( " 1 min", 60 ); | 92 | mPausePopUp->insertItem( " 1 min", 60 ); |
89 | mPausePopUp->insertItem( " 5 min", 300 ); | 93 | mPausePopUp->insertItem( " 5 min", 300 ); |
90 | mPausePopUp->insertItem( "10 min", 600 ); | 94 | mPausePopUp->insertItem( "10 min", 600 ); |
91 | mSuspendPopUp = new QPopupMenu( this ); | 95 | mSuspendPopUp = new QPopupMenu( this ); |
92 | mSuspendPopUp->insertItem( "Off", 0 ); | 96 | mSuspendPopUp->insertItem( "Off", 0 ); |
93 | mSuspendPopUp->insertItem( " 1x", 1 ); | 97 | mSuspendPopUp->insertItem( " 1x", 1 ); |
94 | mSuspendPopUp->insertItem( " 2x", 2 ); | 98 | mSuspendPopUp->insertItem( " 2x", 2 ); |
95 | mSuspendPopUp->insertItem( " 3x", 3 ); | 99 | mSuspendPopUp->insertItem( " 3x", 3 ); |
96 | mSuspendPopUp->insertItem( " 5x", 5 ); | 100 | mSuspendPopUp->insertItem( " 5x", 5 ); |
97 | mSuspendPopUp->insertItem( "10x", 10 ); | 101 | mSuspendPopUp->insertItem( "10x", 10 ); |
98 | mSuspendPopUp->insertItem( "20x", 20 ); | 102 | mSuspendPopUp->insertItem( "20x", 20 ); |
99 | mSuspendPopUp->insertItem( "30x", 30 ); | 103 | mSuspendPopUp->insertItem( "30x", 30 ); |
100 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | 104 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); |
101 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | 105 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); |
102 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | 106 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); |
103 | mBeepPopUp->insertItem( "Config",savePopUp ); | 107 | mBeepPopUp->insertItem( "Config",savePopUp ); |
@@ -283,98 +287,96 @@ void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | |||
283 | else { | 287 | else { |
284 | tempfilename = mess.mid( 13, len ); | 288 | tempfilename = mess.mid( 13, len ); |
285 | if ( !QFile::exists( tempfilename ) ) | 289 | if ( !QFile::exists( tempfilename ) ) |
286 | error = true; | 290 | error = true; |
287 | } | 291 | } |
288 | if ( ! error ) { | 292 | if ( ! error ) { |
289 | filename = tempfilename; | 293 | filename = tempfilename; |
290 | } | 294 | } |
291 | mAlarmMessage = mess.mid( 13+len+3 ); | 295 | mAlarmMessage = mess.mid( 13+len+3 ); |
292 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 296 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
293 | startAlarm( mAlarmMessage, filename); | 297 | startAlarm( mAlarmMessage, filename); |
294 | return; | 298 | return; |
295 | } | 299 | } |
296 | if ( mess.left( 11 ) == "timer_alarm") { | 300 | if ( mess.left( 11 ) == "timer_alarm") { |
297 | mTimerTime = 0; | 301 | mTimerTime = 0; |
298 | startAlarm( mess.mid( 11 ), filename ); | 302 | startAlarm( mess.mid( 11 ), filename ); |
299 | return; | 303 | return; |
300 | } | 304 | } |
301 | if ( mess.left( 10 ) == "proc_alarm") { | 305 | if ( mess.left( 10 ) == "proc_alarm") { |
302 | bool error = false; | 306 | bool error = false; |
303 | int len = mess.mid( 10 ).find("+++"); | 307 | int len = mess.mid( 10 ).find("+++"); |
304 | if ( len < 2 ) | 308 | if ( len < 2 ) |
305 | error = true; | 309 | error = true; |
306 | else { | 310 | else { |
307 | tempfilename = mess.mid( 10, len ); | 311 | tempfilename = mess.mid( 10, len ); |
308 | if ( !QFile::exists( tempfilename ) ) | 312 | if ( !QFile::exists( tempfilename ) ) |
309 | error = true; | 313 | error = true; |
310 | } | 314 | } |
311 | if ( error ) { | 315 | if ( error ) { |
312 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 316 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
313 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 317 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
314 | } else { | 318 | } else { |
315 | { | ||
316 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | ||
317 | } | ||
318 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 319 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
319 | if ( vfork () == 0 ) { | 320 | if ( vfork () == 0 ) { |
320 | execl ( tempfilename.latin1(), 0 ); | 321 | execl ( tempfilename.latin1(), 0 ); |
321 | return; | 322 | return; |
322 | } | 323 | } |
324 | QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); | ||
323 | return; | 325 | return; |
324 | } | 326 | } |
325 | 327 | ||
326 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 328 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
327 | } | 329 | } |
328 | if ( mess.left( 11 ) == "audio_alarm") { | 330 | if ( mess.left( 11 ) == "audio_alarm") { |
329 | bool error = false; | 331 | bool error = false; |
330 | int len = mess.mid( 11 ).find("+++"); | 332 | int len = mess.mid( 11 ).find("+++"); |
331 | if ( len < 2 ) | 333 | if ( len < 2 ) |
332 | error = true; | 334 | error = true; |
333 | else { | 335 | else { |
334 | tempfilename = mess.mid( 11, len ); | 336 | tempfilename = mess.mid( 11, len ); |
335 | if ( !QFile::exists( tempfilename ) ) | 337 | if ( !QFile::exists( tempfilename ) ) |
336 | error = true; | 338 | error = true; |
337 | } | 339 | } |
338 | if ( ! error ) { | 340 | if ( ! error ) { |
339 | filename = tempfilename; | 341 | filename = tempfilename; |
340 | } | 342 | } |
341 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 343 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
342 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 344 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
343 | } | 345 | } |
344 | if ( mess.left( 9 ) == "cal_alarm") { | 346 | if ( mess.left( 9 ) == "cal_alarm") { |
345 | mAlarmMessage = mess.mid( 9 ) ; | 347 | mAlarmMessage = mess.mid( 9 ) ; |
346 | } | 348 | } |
347 | 349 | ||
348 | writeFile(); | 350 | QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); |
349 | startAlarm( mAlarmMessage, filename ); | 351 | startAlarm( mAlarmMessage, filename ); |
350 | 352 | ||
351 | } | 353 | } |
352 | 354 | ||
353 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 355 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
354 | { | 356 | { |
355 | return 0; | 357 | return 0; |
356 | } | 358 | } |
357 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 359 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
358 | { | 360 | { |
359 | //mAlarmDialog->show(); | 361 | //mAlarmDialog->show(); |
360 | //mAlarmDialog->raise(); | 362 | //mAlarmDialog->raise(); |
361 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 363 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
362 | } | 364 | } |
363 | 365 | ||
364 | 366 | ||
365 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 367 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
366 | { | 368 | { |
367 | 369 | ||
368 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 370 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
369 | if ( mTimerPopupConf == mTimerTime ) { | 371 | if ( mTimerPopupConf == mTimerTime ) { |
370 | if ( mTimerTime ) { | 372 | if ( mTimerTime ) { |
371 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 373 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
372 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 374 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
373 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 375 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
374 | } | 376 | } |
375 | else { | 377 | else { |
376 | QString text = mCustomText.stripWhiteSpace (); | 378 | QString text = mCustomText.stripWhiteSpace (); |
377 | int in = text.find( " " ); | 379 | int in = text.find( " " ); |
378 | text = text.left ( in ); | 380 | text = text.left ( in ); |
379 | mTimerPopUp->changeItem ( 3, text ); | 381 | mTimerPopUp->changeItem ( 3, text ); |
380 | } | 382 | } |
@@ -619,62 +621,62 @@ void SimpleAlarmDaemonImpl::showWN() | |||
619 | { | 621 | { |
620 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 622 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
621 | } | 623 | } |
622 | void SimpleAlarmDaemonImpl::newTodo() | 624 | void SimpleAlarmDaemonImpl::newTodo() |
623 | { | 625 | { |
624 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 626 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
625 | } | 627 | } |
626 | 628 | ||
627 | void SimpleAlarmDaemonImpl::newEvent() | 629 | void SimpleAlarmDaemonImpl::newEvent() |
628 | { | 630 | { |
629 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 631 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
630 | 632 | ||
631 | } | 633 | } |
632 | void SimpleAlarmDaemonImpl::newMail() | 634 | void SimpleAlarmDaemonImpl::newMail() |
633 | { | 635 | { |
634 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 636 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
635 | } | 637 | } |
636 | void SimpleAlarmDaemonImpl::showAdd() | 638 | void SimpleAlarmDaemonImpl::showAdd() |
637 | { | 639 | { |
638 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 640 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
639 | } | 641 | } |
640 | void SimpleAlarmDaemonImpl::ringSync() | 642 | void SimpleAlarmDaemonImpl::ringSync() |
641 | { | 643 | { |
642 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 644 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
643 | 645 | ||
644 | } | 646 | } |
645 | void SimpleAlarmDaemonImpl::newCountdown() | 647 | void SimpleAlarmDaemonImpl::newCountdown() |
646 | { | 648 | { |
647 | //recieve("cal_alarm", 10 ); | 649 | //recieve("cal_alarm", 10 ); |
648 | } | 650 | } |
649 | void SimpleAlarmDaemonImpl::simulate() | 651 | void SimpleAlarmDaemonImpl::simulate() |
650 | { | 652 | { |
651 | writeFile(); | 653 | QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); |
652 | QString filename = getenv("QPEDIR") ; | 654 | QString filename = getenv("QPEDIR") ; |
653 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 655 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
654 | startAlarm("Alarm simulation", filename ); | 656 | startAlarm("Alarm simulation", filename ); |
655 | } | 657 | } |
656 | void SimpleAlarmDaemonImpl::showKO() | 658 | void SimpleAlarmDaemonImpl::showKO() |
657 | { | 659 | { |
658 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 660 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
659 | // testing only | 661 | // testing only |
660 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | 662 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); |
661 | 663 | ||
662 | } | 664 | } |
663 | void SimpleAlarmDaemonImpl::showTodo() | 665 | void SimpleAlarmDaemonImpl::showTodo() |
664 | { | 666 | { |
665 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 667 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
666 | 668 | ||
667 | } | 669 | } |
668 | void SimpleAlarmDaemonImpl::writeJournal() | 670 | void SimpleAlarmDaemonImpl::writeJournal() |
669 | { | 671 | { |
670 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 672 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
671 | 673 | ||
672 | } | 674 | } |
673 | 675 | ||
674 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 676 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
675 | { | 677 | { |
676 | 678 | ||
677 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 679 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
678 | 680 | ||
679 | } | 681 | } |
680 | 682 | ||