summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
authorzautrix <zautrix>2005-04-08 23:40:38 (UTC)
committer zautrix <zautrix>2005-04-08 23:40:38 (UTC)
commita74c23d91e80343cd1ccfd1fe712958fad1d5891 (patch) (unidiff)
tree2dc90dffe822e1425ace17cdbf9e420fa0be6ac7 /kalarmd/simplealarmdaemonimpl.cpp
parentc4bab697d650c249cdff45b753b9e6df2a817877 (diff)
downloadkdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.zip
kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.tar.gz
kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.tar.bz2
ad fix
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 294ce7d..2a463b3 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -244,129 +244,131 @@ void SimpleAlarmDaemonImpl::confPause( int num )
244void SimpleAlarmDaemonImpl::confSound( int num ) 244void SimpleAlarmDaemonImpl::confSound( int num )
245{ 245{
246 if ( num == 0 ) { 246 if ( num == 0 ) {
247 wavAlarm = false; 247 wavAlarm = false;
248 mSoundPopUp->setItemChecked ( 0, true ); 248 mSoundPopUp->setItemChecked ( 0, true );
249 mSoundPopUp->setItemChecked ( 1, false ); 249 mSoundPopUp->setItemChecked ( 1, false );
250 } else { 250 } else {
251 wavAlarm = true; 251 wavAlarm = true;
252 mSoundPopUp->setItemChecked ( 0, false ); 252 mSoundPopUp->setItemChecked ( 0, false );
253 mSoundPopUp->setItemChecked ( 1, true ); 253 mSoundPopUp->setItemChecked ( 1, true );
254 } 254 }
255} 255}
256void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 256void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
257{ 257{
258 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 258 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
259 mPlayBeeps = num; 259 mPlayBeeps = num;
260 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 260 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
261} 261}
262 262
263void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 263void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
264{ 264{
265 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 265 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
266 QString mess = msg; 266 QString mess = msg;
267 mAlarmMessage = mess.mid( 9 ); 267 mAlarmMessage = mess.mid( 9 );
268 QString filename = getenv("QPEDIR") ; 268 QString filename = getenv("QPEDIR") ;
269 filename += "/pics/kdepim/korganizer/koalarm.wav"; 269 filename += "/pics/kdepim/korganizer/koalarm.wav";
270 QString tempfilename; 270 QString tempfilename;
271 if ( mess.left( 13 ) == "suspend_alarm") { 271 if ( mess.left( 13 ) == "suspend_alarm") {
272 bool error = false; 272 bool error = false;
273 int len = mess.mid( 13 ).find("+++"); 273 int len = mess.mid( 13 ).find("+++");
274 if ( len < 2 ) 274 if ( len < 2 )
275 error = true; 275 error = true;
276 else { 276 else {
277 tempfilename = mess.mid( 13, len ); 277 tempfilename = mess.mid( 13, len );
278 if ( !QFile::exists( tempfilename ) ) 278 if ( !QFile::exists( tempfilename ) )
279 error = true; 279 error = true;
280 } 280 }
281 if ( ! error ) { 281 if ( ! error ) {
282 filename = tempfilename; 282 filename = tempfilename;
283 } 283 }
284 mAlarmMessage = mess.mid( 13+len+3 ); 284 mAlarmMessage = mess.mid( 13+len+3 );
285 //qDebug("suspend file %s ",tempfilename.latin1() ); 285 //qDebug("suspend file %s ",tempfilename.latin1() );
286 startAlarm( mAlarmMessage, filename); 286 startAlarm( mAlarmMessage, filename);
287 return; 287 return;
288 } 288 }
289 if ( mess.left( 11 ) == "timer_alarm") { 289 if ( mess.left( 11 ) == "timer_alarm") {
290 mTimerTime = 0; 290 mTimerTime = 0;
291 startAlarm( mess.mid( 11 ), filename ); 291 startAlarm( mess.mid( 11 ), filename );
292 return; 292 return;
293 } 293 }
294 if ( mess.left( 10 ) == "proc_alarm") { 294 if ( mess.left( 10 ) == "proc_alarm") {
295 bool error = false; 295 bool error = false;
296 int len = mess.mid( 10 ).find("+++"); 296 int len = mess.mid( 10 ).find("+++");
297 if ( len < 2 ) 297 if ( len < 2 )
298 error = true; 298 error = true;
299 else { 299 else {
300 tempfilename = mess.mid( 10, len ); 300 tempfilename = mess.mid( 10, len );
301 if ( !QFile::exists( tempfilename ) ) 301 if ( !QFile::exists( tempfilename ) )
302 error = true; 302 error = true;
303 } 303 }
304 if ( error ) { 304 if ( error ) {
305 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 305 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
306 mAlarmMessage += mess.mid( 10+len+3+9 ); 306 mAlarmMessage += mess.mid( 10+len+3+9 );
307 } else { 307 } else {
308 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 308 {
309 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
310 }
309 //qDebug("-----system command %s ",tempfilename.latin1() ); 311 //qDebug("-----system command %s ",tempfilename.latin1() );
310 if ( vfork () == 0 ) { 312 if ( vfork () == 0 ) {
311 execl ( tempfilename.latin1(), 0 ); 313 execl ( tempfilename.latin1(), 0 );
312 return; 314 return;
313 } 315 }
314 return; 316 return;
315 } 317 }
316 318
317 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 319 //qDebug("+++++++system command %s ",tempfilename.latin1() );
318 } 320 }
319 if ( mess.left( 11 ) == "audio_alarm") { 321 if ( mess.left( 11 ) == "audio_alarm") {
320 bool error = false; 322 bool error = false;
321 int len = mess.mid( 11 ).find("+++"); 323 int len = mess.mid( 11 ).find("+++");
322 if ( len < 2 ) 324 if ( len < 2 )
323 error = true; 325 error = true;
324 else { 326 else {
325 tempfilename = mess.mid( 11, len ); 327 tempfilename = mess.mid( 11, len );
326 if ( !QFile::exists( tempfilename ) ) 328 if ( !QFile::exists( tempfilename ) )
327 error = true; 329 error = true;
328 } 330 }
329 if ( ! error ) { 331 if ( ! error ) {
330 filename = tempfilename; 332 filename = tempfilename;
331 } 333 }
332 mAlarmMessage = mess.mid( 11+len+3+9 ); 334 mAlarmMessage = mess.mid( 11+len+3+9 );
333 //qDebug("audio file command %s ",tempfilename.latin1() ); 335 //qDebug("audio file command %s ",tempfilename.latin1() );
334 } 336 }
335 if ( mess.left( 9 ) == "cal_alarm") { 337 if ( mess.left( 9 ) == "cal_alarm") {
336 mAlarmMessage = mess.mid( 9 ) ; 338 mAlarmMessage = mess.mid( 9 ) ;
337 } 339 }
338 340
339 writeFile(); 341 writeFile();
340 startAlarm( mAlarmMessage, filename ); 342 startAlarm( mAlarmMessage, filename );
341 343
342} 344}
343 345
344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 346int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
345{ 347{
346 return 0; 348 return 0;
347} 349}
348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 350void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
349{ 351{
350 //mAlarmDialog->show(); 352 //mAlarmDialog->show();
351 //mAlarmDialog->raise(); 353 //mAlarmDialog->raise();
352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 354 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
353} 355}
354 356
355 357
356void SimpleAlarmDaemonImpl::fillTimerPopUp() 358void SimpleAlarmDaemonImpl::fillTimerPopUp()
357{ 359{
358 360
359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 361 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
360 if ( mTimerPopupConf == mTimerTime ) { 362 if ( mTimerPopupConf == mTimerTime ) {
361 if ( mTimerTime ) { 363 if ( mTimerTime ) {
362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 364 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
363 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 365 QTime t ( secs/3600, (secs/60)%60, secs%60 );
364 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 366 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
365 } 367 }
366 else { 368 else {
367 QString text = mCustomText.stripWhiteSpace (); 369 QString text = mCustomText.stripWhiteSpace ();
368 int in = text.find( " " ); 370 int in = text.find( " " );
369 text = text.left ( in ); 371 text = text.left ( in );
370 mTimerPopUp->changeItem ( 3, text ); 372 mTimerPopUp->changeItem ( 3, text );
371 } 373 }
372 return; 374 return;
@@ -557,130 +559,131 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
557 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 559 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
558 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 560 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
559 spinh.setFixedSize( 100,62 ); 561 spinh.setFixedSize( 100,62 );
560 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 562 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
561 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 563 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
562 spinm.downButton ()->setGeometry( 50,50,50,50); 564 spinm.downButton ()->setGeometry( 50,50,50,50);
563 // spinm.setSuffix( " m" ); 565 // spinm.setSuffix( " m" );
564 //spinh.setSuffix( " h" ); 566 //spinh.setSuffix( " h" );
565 spinm.setWrapping ( true ); 567 spinm.setWrapping ( true );
566 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 568 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
567 spinm.setLineStep( 1 ); 569 spinm.setLineStep( 1 );
568 spinm.setFixedSize( 110,62 ); 570 spinm.setFixedSize( 110,62 );
569 lay.addWidget( &hbox); 571 lay.addWidget( &hbox);
570 QLabel lab5 ("Timer fires at:", &dia ); 572 QLabel lab5 ("Timer fires at:", &dia );
571 lab5.setAlignment( AlignCenter ); 573 lab5.setAlignment( AlignCenter );
572 lay.addWidget( &lab5); 574 lay.addWidget( &lab5);
573 KODateLabel dl ( &dia ); 575 KODateLabel dl ( &dia );
574 dl.setAlignment( AlignCenter ); 576 dl.setAlignment( AlignCenter );
575 dl.setFont( fo ); 577 dl.setFont( fo );
576 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 578 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
577 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 579 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
578 lay.addWidget( &dl); 580 lay.addWidget( &dl);
579 spinh.setValue( mCustomMinutes/60 ); 581 spinh.setValue( mCustomMinutes/60 );
580 spinm.setValue( mCustomMinutes%60 ); 582 spinm.setValue( mCustomMinutes%60 );
581 QPushButton ok ( "Start timer", &dia); 583 QPushButton ok ( "Start timer", &dia);
582 ok.setDefault( true ); 584 ok.setDefault( true );
583 ok.setFont( fo ); 585 ok.setFont( fo );
584 spinh.setFocus(); 586 spinh.setFocus();
585 lay.addWidget( &ok); 587 lay.addWidget( &ok);
586 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 588 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
587 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 589 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
588 590
589 if ( !dia.exec() ) 591 if ( !dia.exec() )
590 return; 592 return;
591 mCustomText = lEdit.text(); 593 mCustomText = lEdit.text();
592 mCustomMinutes = spinh.value()*60+spinm.value(); 594 mCustomMinutes = spinh.value()*60+spinm.value();
593 if ( mCustomMinutes == 0 ) 595 if ( mCustomMinutes == 0 )
594 mCustomMinutes = 1; 596 mCustomMinutes = 1;
595 if ( mCustomMinutes > 1440 ) 597 if ( mCustomMinutes > 1440 )
596 mCustomMinutes = 1440; 598 mCustomMinutes = 1440;
597 mess += mCustomText; 599 mess += mCustomText;
598 minutes = mCustomMinutes; 600 minutes = mCustomMinutes;
599 mRunningTimerText = mCustomText.stripWhiteSpace (); 601 mRunningTimerText = mCustomText.stripWhiteSpace ();
600 int in = mRunningTimerText.find( " " ); 602 int in = mRunningTimerText.find( " " );
601 mRunningTimerText = mRunningTimerText.left ( in ); 603 mRunningTimerText = mRunningTimerText.left ( in );
602 } 604 }
603 else { 605 else {
604 mess+= QString::number ( minutes ) + ( " minutes are past!"); 606 mess+= QString::number ( minutes ) + ( " minutes are past!");
605 int min = minutes; 607 int min = minutes;
606 if ( min % 60 == 0 ) 608 if ( min % 60 == 0 )
607 mRunningTimerText = QString::number ( min/60 ) + ( " hours"); 609 mRunningTimerText = QString::number ( min/60 ) + ( " hours");
608 else 610 else
609 mRunningTimerText = QString::number ( minutes ) + ( " minutes"); 611 mRunningTimerText = QString::number ( minutes ) + ( " minutes");
610 } 612 }
611 } 613 }
612 //minutes = 1; 614 //minutes = 1;
613 615
614 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 616 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
615 timerMesssage = mess; 617 timerMesssage = mess;
616 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 618 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
617 mTimerTime = 1; 619 mTimerTime = 1;
618} 620}
619 621
620void SimpleAlarmDaemonImpl::writeFile() 622void SimpleAlarmDaemonImpl::writeFile()
621{ 623{
622 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 624 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
625 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
623} 626}
624void SimpleAlarmDaemonImpl::showWN() 627void SimpleAlarmDaemonImpl::showWN()
625{ 628{
626 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 629 QCopEnvelope e("QPE/Application/kopi", "-showWN");
627} 630}
628void SimpleAlarmDaemonImpl::newTodo() 631void SimpleAlarmDaemonImpl::newTodo()
629{ 632{
630 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 633 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
631} 634}
632 635
633void SimpleAlarmDaemonImpl::newEvent() 636void SimpleAlarmDaemonImpl::newEvent()
634{ 637{
635 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 638 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
636 639
637} 640}
638void SimpleAlarmDaemonImpl::newMail() 641void SimpleAlarmDaemonImpl::newMail()
639{ 642{
640 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 643 QCopEnvelope e("QPE/Application/ompi", "newMail()");
641} 644}
642void SimpleAlarmDaemonImpl::showAdd() 645void SimpleAlarmDaemonImpl::showAdd()
643{ 646{
644 QCopEnvelope e("QPE/Application/kapi", "raise()"); 647 QCopEnvelope e("QPE/Application/kapi", "raise()");
645} 648}
646void SimpleAlarmDaemonImpl::ringSync() 649void SimpleAlarmDaemonImpl::ringSync()
647{ 650{
648 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 651 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
649 652
650} 653}
651void SimpleAlarmDaemonImpl::newCountdown() 654void SimpleAlarmDaemonImpl::newCountdown()
652{ 655{
653 //recieve("cal_alarm", 10 ); 656 //recieve("cal_alarm", 10 );
654} 657}
655void SimpleAlarmDaemonImpl::simulate() 658void SimpleAlarmDaemonImpl::simulate()
656{ 659{
657 writeFile(); 660 writeFile();
658 QString filename = getenv("QPEDIR") ; 661 QString filename = getenv("QPEDIR") ;
659 filename += "/pics/kdepim/korganizer/koalarm.wav"; 662 filename += "/pics/kdepim/korganizer/koalarm.wav";
660 startAlarm("Alarm simulation", filename ); 663 startAlarm("Alarm simulation", filename );
661} 664}
662void SimpleAlarmDaemonImpl::showKO() 665void SimpleAlarmDaemonImpl::showKO()
663{ 666{
664 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 667 QCopEnvelope e("QPE/Application/kopi", "-showKO");
665 // testing only 668 // testing only
666 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 669 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
667 670
668} 671}
669void SimpleAlarmDaemonImpl::showTodo() 672void SimpleAlarmDaemonImpl::showTodo()
670{ 673{
671 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 674 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
672 675
673} 676}
674void SimpleAlarmDaemonImpl::writeJournal() 677void SimpleAlarmDaemonImpl::writeJournal()
675{ 678{
676 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 679 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
677 680
678} 681}
679 682
680void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 683void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
681{ 684{
682 685
683 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 686 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
684 687
685} 688}
686 689