summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
Unidiff
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
@@ -260,97 +260,99 @@ void SimpleAlarmDaemonImpl::slotPlayBeep( int 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()
@@ -573,98 +575,99 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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{