summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
Unidiff
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 18e4299..4ff6861 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -307,301 +307,301 @@ void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
307 } 307 }
308 return; 308 return;
309 } 309 }
310 310
311 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 311 //qDebug("+++++++system command %s ",tempfilename.latin1() );
312 } 312 }
313 if ( mess.left( 11 ) == "audio_alarm") { 313 if ( mess.left( 11 ) == "audio_alarm") {
314 bool error = false; 314 bool error = false;
315 int len = mess.mid( 11 ).find("+++"); 315 int len = mess.mid( 11 ).find("+++");
316 if ( len < 2 ) 316 if ( len < 2 )
317 error = true; 317 error = true;
318 else { 318 else {
319 tempfilename = mess.mid( 11, len ); 319 tempfilename = mess.mid( 11, len );
320 if ( !QFile::exists( tempfilename ) ) 320 if ( !QFile::exists( tempfilename ) )
321 error = true; 321 error = true;
322 } 322 }
323 if ( ! error ) { 323 if ( ! error ) {
324 filename = tempfilename; 324 filename = tempfilename;
325 } 325 }
326 mAlarmMessage = mess.mid( 11+len+3+9 ); 326 mAlarmMessage = mess.mid( 11+len+3+9 );
327 //qDebug("audio file command %s ",tempfilename.latin1() ); 327 //qDebug("audio file command %s ",tempfilename.latin1() );
328 } 328 }
329 if ( mess.left( 9 ) == "cal_alarm") { 329 if ( mess.left( 9 ) == "cal_alarm") {
330 mAlarmMessage = mess.mid( 9 ) ; 330 mAlarmMessage = mess.mid( 9 ) ;
331 } 331 }
332 332
333 writeFile(); 333 writeFile();
334 startAlarm( mAlarmMessage, filename ); 334 startAlarm( mAlarmMessage, filename );
335 335
336} 336}
337 337
338int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 338int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
339{ 339{
340 return 0; 340 return 0;
341} 341}
342void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 342void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
343{ 343{
344 //mAlarmDialog->show(); 344 //mAlarmDialog->show();
345 //mAlarmDialog->raise(); 345 //mAlarmDialog->raise();
346 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 346 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
347} 347}
348 348
349 349
350void SimpleAlarmDaemonImpl::fillTimerPopUp() 350void SimpleAlarmDaemonImpl::fillTimerPopUp()
351{ 351{
352 352
353 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 353 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
354 if ( mTimerPopupConf == mTimerTime ) { 354 if ( mTimerPopupConf == mTimerTime ) {
355 if ( mTimerTime ) { 355 if ( mTimerTime ) {
356 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 356 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
357 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 357 QTime t ( secs/3600, (secs/60)%60, secs%60 );
358 mTimerPopUp->changeItem ( 1 , t.toString()); 358 mTimerPopUp->changeItem ( 1 , t.toString());
359 } 359 }
360 else { 360 else {
361 QString text = mCustomText.stripWhiteSpace (); 361 QString text = mCustomText.stripWhiteSpace ();
362 int in = text.find( " " ); 362 int in = text.find( " " );
363 text = text.left ( in ); 363 text = text.left ( in );
364 mTimerPopUp->changeItem ( 3, text ); 364 mTimerPopUp->changeItem ( 3, text );
365 } 365 }
366 return; 366 return;
367 } 367 }
368 mTimerPopupConf = mTimerTime; 368 mTimerPopupConf = mTimerTime;
369 mTimerPopUp->clear(); 369 mTimerPopUp->clear();
370 if ( mTimerTime ) { 370 if ( mTimerTime ) {
371 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 371 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
372 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 372 QTime t ( secs/3600, (secs/60)%60, secs%60 );
373 mTimerPopUp->insertItem( "Stop", 0 ); 373 mTimerPopUp->insertItem( "Stop", 0 );
374 mTimerPopUp->insertItem( t.toString(),1); 374 mTimerPopUp->insertItem( t.toString(),1);
375 } else { 375 } else {
376 376
377 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 377 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
378 QFile file( fileName ); 378 QFile file( fileName );
379 if( !QFile::exists( fileName) ) { 379 if( !QFile::exists( fileName) ) {
380 // write defaults 380 // write defaults
381 if (!file.open( IO_WriteOnly ) ) { 381 if (!file.open( IO_WriteOnly ) ) {
382 return; 382 return;
383 } 383 }
384 QString configString ; 384 QString configString ;
385 configString += "#config file for kopi alarm timer\n"; 385 configString += "#config file for kopi alarm timer\n";
386 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 386 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
387 configString += "#NOTE: minimum value for timer are 3 minutes!\n"; 387 configString += "#NOTE: minimum value for timer are 3 minutes!\n";
388 configString += "24 h; 1440\n"; 388 configString += "24 h; 1440\n";
389 configString += " 8 h; 480\n"; 389 configString += " 8 h; 480\n";
390 configString += " 5 h; 300\n"; 390 configString += " 5 h; 300\n";
391 configString += " 1 h; 60\n"; 391 configString += " 1 h; 60\n";
392 configString += "30 min; 30\n"; 392 configString += "30 min; 30\n";
393 configString += "15 min; 15\n"; 393 configString += "15 min; 15\n";
394 configString += "SEPARATOR\n"; 394 configString += "SEPARATOR\n";
395 configString += "Pizza; 22\n"; 395 configString += "Pizza; 22\n";
396 configString += "Nap; 45\n"; 396 configString += "Nap; 45\n";
397 configString += "Tea; 5\n"; 397 configString += "Tea; 5\n";
398 QTextStream ts( &file ); 398 QTextStream ts( &file );
399 ts << configString ; 399 ts << configString ;
400 file.close(); 400 file.close();
401 } 401 }
402 402
403 if (!file.open( IO_ReadOnly ) ) { 403 if (!file.open( IO_ReadOnly ) ) {
404 return ; 404 return ;
405 } 405 }
406 QString line; 406 QString line;
407 bool ok; 407 bool ok;
408 while ( file.readLine( line, 1024 ) > 0 ) { 408 while ( file.readLine( line, 1024 ) > 0 ) {
409 //qDebug("read %s ", line.latin1()); 409 //qDebug("read %s ", line.latin1());
410 if ( line.left(1 ) != "#" ) { 410 if ( line.left(1 ) != "#" ) {
411 // no comment 411 // no comment
412 if ( line.left(9 ) == "SEPARATOR" ) { 412 if ( line.left(9 ) == "SEPARATOR" ) {
413 mTimerPopUp->insertSeparator(); 413 mTimerPopUp->insertSeparator();
414 } else { 414 } else {
415 QStringList li = QStringList::split(";",line); 415 QStringList li = QStringList::split(";",line);
416 ok = false; 416 ok = false;
417 if ( li.count() == 2 ) { 417 if ( li.count() == 2 ) {
418 int val = li[1].toInt( &ok ); 418 int val = li[1].toInt( &ok );
419 if ( ok && val > 2 ) { 419 if ( ok && val > 2 ) {
420 mTimerPopUp->insertItem( li[0], val); 420 mTimerPopUp->insertItem( li[0], val);
421 } 421 }
422 } 422 }
423 } 423 }
424 } 424 }
425 } 425 }
426 file.close(); 426 file.close();
427#if 0 427#if 0
428 mTimerPopUp->insertItem( "24 h", 1440 ); 428 mTimerPopUp->insertItem( "24 h", 1440 );
429 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 429 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
430 mTimerPopUp->insertItem( " 8 h", 480 ); 430 mTimerPopUp->insertItem( " 8 h", 480 );
431 mTimerPopUp->insertItem( " 5 h", 300 ); 431 mTimerPopUp->insertItem( " 5 h", 300 );
432 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 432 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
433 mTimerPopUp->insertItem( " 1 h", 60 ); 433 mTimerPopUp->insertItem( " 1 h", 60 );
434 mTimerPopUp->insertItem( "30 min", 30 ); 434 mTimerPopUp->insertItem( "30 min", 30 );
435 mTimerPopUp->insertItem( "15 min", 15 ); 435 mTimerPopUp->insertItem( "15 min", 15 );
436 mTimerPopUp->insertItem( "10 min", 10 ); 436 mTimerPopUp->insertItem( "10 min", 10 );
437 //mTimerPopUp->insertItem( " 5 min", 5 ); 437 //mTimerPopUp->insertItem( " 5 min", 5 );
438 mTimerPopUp->insertSeparator(); 438 mTimerPopUp->insertSeparator();
439 mTimerPopUp->insertItem( "Pizza", 22 ); 439 mTimerPopUp->insertItem( "Pizza", 22 );
440 mTimerPopUp->insertItem( "Nap", 45 ); 440 mTimerPopUp->insertItem( "Nap", 45 );
441 mTimerPopUp->insertItem( "Tea", 5 ); 441 mTimerPopUp->insertItem( "Tea", 5 );
442#endif 442#endif
443 QString text = mCustomText.stripWhiteSpace (); 443 QString text = mCustomText.stripWhiteSpace ();
444 int in = text.find( " " ); 444 int in = text.find( " " );
445 text = text.left ( in ); 445 text = text.left ( in );
446 mTimerPopUp->insertItem( text, 3 ); 446 mTimerPopUp->insertItem( text, 3 );
447 mTimerPopUp->insertSeparator(); 447 mTimerPopUp->insertSeparator();
448 mTimerPopUp->insertItem( "Customize", 2 ); 448 mTimerPopUp->insertItem( "Customize", 2 );
449 } 449 }
450 450
451} 451}
452 452
453void SimpleAlarmDaemonImpl::showTimer() 453void SimpleAlarmDaemonImpl::showTimer()
454{ 454{
455 fillTimerPopUp(); 455 fillTimerPopUp();
456} 456}
457 457
458void SimpleAlarmDaemonImpl::confTimer( int time ) 458void SimpleAlarmDaemonImpl::confTimer( int time )
459{ 459{
460 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 460 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
461 int minutes = time; 461 int minutes = time;
462 if ( minutes == 0 ) { 462 if ( minutes == 0 ) {
463 if ( ! mTimerTime ) 463 if ( ! mTimerTime )
464 return; 464 return;
465 465
466 QDialog dia ( 0, ("Stop Timer" ), true ); 466 QDialog dia ( 0, ("Stop Timer" ), true );
467 QLabel lab (("Really stop the timer?"), &dia ); 467 QLabel lab (("Really stop the timer?"), &dia );
468 dia.setCaption(("KO/Pi Timer Stop" )); 468 dia.setCaption(("KO/Pi Timer Stop" ));
469 QVBoxLayout lay( &dia ); 469 QVBoxLayout lay( &dia );
470 lay.setMargin(5); 470 lay.setMargin(5);
471 lay.setSpacing(5); 471 lay.setSpacing(5);
472 lay.addWidget( &lab); 472 lay.addWidget( &lab);
473 dia.resize( 200, dia.sizeHint().height() ); 473 dia.resize( 200, dia.sizeHint().height() );
474 474
475 if ( !dia.exec() ) 475 if ( !dia.exec() )
476 return; 476 return;
477 477
478 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); 478 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() );
479 mTimerTime = 0; 479 mTimerTime = 0;
480 return; 480 return;
481 } 481 }
482 if ( mTimerTime ) 482 if ( mTimerTime )
483 return; 483 return;
484 if ( minutes == 1 ) { 484 if ( minutes == 1 ) {
485 return; 485 return;
486 } 486 }
487 QString mess = "timer_alarm"; 487 QString mess = "timer_alarm";
488 mess += ("Timer Alarm!\n"); 488 mess += ("Timer Alarm!\n");
489 if ( minutes == 22 ) 489 if ( minutes == 22 )
490 mess += ( "Pizza is ready"); 490 mess += ( "Pizza is ready");
491 else if ( minutes == 45 ) 491 else if ( minutes == 45 )
492 mess += ( "Please wake up!"); 492 mess += ( "Please wake up!");
493 else if ( minutes == 5 ) 493 else if ( minutes == 5 )
494 mess += ( "Tea is ready"); 494 mess += ( "Tea is ready");
495 else if ( minutes == 3 ) { 495 else if ( minutes == 3 ) {
496 mess += mCustomText; 496 mess += mCustomText;
497 minutes = mCustomMinutes ; 497 minutes = mCustomMinutes ;
498 } 498 }
499 else { 499 else {
500 if ( minutes == 2 ) { 500 if ( minutes == 2 ) {
501 // ask time 501 // ask time
502 QDialog dia ( 0, ("Customize Timer" ), true ); 502 QDialog dia ( 0, ("Customize Timer" ), true );
503 QLabel lab (("Message Text:"), &dia ); 503 QLabel lab (("Message Text:"), &dia );
504 dia.setCaption(("KO/Pi Timer" )); 504 dia.setCaption(("KO/Pi Timer" ));
505 QVBoxLayout lay( &dia ); 505 QVBoxLayout lay( &dia );
506 lay.setMargin(5); 506 lay.setMargin(5);
507 lay.setSpacing(5); 507 lay.setSpacing(5);
508 lay.addWidget( &lab); 508 lay.addWidget( &lab);
509 QLineEdit lEdit( mCustomText, &dia ); 509 QLineEdit lEdit( mCustomText, &dia );
510 lay.addWidget( &lEdit); 510 lay.addWidget( &lEdit);
511 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 511 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
512 lay.addWidget( &lab2); 512 lay.addWidget( &lab2);
513 QHBox hbox ( &dia ); 513 QHBox hbox ( &dia );
514 QLabel lab3 (("h:"), &hbox ); 514 QLabel lab3 (("h:"), &hbox );
515 QSpinBox spinh( 0, 24, 1,& hbox ); 515 QSpinBox spinh( 0, 24, 1,& hbox );
516 QLabel lab4 ((" min:"), &hbox ); 516 QLabel lab4 ((" min:"), &hbox );
517 QSpinBox spinm( 0, 59, 1,&hbox ); 517 QSpinBox spinm( 0, 59, 1,&hbox );
518 spinh.setValue( mCustomMinutes/60 ); 518 spinh.setValue( mCustomMinutes/60 );
519 spinm.setValue( mCustomMinutes%60 ); 519 spinm.setValue( mCustomMinutes%60 );
520 lay.addWidget( &hbox); 520 lay.addWidget( &hbox);
521 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 521 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
522 if ( !dia.exec() ) 522 if ( !dia.exec() )
523 return; 523 return;
524 mCustomText = lEdit.text(); 524 mCustomText = lEdit.text();
525 mCustomMinutes = spinh.value()*60+spinm.value(); 525 mCustomMinutes = spinh.value()*60+spinm.value();
526 if ( mCustomMinutes == 0 ) 526 if ( mCustomMinutes == 0 )
527 mCustomMinutes = 1; 527 mCustomMinutes = 1;
528 if ( mCustomMinutes > 1440 ) 528 if ( mCustomMinutes > 1440 )
529 mCustomMinutes = 1440; 529 mCustomMinutes = 1440;
530 mess += mCustomText; 530 mess += mCustomText;
531 minutes = mCustomMinutes; 531 minutes = mCustomMinutes;
532 } 532 }
533 else 533 else
534 mess+= QString::number ( minutes ) + ( " minutes are past!"); 534 mess+= QString::number ( minutes ) + ( " minutes are past!");
535 } 535 }
536 //minutes = 1; 536 //minutes = 1;
537 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 537 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
538 timerMesssage = mess; 538 timerMesssage = mess;
539 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 539 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
540 mTimerTime = 1; 540 mTimerTime = 1;
541} 541}
542 542
543void SimpleAlarmDaemonImpl::writeFile() 543void SimpleAlarmDaemonImpl::writeFile()
544{ 544{
545 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 545 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
546} 546}
547void SimpleAlarmDaemonImpl::showWN() 547void SimpleAlarmDaemonImpl::showWN()
548{ 548{
549 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 549 QCopEnvelope e("QPE/Application/kopi", "-showWN");
550} 550}
551void SimpleAlarmDaemonImpl::newTodo() 551void SimpleAlarmDaemonImpl::newTodo()
552{ 552{
553 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 553 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
554} 554}
555 555
556void SimpleAlarmDaemonImpl::newEvent() 556void SimpleAlarmDaemonImpl::newEvent()
557{ 557{
558 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 558 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
559 559
560} 560}
561void SimpleAlarmDaemonImpl::newMail() 561void SimpleAlarmDaemonImpl::newMail()
562{ 562{
563 QCopEnvelope e("QPE/Application/kmpi", "newMail()"); 563 QCopEnvelope e("QPE/Application/ompi", "newMail()");
564} 564}
565void SimpleAlarmDaemonImpl::showAdd() 565void SimpleAlarmDaemonImpl::showAdd()
566{ 566{
567 QCopEnvelope e("QPE/Application/kapi", " "); 567 QCopEnvelope e("QPE/Application/kapi", " ");
568} 568}
569void SimpleAlarmDaemonImpl::ringSync() 569void SimpleAlarmDaemonImpl::ringSync()
570{ 570{
571 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 571 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
572 572
573} 573}
574void SimpleAlarmDaemonImpl::newCountdown() 574void SimpleAlarmDaemonImpl::newCountdown()
575{ 575{
576 //recieve("cal_alarm", 10 ); 576 //recieve("cal_alarm", 10 );
577} 577}
578void SimpleAlarmDaemonImpl::simulate() 578void SimpleAlarmDaemonImpl::simulate()
579{ 579{
580 writeFile(); 580 writeFile();
581 QString filename = getenv("QPEDIR") ; 581 QString filename = getenv("QPEDIR") ;
582 filename += "/pics/kdepim/korganizer/koalarm.wav"; 582 filename += "/pics/kdepim/korganizer/koalarm.wav";
583 startAlarm("Alarm simulation", filename ); 583 startAlarm("Alarm simulation", filename );
584} 584}
585void SimpleAlarmDaemonImpl::showKO() 585void SimpleAlarmDaemonImpl::showKO()
586{ 586{
587 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 587 QCopEnvelope e("QPE/Application/kopi", "-showKO");
588 588
589} 589}
590void SimpleAlarmDaemonImpl::showTodo() 590void SimpleAlarmDaemonImpl::showTodo()
591{ 591{
592 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 592 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
593 593
594} 594}
595void SimpleAlarmDaemonImpl::writeJournal() 595void SimpleAlarmDaemonImpl::writeJournal()
596{ 596{
597 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 597 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
598 598
599} 599}
600 600
601void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 601void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
602{ 602{
603 603
604 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 604 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
605 605
606} 606}
607 607