summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp16
-rw-r--r--kalarmd/simplealarmdaemonimpl.h1
2 files changed, 10 insertions, 7 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 2bc6643..471836b 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -4,110 +4,109 @@
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "simplealarmdaemonimpl.h" 24#include "simplealarmdaemonimpl.h"
25 25
26#include "alarmdialog.h" 26#include "alarmdialog.h"
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qapp.h> 28#include <qapp.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qhbox.h> 31#include <qhbox.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qdialog.h> 36#include <qdialog.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qtextstream.h> 38#include <qtextstream.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#include <qtopia/alarmserver.h> 40#include <qtopia/alarmserver.h>
41 41
42#include <stdlib.h> 42#include <stdlib.h>
43#include <stdio.h> 43#include <stdio.h>
44#include <unistd.h> 44#include <unistd.h>
45 45
46 46
47SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 47SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
48 : QLabel( parent ) 48 : QLabel( parent )
49{ 49{
50 mAlarmDialog = new AlarmDialog( 0 ); 50 mAlarmDialog = new AlarmDialog( 0 );
51 mPopUp = new QPopupMenu( 0 ); 51 mPopUp = new QPopupMenu( 0 );
52 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
53 mPopUp->insertSeparator();
54 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
55 mPopUp->insertSeparator();
56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); 52 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
53 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
57 mPopUp->insertSeparator(); 54 mPopUp->insertSeparator();
58 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); 55 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) );
59 mPopUp->insertSeparator(); 56 mPopUp->insertSeparator();
60 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); 57 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
61 mPopUp->insertSeparator(); 58 mPopUp->insertSeparator();
62 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); 59 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
63 mPopUp->insertSeparator();
64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); 60 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); 61 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
62 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) );
63 mPopUp->insertSeparator();
64 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
66 mTimerPopUp = new QPopupMenu( mPopUp ); 65 mTimerPopUp = new QPopupMenu( mPopUp );
67 66
68 mBeepPopUp = new QPopupMenu( mPopUp ); 67 mBeepPopUp = new QPopupMenu( mPopUp );
69 mSoundPopUp = new QPopupMenu( mBeepPopUp ); 68 mSoundPopUp = new QPopupMenu( mBeepPopUp );
70 mPausePopUp = new QPopupMenu( mBeepPopUp ); 69 mPausePopUp = new QPopupMenu( mBeepPopUp );
71 QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp ); 70 QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp );
72 savePopUp->insertItem( "Save", 0 ); 71 savePopUp->insertItem( "Save", 0 );
73 savePopUp->insertItem( "Load", 1 ); 72 savePopUp->insertItem( "Load", 1 );
74 mSoundPopUp->insertItem( "Buzzer", 0 ); 73 mSoundPopUp->insertItem( "Buzzer", 0 );
75 mSoundPopUp->insertItem( "Wav file", 1 ); 74 mSoundPopUp->insertItem( "Wav file", 1 );
76 mPausePopUp->insertItem( " 1 sec", 1 ); 75 mPausePopUp->insertItem( " 1 sec", 1 );
77 mPausePopUp->insertItem( " 2 sec", 2 ); 76 mPausePopUp->insertItem( " 2 sec", 2 );
78 mPausePopUp->insertItem( " 3 sec", 3 ); 77 mPausePopUp->insertItem( " 3 sec", 3 );
79 mPausePopUp->insertItem( " 5 sec", 5 ); 78 mPausePopUp->insertItem( " 5 sec", 5 );
80 mPausePopUp->insertItem( "10 sec", 10 ); 79 mPausePopUp->insertItem( "10 sec", 10 );
81 mPausePopUp->insertItem( "30 sec", 30 ); 80 mPausePopUp->insertItem( "30 sec", 30 );
82 mPausePopUp->insertItem( " 1 min", 60 ); 81 mPausePopUp->insertItem( " 1 min", 60 );
83 mPausePopUp->insertItem( " 5 min", 300 ); 82 mPausePopUp->insertItem( " 5 min", 300 );
84 mPausePopUp->insertItem( "10 min", 600 ); 83 mPausePopUp->insertItem( "10 min", 600 );
85 mSuspendPopUp = new QPopupMenu( mBeepPopUp ); 84 mSuspendPopUp = new QPopupMenu( mBeepPopUp );
86 mSuspendPopUp->insertItem( "Off", 0 ); 85 mSuspendPopUp->insertItem( "Off", 0 );
87 mSuspendPopUp->insertItem( " 1x", 1 ); 86 mSuspendPopUp->insertItem( " 1x", 1 );
88 mSuspendPopUp->insertItem( " 2x", 2 ); 87 mSuspendPopUp->insertItem( " 2x", 2 );
89 mSuspendPopUp->insertItem( " 3x", 3 ); 88 mSuspendPopUp->insertItem( " 3x", 3 );
90 mSuspendPopUp->insertItem( " 5x", 5 ); 89 mSuspendPopUp->insertItem( " 5x", 5 );
91 mSuspendPopUp->insertItem( "10x", 10 ); 90 mSuspendPopUp->insertItem( "10x", 10 );
92 mSuspendPopUp->insertItem( "20x", 20 ); 91 mSuspendPopUp->insertItem( "20x", 20 );
93 mSuspendPopUp->insertItem( "30x", 30 ); 92 mSuspendPopUp->insertItem( "30x", 30 );
94 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 93 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
95 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 94 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
96 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 95 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
97 mBeepPopUp->insertItem( "Config",savePopUp ); 96 mBeepPopUp->insertItem( "Config",savePopUp );
98 mBeepPopUp->insertItem( "300", 300 ); 97 mBeepPopUp->insertItem( "300", 300 );
99 mBeepPopUp->insertItem( "180", 180 ); 98 mBeepPopUp->insertItem( "180", 180 );
100 mBeepPopUp->insertItem( "60", 60 ); 99 mBeepPopUp->insertItem( "60", 60 );
101 mBeepPopUp->insertItem( "30", 30 ); 100 mBeepPopUp->insertItem( "30", 30 );
102 mBeepPopUp->insertItem( "10", 10 ); 101 mBeepPopUp->insertItem( "10", 10 );
103 mBeepPopUp->insertItem( "3", 3 ); 102 mBeepPopUp->insertItem( "3", 3 );
104 mBeepPopUp->insertItem( "1", 1 ); 103 mBeepPopUp->insertItem( "1", 1 );
105 mBeepPopUp->insertItem( "Off", 0 ); 104 mBeepPopUp->insertItem( "Off", 0 );
106 mBeepPopUp->setCheckable( true ); 105 mBeepPopUp->setCheckable( true );
107 mPopUp->insertSeparator(); 106 mPopUp->insertSeparator();
108 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 107 mPopUp->insertItem( "Play beeps", mBeepPopUp );
109 mPopUp->insertSeparator(); 108 mPopUp->insertSeparator();
110 mPopUp->insertItem( "Timer", mTimerPopUp ); 109 mPopUp->insertItem( "Timer", mTimerPopUp );
111 mPopUp->insertSeparator(); 110 mPopUp->insertSeparator();
112 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 111 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
113 112
@@ -461,92 +460,95 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
461 QHBox hbox ( &dia ); 460 QHBox hbox ( &dia );
462 QLabel lab3 (("h:"), &hbox ); 461 QLabel lab3 (("h:"), &hbox );
463 QSpinBox spinh( 0, 24, 1,& hbox ); 462 QSpinBox spinh( 0, 24, 1,& hbox );
464 QLabel lab4 ((" min:"), &hbox ); 463 QLabel lab4 ((" min:"), &hbox );
465 QSpinBox spinm( 0, 59, 1,&hbox ); 464 QSpinBox spinm( 0, 59, 1,&hbox );
466 spinh.setValue( mCustomMinutes/60 ); 465 spinh.setValue( mCustomMinutes/60 );
467 spinm.setValue( mCustomMinutes%60 ); 466 spinm.setValue( mCustomMinutes%60 );
468 lay.addWidget( &hbox); 467 lay.addWidget( &hbox);
469 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 468 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
470 if ( !dia.exec() ) 469 if ( !dia.exec() )
471 return; 470 return;
472 mCustomText = lEdit.text(); 471 mCustomText = lEdit.text();
473 mCustomMinutes = spinh.value()*60+spinm.value(); 472 mCustomMinutes = spinh.value()*60+spinm.value();
474 if ( mCustomMinutes == 0 ) 473 if ( mCustomMinutes == 0 )
475 mCustomMinutes = 1; 474 mCustomMinutes = 1;
476 if ( mCustomMinutes > 1440 ) 475 if ( mCustomMinutes > 1440 )
477 mCustomMinutes = 1440; 476 mCustomMinutes = 1440;
478 mess += mCustomText; 477 mess += mCustomText;
479 minutes = mCustomMinutes; 478 minutes = mCustomMinutes;
480 } 479 }
481 else 480 else
482 mess+= QString::number ( minutes ) + ( " minutes are past!"); 481 mess+= QString::number ( minutes ) + ( " minutes are past!");
483 } 482 }
484 //minutes = 1; 483 //minutes = 1;
485 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 484 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
486 timerMesssage = mess; 485 timerMesssage = mess;
487 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 486 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
488 mTimerTime = 1; 487 mTimerTime = 1;
489} 488}
490 489
491void SimpleAlarmDaemonImpl::writeFile() 490void SimpleAlarmDaemonImpl::writeFile()
492{ 491{
493 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 492 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
494} 493}
495void SimpleAlarmDaemonImpl::showWN() 494void SimpleAlarmDaemonImpl::showWN()
496{ 495{
497 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 496 QCopEnvelope e("QPE/Application/kopi", "-showWN");
498} 497}
499void SimpleAlarmDaemonImpl::newTodo() 498void SimpleAlarmDaemonImpl::newTodo()
500{ 499{
501 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 500 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
502} 501}
503 502
504void SimpleAlarmDaemonImpl::newEvent() 503void SimpleAlarmDaemonImpl::newEvent()
505{ 504{
506 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 505 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
507 506
508} 507}
509 508void SimpleAlarmDaemonImpl::newMail()
509{
510 QCopEnvelope e("QPE/Application/kmpi", "newMail()");
511}
510void SimpleAlarmDaemonImpl::showAdd() 512void SimpleAlarmDaemonImpl::showAdd()
511{ 513{
512 QCopEnvelope e("QPE/Application/kapi", " "); 514 QCopEnvelope e("QPE/Application/kapi", " ");
513} 515}
514void SimpleAlarmDaemonImpl::ringSync() 516void SimpleAlarmDaemonImpl::ringSync()
515{ 517{
516 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 518 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
517 519
518} 520}
519void SimpleAlarmDaemonImpl::newCountdown() 521void SimpleAlarmDaemonImpl::newCountdown()
520{ 522{
521 //recieve("cal_alarm", 10 ); 523 //recieve("cal_alarm", 10 );
522} 524}
523void SimpleAlarmDaemonImpl::simulate() 525void SimpleAlarmDaemonImpl::simulate()
524{ 526{
525 writeFile(); 527 writeFile();
526 QString filename = getenv("QPEDIR") ; 528 QString filename = getenv("QPEDIR") ;
527 filename += "/pics/kdepim/korganizer/koalarm.wav"; 529 filename += "/pics/kdepim/korganizer/koalarm.wav";
528 startAlarm("Alarm simulation", filename ); 530 startAlarm("Alarm simulation", filename );
529} 531}
530void SimpleAlarmDaemonImpl::showKO() 532void SimpleAlarmDaemonImpl::showKO()
531{ 533{
532 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 534 QCopEnvelope e("QPE/Application/kopi", "-showKO");
533 535
534} 536}
535void SimpleAlarmDaemonImpl::showTodo() 537void SimpleAlarmDaemonImpl::showTodo()
536{ 538{
537 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 539 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
538 540
539} 541}
540void SimpleAlarmDaemonImpl::writeJournal() 542void SimpleAlarmDaemonImpl::writeJournal()
541{ 543{
542 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 544 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
543 545
544} 546}
545 547
546void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 548void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
547{ 549{
548 550
549 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 551 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
550 552
551} 553}
552 554
diff --git a/kalarmd/simplealarmdaemonimpl.h b/kalarmd/simplealarmdaemonimpl.h
index 1c16af8..32a3867 100644
--- a/kalarmd/simplealarmdaemonimpl.h
+++ b/kalarmd/simplealarmdaemonimpl.h
@@ -3,83 +3,84 @@
3 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef SIMPLEALARMDAEMONIMPL_H 23#ifndef SIMPLEALARMDAEMONIMPL_H
24#define SIMPLEALARMDAEMONIMPL_H 24#define SIMPLEALARMDAEMONIMPL_H
25 25
26//#include "simplealarmdaemon.h" 26//#include "simplealarmdaemon.h"
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlabel.h> 28#include <qlabel.h>
29 29
30class QLabel; 30class QLabel;
31class QTimer; 31class QTimer;
32class QPopupMenu; 32class QPopupMenu;
33class AlarmDialog; 33class AlarmDialog;
34class SimpleAlarmDaemonImpl : public QLabel 34class SimpleAlarmDaemonImpl : public QLabel
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 SimpleAlarmDaemonImpl( QWidget *parent = 0 ); 38 SimpleAlarmDaemonImpl( QWidget *parent = 0 );
39 39
40 ~SimpleAlarmDaemonImpl(); 40 ~SimpleAlarmDaemonImpl();
41 41
42 protected slots: 42 protected slots:
43 void recieve( const QCString& msg, const QByteArray& data ); 43 void recieve( const QCString& msg, const QByteArray& data );
44 void newTodo(); 44 void newTodo();
45 void newEvent(); 45 void newEvent();
46 void newCountdown(); 46 void newCountdown();
47 void simulate(); 47 void simulate();
48 void showKO(); 48 void showKO();
49 void showWN(); 49 void showWN();
50 void showAdd(); 50 void showAdd();
51 void newMail();
51 void ringSync(); 52 void ringSync();
52 void showTodo(); 53 void showTodo();
53 void writeFile(); 54 void writeFile();
54 void writeJournal(); 55 void writeJournal();
55 void slotPlayBeep( int ); 56 void slotPlayBeep( int );
56 void showTimer( ); 57 void showTimer( );
57 void confPause( int ); 58 void confPause( int );
58 void confTimer( int ); 59 void confTimer( int );
59 void saveSlot( int ); 60 void saveSlot( int );
60 void confSuspend( int ); 61 void confSuspend( int );
61 void confSound( int num ); 62 void confSound( int num );
62 void startAlarm(QString mess, QString fn ); 63 void startAlarm(QString mess, QString fn );
63 64
64 protected: 65 protected:
65 void mousePressEvent( QMouseEvent * ); 66 void mousePressEvent( QMouseEvent * );
66 67
67 private: 68 private:
68 AlarmDialog *mAlarmDialog; 69 AlarmDialog *mAlarmDialog;
69 int mPlayBeeps; 70 int mPlayBeeps;
70 int mPausePlay; 71 int mPausePlay;
71 int mSuspend; 72 int mSuspend;
72 QString mAlarmMessage; 73 QString mAlarmMessage;
73 int mTimerTime; 74 int mTimerTime;
74 int getFileNameLen( QString ); 75 int getFileNameLen( QString );
75 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp; 76 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp;
76 QDateTime mRunningTimer; 77 QDateTime mRunningTimer;
77 void fillTimerPopUp(); 78 void fillTimerPopUp();
78 QString timerMesssage; 79 QString timerMesssage;
79 QString mCustomText; 80 QString mCustomText;
80 int mCustomMinutes; 81 int mCustomMinutes;
81 int mTimerPopupConf; 82 int mTimerPopupConf;
82 bool wavAlarm; 83 bool wavAlarm;
83}; 84};
84 85
85#endif 86#endif