summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp23
-rw-r--r--kalarmd/simplealarmdaemonimpl.h1
2 files changed, 23 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 8ea8a73..04b8b21 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,679 +1,700 @@
1/* 1/*
2 This file is part of the KOrganizer alarm daemon. 2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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 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 <qdatetime.h> 34#include <qdatetime.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qdialog.h> 38#include <qdialog.h>
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
51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 51SimpleAlarmDaemonImpl::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 int points = (fon.pointSize()*4)/3; 71 int points = (fon.pointSize()*4)/3;
72 fon.setPointSize( points ); 72 fon.setPointSize( points );
73 mTimerPopUp->setFont( fon ); 73 mTimerPopUp->setFont( fon );
74 mPopUp->setFont( fon ); 74 mPopUp->setFont( fon );
75 mBeepPopUp = new QPopupMenu( this ); 75 mBeepPopUp = new QPopupMenu( this );
76 mSoundPopUp = new QPopupMenu( this ); 76 mSoundPopUp = new QPopupMenu( this );
77 mPausePopUp = new QPopupMenu( this ); 77 mPausePopUp = new QPopupMenu( this );
78 QPopupMenu* savePopUp = new QPopupMenu( this ); 78 QPopupMenu* savePopUp = new QPopupMenu( this );
79 savePopUp->insertItem( "Save", 0 ); 79 savePopUp->insertItem( "Save", 0 );
80 savePopUp->insertItem( "Load", 1 ); 80 savePopUp->insertItem( "Load", 1 );
81 mSoundPopUp->insertItem( "Buzzer", 0 ); 81 mSoundPopUp->insertItem( "Buzzer", 0 );
82 mSoundPopUp->insertItem( "Wav file", 1 ); 82 mSoundPopUp->insertItem( "Wav file", 1 );
83 mPausePopUp->insertItem( " 1 sec", 1 ); 83 mPausePopUp->insertItem( " 1 sec", 1 );
84 mPausePopUp->insertItem( " 2 sec", 2 ); 84 mPausePopUp->insertItem( " 2 sec", 2 );
85 mPausePopUp->insertItem( " 3 sec", 3 ); 85 mPausePopUp->insertItem( " 3 sec", 3 );
86 mPausePopUp->insertItem( " 5 sec", 5 ); 86 mPausePopUp->insertItem( " 5 sec", 5 );
87 mPausePopUp->insertItem( "10 sec", 10 ); 87 mPausePopUp->insertItem( "10 sec", 10 );
88 mPausePopUp->insertItem( "30 sec", 30 ); 88 mPausePopUp->insertItem( "30 sec", 30 );
89 mPausePopUp->insertItem( " 1 min", 60 ); 89 mPausePopUp->insertItem( " 1 min", 60 );
90 mPausePopUp->insertItem( " 5 min", 300 ); 90 mPausePopUp->insertItem( " 5 min", 300 );
91 mPausePopUp->insertItem( "10 min", 600 ); 91 mPausePopUp->insertItem( "10 min", 600 );
92 mSuspendPopUp = new QPopupMenu( this ); 92 mSuspendPopUp = new QPopupMenu( this );
93 mSuspendPopUp->insertItem( "Off", 0 ); 93 mSuspendPopUp->insertItem( "Off", 0 );
94 mSuspendPopUp->insertItem( " 1x", 1 ); 94 mSuspendPopUp->insertItem( " 1x", 1 );
95 mSuspendPopUp->insertItem( " 2x", 2 ); 95 mSuspendPopUp->insertItem( " 2x", 2 );
96 mSuspendPopUp->insertItem( " 3x", 3 ); 96 mSuspendPopUp->insertItem( " 3x", 3 );
97 mSuspendPopUp->insertItem( " 5x", 5 ); 97 mSuspendPopUp->insertItem( " 5x", 5 );
98 mSuspendPopUp->insertItem( "10x", 10 ); 98 mSuspendPopUp->insertItem( "10x", 10 );
99 mSuspendPopUp->insertItem( "20x", 20 ); 99 mSuspendPopUp->insertItem( "20x", 20 );
100 mSuspendPopUp->insertItem( "30x", 30 ); 100 mSuspendPopUp->insertItem( "30x", 30 );
101 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 101 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
102 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 102 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
103 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 103 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
104 mBeepPopUp->insertItem( "Config",savePopUp ); 104 mBeepPopUp->insertItem( "Config",savePopUp );
105 mBeepPopUp->insertItem( "300", 300 ); 105 mBeepPopUp->insertItem( "300", 300 );
106 mBeepPopUp->insertItem( "180", 180 ); 106 mBeepPopUp->insertItem( "180", 180 );
107 mBeepPopUp->insertItem( "60", 60 ); 107 mBeepPopUp->insertItem( "60", 60 );
108 mBeepPopUp->insertItem( "30", 30 ); 108 mBeepPopUp->insertItem( "30", 30 );
109 mBeepPopUp->insertItem( "10", 10 ); 109 mBeepPopUp->insertItem( "10", 10 );
110 mBeepPopUp->insertItem( "3", 3 ); 110 mBeepPopUp->insertItem( "3", 3 );
111 mBeepPopUp->insertItem( "1", 1 ); 111 mBeepPopUp->insertItem( "1", 1 );
112 mBeepPopUp->insertItem( "Off", 0 ); 112 mBeepPopUp->insertItem( "Off", 0 );
113 mBeepPopUp->insertSeparator(); 113 mBeepPopUp->insertSeparator();
114 mBeepPopUp->insertItem( "Simulate", 1000 ); 114 mBeepPopUp->insertItem( "Simulate", 1000 );
115 mBeepPopUp->setCheckable( true ); 115 mBeepPopUp->setCheckable( true );
116 mPopUp->insertSeparator(); 116 mPopUp->insertSeparator();
117 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 117 mPopUp->insertItem( "Play beeps", mBeepPopUp );
118 mPopUp->insertSeparator(); 118 mPopUp->insertSeparator();
119 mPopUp->insertItem( "Timer", mTimerPopUp ); 119 mPopUp->insertItem( "Timer", mTimerPopUp );
120 //mPopUp->insertSeparator(); 120 //mPopUp->insertSeparator();
121 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 121 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
122 122
123 mPopUp->resize( mPopUp->sizeHint() ); 123 mPopUp->resize( mPopUp->sizeHint() );
124 mPlayBeeps = 60; 124 mPlayBeeps = 60;
125 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 125 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
126 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 126 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
127 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 127 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
128 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 128 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
129 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 129 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
130 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 130 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
131 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 131 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
132 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 132 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
133 mTimerTime = 0; 133 mTimerTime = 0;
134 mCustomText = "Custom Text"; 134 mCustomText = "Custom Text";
135 mCustomMinutes = 7; 135 mCustomMinutes = 7;
136 mTimerPopupConf = 1; 136 mTimerPopupConf = 1;
137 fillTimerPopUp(); 137 fillTimerPopUp();
138 mPausePlay = 0; 138 mPausePlay = 0;
139 confPause( 1 ); 139 confPause( 1 );
140 mSuspend = 0; 140 mSuspend = 0;
141 confSuspend( 0 ); 141 confSuspend( 0 );
142 if ( QApplication::desktop()->width() < 480 ) { 142 if ( QApplication::desktop()->width() < 480 ) {
143 wavAlarm = false; 143 wavAlarm = false;
144 mSoundPopUp->setItemChecked ( 0, true ); 144 mSoundPopUp->setItemChecked ( 0, true );
145 } 145 }
146 else { 146 else {
147 wavAlarm = true; 147 wavAlarm = true;
148 mSoundPopUp->setItemChecked ( 1, true ); 148 mSoundPopUp->setItemChecked ( 1, true );
149 } 149 }
150 saveSlot( 1 ); 150 saveSlot( 1 );
151 mTimerStartLabel = new QLabel( 0 );
152 mTimerStartLabel->setCaption( "Timer started!");
153 fon = mTimerPopUp->font();
154 fon.setBold( true );
155 points = (fon.pointSize()*2);
156 fon.setPointSize( points );
157 mTimerStartLabel->setFont( fon );
151} 158}
152 159
153SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 160SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
154{ 161{
155 //delete mPopUp; 162 //delete mPopUp;
156 delete mAlarmDialog; 163 delete mAlarmDialog;
164 delete mTimerStartLabel;
157} 165}
166
158void SimpleAlarmDaemonImpl::saveSlot( int load ) 167void SimpleAlarmDaemonImpl::saveSlot( int load )
159{ 168{
160 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 169 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
161 //qDebug("save %d ", load ); 170 //qDebug("save %d ", load );
162 QFile file( fileName ); 171 QFile file( fileName );
163 if ( load ) { 172 if ( load ) {
164 if( !QFile::exists( fileName) ) 173 if( !QFile::exists( fileName) )
165 return; 174 return;
166 if (!file.open( IO_ReadOnly ) ) { 175 if (!file.open( IO_ReadOnly ) ) {
167 return ; 176 return ;
168 } 177 }
169 QString line; 178 QString line;
170 bool ok; 179 bool ok;
171 int val; 180 int val;
172 int len; 181 int len;
173 while ( file.readLine( line, 1024 ) > 0 ) { 182 while ( file.readLine( line, 1024 ) > 0 ) {
174 //qDebug("read %s ", line.latin1()); 183 //qDebug("read %s ", line.latin1());
175 len = line.length(); 184 len = line.length();
176 if ( line.left(4 ) == "PPAU" ) { 185 if ( line.left(4 ) == "PPAU" ) {
177 val = line.mid( 4,len-5).toInt( &ok ); 186 val = line.mid( 4,len-5).toInt( &ok );
178 if ( ok ) { 187 if ( ok ) {
179 confPause( val ); 188 confPause( val );
180 } 189 }
181 } 190 }
182 if ( line.left(4 ) == "SUCO" ) { 191 if ( line.left(4 ) == "SUCO" ) {
183 val = line.mid( 4,len-5).toInt( &ok ); 192 val = line.mid( 4,len-5).toInt( &ok );
184 if ( ok ) 193 if ( ok )
185 confSuspend ( val ); 194 confSuspend ( val );
186 } 195 }
187 if ( line.left(4 ) == "WAAL" ) { 196 if ( line.left(4 ) == "WAAL" ) {
188 val = line.mid( 4,len-5).toInt( &ok ); 197 val = line.mid( 4,len-5).toInt( &ok );
189 if ( ok ) 198 if ( ok )
190 confSound( val ); 199 confSound( val );
191 200
192 } 201 }
193 if ( line.left(4 ) == "PLBE" ) { 202 if ( line.left(4 ) == "PLBE" ) {
194 val = line.mid( 4,len-5).toInt( &ok ); 203 val = line.mid( 4,len-5).toInt( &ok );
195 if ( ok ) 204 if ( ok )
196 slotPlayBeep( val ); 205 slotPlayBeep( val );
197 206
198 } 207 }
199 if ( line.left(4 ) == "CUTE" ) { 208 if ( line.left(4 ) == "CUTE" ) {
200 mCustomText = line.mid( 5,len-6); 209 mCustomText = line.mid( 5,len-6);
201 // qDebug("text ***%s*** ",mCustomText.latin1() ); 210 // qDebug("text ***%s*** ",mCustomText.latin1() );
202 211
203 } 212 }
204 if ( line.left(4 ) == "CUMI" ) { 213 if ( line.left(4 ) == "CUMI" ) {
205 val = line.mid( 4,len-5).toInt( &ok ); 214 val = line.mid( 4,len-5).toInt( &ok );
206 if ( ok ) 215 if ( ok )
207 mCustomMinutes = val; 216 mCustomMinutes = val;
208 217
209 } 218 }
210 if ( line.left(4 ) == "SUTI" ) { 219 if ( line.left(4 ) == "SUTI" ) {
211 val = line.mid( 4,len-5).toInt( &ok ); 220 val = line.mid( 4,len-5).toInt( &ok );
212 if ( ok ) 221 if ( ok )
213 mAlarmDialog->setSuspendTime( val );; 222 mAlarmDialog->setSuspendTime( val );;
214 223
215 } 224 }
216 } 225 }
217 file.close(); 226 file.close();
218 } else { 227 } else {
219 if (!file.open( IO_WriteOnly ) ) { 228 if (!file.open( IO_WriteOnly ) ) {
220 return; 229 return;
221 } 230 }
222 QString configString ; 231 QString configString ;
223 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 232 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
224 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 233 configString += "SUCO " + QString::number( mSuspend ) + "\n";
225 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 234 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
226 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 235 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
227 configString += "CUTE " + mCustomText + "\n"; 236 configString += "CUTE " + mCustomText + "\n";
228 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 237 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
229 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 238 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
230 QTextStream ts( &file ); 239 QTextStream ts( &file );
231 ts << configString ; 240 ts << configString ;
232 file.close(); 241 file.close();
233 } 242 }
234 243
235} 244}
236void SimpleAlarmDaemonImpl::confSuspend( int num ) 245void SimpleAlarmDaemonImpl::confSuspend( int num )
237{ 246{
238 mSuspendPopUp->setItemChecked ( mSuspend,false ); 247 mSuspendPopUp->setItemChecked ( mSuspend,false );
239 mSuspend = num; 248 mSuspend = num;
240 mSuspendPopUp->setItemChecked ( mSuspend,true ); 249 mSuspendPopUp->setItemChecked ( mSuspend,true );
241} 250}
242void SimpleAlarmDaemonImpl::confPause( int num ) 251void SimpleAlarmDaemonImpl::confPause( int num )
243{ 252{
244 mPausePopUp->setItemChecked ( mPausePlay,false ); 253 mPausePopUp->setItemChecked ( mPausePlay,false );
245 mPausePlay = num; 254 mPausePlay = num;
246 mPausePopUp->setItemChecked ( mPausePlay,true ); 255 mPausePopUp->setItemChecked ( mPausePlay,true );
247} 256}
248void SimpleAlarmDaemonImpl::confSound( int num ) 257void SimpleAlarmDaemonImpl::confSound( int num )
249{ 258{
250 if ( num == 0 ) { 259 if ( num == 0 ) {
251 wavAlarm = false; 260 wavAlarm = false;
252 mSoundPopUp->setItemChecked ( 0, true ); 261 mSoundPopUp->setItemChecked ( 0, true );
253 mSoundPopUp->setItemChecked ( 1, false ); 262 mSoundPopUp->setItemChecked ( 1, false );
254 } else { 263 } else {
255 wavAlarm = true; 264 wavAlarm = true;
256 mSoundPopUp->setItemChecked ( 0, false ); 265 mSoundPopUp->setItemChecked ( 0, false );
257 mSoundPopUp->setItemChecked ( 1, true ); 266 mSoundPopUp->setItemChecked ( 1, true );
258 } 267 }
259} 268}
260void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 269void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
261{ 270{
262 if ( num == 1000 ) { 271 if ( num == 1000 ) {
263 simulate(); 272 simulate();
264 return; 273 return;
265 } 274 }
266 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 275 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
267 mPlayBeeps = num; 276 mPlayBeeps = num;
268 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 277 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
269} 278}
270 279
271void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 280void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
272{ 281{
273 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 282 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
274 QString mess = QString::fromUtf8(msg.data()); 283 QString mess = QString::fromUtf8(msg.data());
275 mAlarmMessage = mess.mid( 9 ); 284 mAlarmMessage = mess.mid( 9 );
276 QString filename = getenv("QPEDIR") ; 285 QString filename = getenv("QPEDIR") ;
277 filename += "/pics/kdepim/korganizer/koalarm.wav"; 286 filename += "/pics/kdepim/korganizer/koalarm.wav";
278 QString tempfilename; 287 QString tempfilename;
279 if ( mess.left( 13 ) == "suspend_alarm") { 288 if ( mess.left( 13 ) == "suspend_alarm") {
280 bool error = false; 289 bool error = false;
281 int len = mess.mid( 13 ).find("+++"); 290 int len = mess.mid( 13 ).find("+++");
282 if ( len < 2 ) 291 if ( len < 2 )
283 error = true; 292 error = true;
284 else { 293 else {
285 tempfilename = mess.mid( 13, len ); 294 tempfilename = mess.mid( 13, len );
286 if ( !QFile::exists( tempfilename ) ) 295 if ( !QFile::exists( tempfilename ) )
287 error = true; 296 error = true;
288 } 297 }
289 if ( ! error ) { 298 if ( ! error ) {
290 filename = tempfilename; 299 filename = tempfilename;
291 } 300 }
292 mAlarmMessage = mess.mid( 13+len+3 ); 301 mAlarmMessage = mess.mid( 13+len+3 );
293 //qDebug("suspend file %s ",tempfilename.latin1() ); 302 //qDebug("suspend file %s ",tempfilename.latin1() );
294 startAlarm( mAlarmMessage, filename); 303 startAlarm( mAlarmMessage, filename);
295 return; 304 return;
296 } 305 }
297 if ( mess.left( 11 ) == "timer_alarm") { 306 if ( mess.left( 11 ) == "timer_alarm") {
298 mTimerTime = 0; 307 mTimerTime = 0;
299 startAlarm( mess.mid( 11 ), filename ); 308 startAlarm( mess.mid( 11 ), filename );
300 return; 309 return;
301 } 310 }
302 if ( mess.left( 10 ) == "proc_alarm") { 311 if ( mess.left( 10 ) == "proc_alarm") {
303 bool error = false; 312 bool error = false;
304 int len = mess.mid( 10 ).find("+++"); 313 int len = mess.mid( 10 ).find("+++");
305 if ( len < 2 ) 314 if ( len < 2 )
306 error = true; 315 error = true;
307 else { 316 else {
308 tempfilename = mess.mid( 10, len ); 317 tempfilename = mess.mid( 10, len );
309 if ( !QFile::exists( tempfilename ) ) 318 if ( !QFile::exists( tempfilename ) )
310 error = true; 319 error = true;
311 } 320 }
312 if ( error ) { 321 if ( error ) {
313 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 322 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
314 mAlarmMessage += mess.mid( 10+len+3+9 ); 323 mAlarmMessage += mess.mid( 10+len+3+9 );
315 } else { 324 } else {
316 //qDebug("-----system command %s ",tempfilename.latin1() ); 325 //qDebug("-----system command %s ",tempfilename.latin1() );
317 if ( vfork () == 0 ) { 326 if ( vfork () == 0 ) {
318 execl ( tempfilename.latin1(), 0 ); 327 execl ( tempfilename.latin1(), 0 );
319 return; 328 return;
320 } 329 }
321 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); 330 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) );
322 return; 331 return;
323 } 332 }
324 333
325 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 334 //qDebug("+++++++system command %s ",tempfilename.latin1() );
326 } 335 }
327 if ( mess.left( 11 ) == "audio_alarm") { 336 if ( mess.left( 11 ) == "audio_alarm") {
328 bool error = false; 337 bool error = false;
329 int len = mess.mid( 11 ).find("+++"); 338 int len = mess.mid( 11 ).find("+++");
330 if ( len < 2 ) 339 if ( len < 2 )
331 error = true; 340 error = true;
332 else { 341 else {
333 tempfilename = mess.mid( 11, len ); 342 tempfilename = mess.mid( 11, len );
334 if ( !QFile::exists( tempfilename ) ) 343 if ( !QFile::exists( tempfilename ) )
335 error = true; 344 error = true;
336 } 345 }
337 if ( ! error ) { 346 if ( ! error ) {
338 filename = tempfilename; 347 filename = tempfilename;
339 } 348 }
340 mAlarmMessage = mess.mid( 11+len+3+9 ); 349 mAlarmMessage = mess.mid( 11+len+3+9 );
341 //qDebug("audio file command %s ",tempfilename.latin1() ); 350 //qDebug("audio file command %s ",tempfilename.latin1() );
342 } 351 }
343 if ( mess.left( 9 ) == "cal_alarm") { 352 if ( mess.left( 9 ) == "cal_alarm") {
344 mAlarmMessage = mess.mid( 9 ) ; 353 mAlarmMessage = mess.mid( 9 ) ;
345 } 354 }
346 355
347 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); 356 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) );
348 startAlarm( mAlarmMessage, filename ); 357 startAlarm( mAlarmMessage, filename );
349 358
350} 359}
351 360
352int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 361int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
353{ 362{
354 return 0; 363 return 0;
355} 364}
356void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 365void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
357{ 366{
358 //mAlarmDialog->show(); 367 //mAlarmDialog->show();
359 //mAlarmDialog->raise(); 368 //mAlarmDialog->raise();
360 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 369 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
361} 370}
362 371
363 372
364void SimpleAlarmDaemonImpl::fillTimerPopUp() 373void SimpleAlarmDaemonImpl::fillTimerPopUp()
365{ 374{
366 375
367 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 376 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
368 if ( mTimerPopupConf == mTimerTime ) { 377 if ( mTimerPopupConf == mTimerTime ) {
369 if ( mTimerTime ) { 378 if ( mTimerTime ) {
370 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 379 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
371 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 380 QTime t ( secs/3600, (secs/60)%60, secs%60 );
372 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 381 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
373 } 382 }
374 else { 383 else {
375 QString text = mCustomText.stripWhiteSpace (); 384 QString text = mCustomText.stripWhiteSpace ();
376 int in = text.find( " " ); 385 int in = text.find( " " );
377 text = text.left ( in ); 386 text = text.left ( in );
378 mTimerPopUp->changeItem ( 3, text ); 387 mTimerPopUp->changeItem ( 3, text );
379 } 388 }
380 return; 389 return;
381 } 390 }
382 mTimerPopupConf = mTimerTime; 391 mTimerPopupConf = mTimerTime;
383 mTimerPopUp->clear(); 392 mTimerPopUp->clear();
384 if ( mTimerTime ) { 393 if ( mTimerTime ) {
385 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 394 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
386 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 395 QTime t ( secs/3600, (secs/60)%60, secs%60 );
387 396
388 397
389 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 398 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
390 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 399 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
391 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 400 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
392 } else { 401 } else {
393 402
394 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 403 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
395 QFile file( fileName ); 404 QFile file( fileName );
396 if( !QFile::exists( fileName) ) { 405 if( !QFile::exists( fileName) ) {
397 // write defaults 406 // write defaults
398 if (!file.open( IO_WriteOnly ) ) { 407 if (!file.open( IO_WriteOnly ) ) {
399 return; 408 return;
400 } 409 }
401 QString configString ; 410 QString configString ;
402 configString += "#config file for kopi alarm timer\n"; 411 configString += "#config file for kopi alarm timer\n";
403 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 412 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
404 configString += "24 hours; 1440\n"; 413 configString += "24 hours; 1440\n";
414 configString += "9 hours; 540\n";
405 configString += "8 hours; 480\n"; 415 configString += "8 hours; 480\n";
406 configString += "5 hours; 300\n";
407 configString += "1 hour; 60\n"; 416 configString += "1 hour; 60\n";
408 configString += "30 min; 30\n"; 417 configString += "30 min; 30\n";
409 configString += "15 min; 15\n"; 418 configString += "15 min; 15\n";
410 configString += "SEPARATOR\n"; 419 configString += "SEPARATOR\n";
411 configString += "Pizza; 22\n"; 420 configString += "Pizza; 22\n";
412 configString += "Nap; 45\n"; 421 configString += "Nap; 45\n";
413 configString += "Tea; 5\n"; 422 configString += "Tea; 5\n";
414 QTextStream ts( &file ); 423 QTextStream ts( &file );
415 ts << configString ; 424 ts << configString ;
416 file.close(); 425 file.close();
417 } 426 }
418 427
419 if (!file.open( IO_ReadOnly ) ) { 428 if (!file.open( IO_ReadOnly ) ) {
420 return ; 429 return ;
421 } 430 }
422 QString line; 431 QString line;
423 bool ok; 432 bool ok;
424 while ( file.readLine( line, 1024 ) > 0 ) { 433 while ( file.readLine( line, 1024 ) > 0 ) {
425 //qDebug("read %s ", line.latin1()); 434 //qDebug("read %s ", line.latin1());
426 if ( line.left(1 ) != "#" ) { 435 if ( line.left(1 ) != "#" ) {
427 // no comment 436 // no comment
428 if ( line.left(9 ) == "SEPARATOR" ) { 437 if ( line.left(9 ) == "SEPARATOR" ) {
429 mTimerPopUp->insertSeparator(); 438 mTimerPopUp->insertSeparator();
430 } else { 439 } else {
431 QStringList li = QStringList::split(";",line); 440 QStringList li = QStringList::split(";",line);
432 ok = false; 441 ok = false;
433 if ( li.count() == 2 ) { 442 if ( li.count() == 2 ) {
434 int val = li[1].toInt( &ok ); 443 int val = li[1].toInt( &ok );
435 if ( ok && val > 0 ) { 444 if ( ok && val > 0 ) {
436 mTimerPopUp->insertItem( li[0], val+10); 445 mTimerPopUp->insertItem( li[0], val+10);
437 } 446 }
438 } 447 }
439 } 448 }
440 } 449 }
441 } 450 }
442 file.close(); 451 file.close();
443#if 0 452#if 0
444 mTimerPopUp->insertItem( "24 hours", 1440 ); 453 mTimerPopUp->insertItem( "24 hours", 1440 );
445 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 454 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
446 mTimerPopUp->insertItem( " 8 hours", 480 ); 455 mTimerPopUp->insertItem( " 8 hours", 480 );
447 mTimerPopUp->insertItem( " 5 hours", 300 ); 456 mTimerPopUp->insertItem( " 5 hours", 300 );
448 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 457 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
449 mTimerPopUp->insertItem( " 1 hour", 60 ); 458 mTimerPopUp->insertItem( " 1 hour", 60 );
450 mTimerPopUp->insertItem( "30 min", 30 ); 459 mTimerPopUp->insertItem( "30 min", 30 );
451 mTimerPopUp->insertItem( "15 min", 15 ); 460 mTimerPopUp->insertItem( "15 min", 15 );
452 mTimerPopUp->insertItem( "10 min", 10 ); 461 mTimerPopUp->insertItem( "10 min", 10 );
453 //mTimerPopUp->insertItem( " 5 min", 5 ); 462 //mTimerPopUp->insertItem( " 5 min", 5 );
454 mTimerPopUp->insertSeparator(); 463 mTimerPopUp->insertSeparator();
455 mTimerPopUp->insertItem( "Pizza", 22 ); 464 mTimerPopUp->insertItem( "Pizza", 22 );
456 mTimerPopUp->insertItem( "Nap", 45 ); 465 mTimerPopUp->insertItem( "Nap", 45 );
457 mTimerPopUp->insertItem( "Tea", 5 ); 466 mTimerPopUp->insertItem( "Tea", 5 );
458#endif 467#endif
459 QString text = mCustomText.stripWhiteSpace (); 468 QString text = mCustomText.stripWhiteSpace ();
460 int in = text.find( " " ); 469 int in = text.find( " " );
461 text = text.left ( in ); 470 text = text.left ( in );
462 mTimerPopUp->insertItem( text, 3 ); 471 mTimerPopUp->insertItem( text, 3 );
463 mTimerPopUp->insertSeparator(); 472 mTimerPopUp->insertSeparator();
464 mTimerPopUp->insertItem( "Customize", 2 ); 473 mTimerPopUp->insertItem( "Customize", 2 );
465 } 474 }
466 475
467} 476}
468 477
469void SimpleAlarmDaemonImpl::showTimer() 478void SimpleAlarmDaemonImpl::showTimer()
470{ 479{
471 fillTimerPopUp(); 480 fillTimerPopUp();
472} 481}
473 482
474void SimpleAlarmDaemonImpl::confTimer( int time ) 483void SimpleAlarmDaemonImpl::confTimer( int time )
475{ 484{
476 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 485 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
477 int minutes = time; 486 int minutes = time;
478 if ( minutes == 0 ) { 487 if ( minutes == 0 ) {
479 if ( ! mTimerTime ) 488 if ( ! mTimerTime )
480 return; 489 return;
481 490
482 QDialog dia ( 0, ("Stop Timer" ), true ); 491 QDialog dia ( 0, ("Stop Timer" ), true );
483 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 492 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
484 lab.setAlignment( AlignCenter ); 493 lab.setAlignment( AlignCenter );
485 dia.setCaption(("KO/Pi Timer Stop" )); 494 dia.setCaption(("KO/Pi Timer Stop" ));
486 QVBoxLayout lay( &dia ); 495 QVBoxLayout lay( &dia );
487 lay.addWidget( &lab); 496 lay.addWidget( &lab);
488 QPushButton ok ( "Stop timer!", &dia); 497 QPushButton ok ( "Stop timer!", &dia);
489 QFont fo = dia.font(); 498 QFont fo = dia.font();
490 fo.setPointSize( 36 ); 499 fo.setPointSize( 36 );
491 ok.setFont( fo ); 500 ok.setFont( fo );
492 lay.addWidget( &ok); 501 lay.addWidget( &ok);
493 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 502 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
494 QPushButton con ( "Continue timer!", &dia); 503 QPushButton con ( "Continue timer!", &dia);
495 fo.setPointSize( 36 ); 504 fo.setPointSize( 36 );
496 con.setFont( fo ); 505 con.setFont( fo );
497 lay.addWidget( &con); 506 lay.addWidget( &con);
498 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 507 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
499 lay.setMargin(5); 508 lay.setMargin(5);
500 lay.setSpacing(5); 509 lay.setSpacing(5);
501 dia.resize(dia.sizeHint() ); 510 dia.resize(dia.sizeHint() );
502 511
503 if ( !dia.exec() ) 512 if ( !dia.exec() )
504 return; 513 return;
505 514
506 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 515 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
507 mTimerTime = 0; 516 mTimerTime = 0;
508 return; 517 return;
509 } 518 }
510 if ( mTimerTime ) 519 if ( mTimerTime )
511 return; 520 return;
512 if ( minutes == 1 ) { 521 if ( minutes == 1 ) {
513 return; 522 return;
514 } 523 }
515 QString mess = "timer_alarm"; 524 QString mess = "timer_alarm";
525 QString disp;
516 mess += ("Timer Alarm!\n"); 526 mess += ("Timer Alarm!\n");
517 if ( minutes == 3 ) { 527 if ( minutes == 3 ) {
518 mess += mCustomText; 528 mess += mCustomText;
519 minutes = mCustomMinutes ; 529 minutes = mCustomMinutes ;
520 mRunningTimerText = mCustomText.stripWhiteSpace (); 530 mRunningTimerText = mCustomText.stripWhiteSpace ();
521 int in = mRunningTimerText.find( " " ); 531 int in = mRunningTimerText.find( " " );
522 mRunningTimerText = mRunningTimerText.left ( in ); 532 mRunningTimerText = mRunningTimerText.left ( in );
533 disp = mCustomText;
523 } 534 }
524 else { 535 else {
525 if ( minutes == 2 ) { 536 if ( minutes == 2 ) {
526 // ask time 537 // ask time
527 QDialog dia ( 0, ("Customize Timer" ), true ); 538 QDialog dia ( 0, ("Customize Timer" ), true );
528 QLabel lab (("Message Text:"), &dia ); 539 QLabel lab (("Message Text:"), &dia );
529 dia.setCaption(("KO/Pi Timer" )); 540 dia.setCaption(("KO/Pi Timer" ));
530 QVBoxLayout lay( &dia ); 541 QVBoxLayout lay( &dia );
531 lay.setMargin(5); 542 lay.setMargin(5);
532 lay.setSpacing(5); 543 lay.setSpacing(5);
533 lay.addWidget( &lab); 544 lay.addWidget( &lab);
534 QLineEdit lEdit( mCustomText, &dia ); 545 QLineEdit lEdit( mCustomText, &dia );
535 lay.addWidget( &lEdit); 546 lay.addWidget( &lEdit);
536 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 547 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
537 lay.addWidget( &lab2); 548 lay.addWidget( &lab2);
538 QHBox hbox1 ( &dia ); 549 QHBox hbox1 ( &dia );
539 lay.addWidget( &hbox1); 550 lay.addWidget( &hbox1);
540 QLabel lab3 (("Hours"), &hbox1 ); 551 QLabel lab3 (("Hours"), &hbox1 );
541 QLabel lab4 (("Minutes"), &hbox1 ); 552 QLabel lab4 (("Minutes"), &hbox1 );
542 QHBox hbox ( &dia ); 553 QHBox hbox ( &dia );
543 QSpinBox spinh( 0, 24, 1,& hbox ); 554 QSpinBox spinh( 0, 24, 1,& hbox );
544 QFont fo = dia.font(); 555 QFont fo = dia.font();
545 fo.setPointSize( 36 ); 556 fo.setPointSize( 36 );
546 QSpinBox spinm( 0, 59, 1,&hbox ); 557 QSpinBox spinm( 0, 59, 1,&hbox );
547 spinm.setFont( fo ); 558 spinm.setFont( fo );
548 spinh.setFont( fo ); 559 spinh.setFont( fo );
549 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 560 spinh.setButtonSymbols( QSpinBox::PlusMinus );
550 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 561 spinm.setButtonSymbols( QSpinBox::PlusMinus );
551 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 562 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
552 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 563 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
553 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 564 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
554 spinh.setFixedSize( 100,62 ); 565 spinh.setFixedSize( 100,62 );
555 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 566 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
556 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 567 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
557 spinm.downButton ()->setGeometry( 50,50,50,50); 568 spinm.downButton ()->setGeometry( 50,50,50,50);
558 // spinm.setSuffix( " m" ); 569 // spinm.setSuffix( " m" );
559 //spinh.setSuffix( " h" ); 570 //spinh.setSuffix( " h" );
560 spinm.setWrapping ( true ); 571 spinm.setWrapping ( true );
561 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 572 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
562 spinm.setLineStep( 1 ); 573 spinm.setLineStep( 1 );
563 spinm.setFixedSize( 110,62 ); 574 spinm.setFixedSize( 110,62 );
564 lay.addWidget( &hbox); 575 lay.addWidget( &hbox);
565 QLabel lab5 ("Timer fires at:", &dia ); 576 QLabel lab5 ("Timer fires at:", &dia );
566 lab5.setAlignment( AlignCenter ); 577 lab5.setAlignment( AlignCenter );
567 lay.addWidget( &lab5); 578 lay.addWidget( &lab5);
568 KODateLabel dl ( &dia ); 579 KODateLabel dl ( &dia );
569 dl.setAlignment( AlignCenter ); 580 dl.setAlignment( AlignCenter );
570 dl.setFont( fo ); 581 dl.setFont( fo );
571 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 582 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
572 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 583 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
573 lay.addWidget( &dl); 584 lay.addWidget( &dl);
574 spinh.setValue( mCustomMinutes/60 ); 585 spinh.setValue( mCustomMinutes/60 );
575 spinm.setValue( mCustomMinutes%60 ); 586 spinm.setValue( mCustomMinutes%60 );
576 QPushButton ok ( "Start timer", &dia); 587 QPushButton ok ( "Start timer", &dia);
577 ok.setDefault( true ); 588 ok.setDefault( true );
578 ok.setFont( fo ); 589 ok.setFont( fo );
579 spinh.setFocus(); 590 spinh.setFocus();
580 lay.addWidget( &ok); 591 lay.addWidget( &ok);
581 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 592 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
582 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 593 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
583 594
584 if ( !dia.exec() ) 595 if ( !dia.exec() )
585 return; 596 return;
586 mCustomText = lEdit.text(); 597 mCustomText = lEdit.text();
587 mCustomMinutes = spinh.value()*60+spinm.value(); 598 mCustomMinutes = spinh.value()*60+spinm.value();
588 if ( mCustomMinutes == 0 ) 599 if ( mCustomMinutes == 0 )
589 mCustomMinutes = 1; 600 mCustomMinutes = 1;
590 if ( mCustomMinutes > 1440 ) 601 if ( mCustomMinutes > 1440 )
591 mCustomMinutes = 1440; 602 mCustomMinutes = 1440;
592 mess += mCustomText; 603 mess += mCustomText;
604 disp = mCustomText;
593 minutes = mCustomMinutes; 605 minutes = mCustomMinutes;
594 mRunningTimerText = mCustomText.stripWhiteSpace (); 606 mRunningTimerText = mCustomText.stripWhiteSpace ();
595 int in = mRunningTimerText.find( " " ); 607 int in = mRunningTimerText.find( " " );
596 mRunningTimerText = mRunningTimerText.left ( in ); 608 mRunningTimerText = mRunningTimerText.left ( in );
597 } 609 }
598 else { 610 else {
599 mess += mTimerPopUp->text( minutes ); 611 mess += mTimerPopUp->text( minutes );
612 disp = mTimerPopUp->text( minutes );
600 mRunningTimerText = mTimerPopUp->text( minutes ); 613 mRunningTimerText = mTimerPopUp->text( minutes );
601 minutes -= 10; 614 minutes -= 10;
602 } 615 }
603 } 616 }
604 //minutes = 1; 617 //minutes = 1;
605 618
606 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 619 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
607 timerMesssage = mess; 620 timerMesssage = mess;
608 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 621 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
622 mTimerStartLabel->setText( disp );
623 int w = 200;
624 int h = mTimerStartLabel->sizeHint().height() ;
625 int dw = QApplication::desktop()->width();
626 int dh = QApplication::desktop()->height();
627 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
628 mTimerStartLabel->show();
629 QTimer::singleShot( 3000, mTimerStartLabel, SLOT ( hide() ) );
609 mTimerTime = 1; 630 mTimerTime = 1;
610} 631}
611 632
612void SimpleAlarmDaemonImpl::writeFile() 633void SimpleAlarmDaemonImpl::writeFile()
613{ 634{
614 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 635 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
615 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 636 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
616} 637}
617void SimpleAlarmDaemonImpl::showWN() 638void SimpleAlarmDaemonImpl::showWN()
618{ 639{
619 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 640 QCopEnvelope e("QPE/Application/kopi", "-showWN");
620} 641}
621void SimpleAlarmDaemonImpl::newTodo() 642void SimpleAlarmDaemonImpl::newTodo()
622{ 643{
623 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 644 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
624} 645}
625 646
626void SimpleAlarmDaemonImpl::newEvent() 647void SimpleAlarmDaemonImpl::newEvent()
627{ 648{
628 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 649 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
629 650
630} 651}
631void SimpleAlarmDaemonImpl::newMail() 652void SimpleAlarmDaemonImpl::newMail()
632{ 653{
633 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 654 QCopEnvelope e("QPE/Application/ompi", "newMail()");
634} 655}
635void SimpleAlarmDaemonImpl::showAdd() 656void SimpleAlarmDaemonImpl::showAdd()
636{ 657{
637 QCopEnvelope e("QPE/Application/kapi", "raise()"); 658 QCopEnvelope e("QPE/Application/kapi", "raise()");
638} 659}
639void SimpleAlarmDaemonImpl::ringSync() 660void SimpleAlarmDaemonImpl::ringSync()
640{ 661{
641 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 662 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
642 663
643} 664}
644void SimpleAlarmDaemonImpl::newCountdown() 665void SimpleAlarmDaemonImpl::newCountdown()
645{ 666{
646 //recieve("cal_alarm", 10 ); 667 //recieve("cal_alarm", 10 );
647} 668}
648void SimpleAlarmDaemonImpl::simulate() 669void SimpleAlarmDaemonImpl::simulate()
649{ 670{
650 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); 671 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) );
651 QString filename = getenv("QPEDIR") ; 672 QString filename = getenv("QPEDIR") ;
652 filename += "/pics/kdepim/korganizer/koalarm.wav"; 673 filename += "/pics/kdepim/korganizer/koalarm.wav";
653 startAlarm("Alarm simulation", filename ); 674 startAlarm("Alarm simulation", filename );
654} 675}
655void SimpleAlarmDaemonImpl::showKO() 676void SimpleAlarmDaemonImpl::showKO()
656{ 677{
657 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 678 QCopEnvelope e("QPE/Application/kopi", "-showKO");
658 // testing only 679 // testing only
659 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 680 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
660 681
661} 682}
662void SimpleAlarmDaemonImpl::showTodo() 683void SimpleAlarmDaemonImpl::showTodo()
663{ 684{
664 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 685 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
665 686
666} 687}
667void SimpleAlarmDaemonImpl::writeJournal() 688void SimpleAlarmDaemonImpl::writeJournal()
668{ 689{
669 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 690 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
670 691
671} 692}
672 693
673void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 694void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
674{ 695{
675 696
676 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 697 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
677 698
678} 699}
679 700
diff --git a/kalarmd/simplealarmdaemonimpl.h b/kalarmd/simplealarmdaemonimpl.h
index cbdba47..9b7de94 100644
--- a/kalarmd/simplealarmdaemonimpl.h
+++ b/kalarmd/simplealarmdaemonimpl.h
@@ -1,119 +1,120 @@
1/* 1/*
2 This file is part of the KOrganizer alarm daemon. 2 This file is part of the KOrganizer alarm daemon.
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#include <qtimer.h> 29#include <qtimer.h>
30 30
31class QLabel; 31class QLabel;
32class QTimer; 32class QTimer;
33class QPopupMenu; 33class QPopupMenu;
34class AlarmDialog; 34class AlarmDialog;
35class SimpleAlarmDaemonImpl : public QLabel 35class SimpleAlarmDaemonImpl : public QLabel
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 SimpleAlarmDaemonImpl( QWidget *parent = 0 ); 39 SimpleAlarmDaemonImpl( QWidget *parent = 0 );
40 40
41 ~SimpleAlarmDaemonImpl(); 41 ~SimpleAlarmDaemonImpl();
42 42
43 protected slots: 43 protected slots:
44 void recieve( const QCString& msg, const QByteArray& data ); 44 void recieve( const QCString& msg, const QByteArray& data );
45 void newTodo(); 45 void newTodo();
46 void newEvent(); 46 void newEvent();
47 void newCountdown(); 47 void newCountdown();
48 void simulate(); 48 void simulate();
49 void showKO(); 49 void showKO();
50 void showWN(); 50 void showWN();
51 void showAdd(); 51 void showAdd();
52 void newMail(); 52 void newMail();
53 void ringSync(); 53 void ringSync();
54 void showTodo(); 54 void showTodo();
55 void writeFile(); 55 void writeFile();
56 void writeJournal(); 56 void writeJournal();
57 void slotPlayBeep( int ); 57 void slotPlayBeep( int );
58 void showTimer( ); 58 void showTimer( );
59 void confPause( int ); 59 void confPause( int );
60 void confTimer( int ); 60 void confTimer( int );
61 void saveSlot( int ); 61 void saveSlot( int );
62 void confSuspend( int ); 62 void confSuspend( int );
63 void confSound( int num ); 63 void confSound( int num );
64 void startAlarm(QString mess, QString fn ); 64 void startAlarm(QString mess, QString fn );
65 65
66 protected: 66 protected:
67 void mousePressEvent( QMouseEvent * ); 67 void mousePressEvent( QMouseEvent * );
68 68
69 private: 69 private:
70 AlarmDialog *mAlarmDialog; 70 AlarmDialog *mAlarmDialog;
71 QLabel * mTimerStartLabel;
71 int mPlayBeeps; 72 int mPlayBeeps;
72 int mPausePlay; 73 int mPausePlay;
73 int mSuspend; 74 int mSuspend;
74 QString mAlarmMessage; 75 QString mAlarmMessage;
75 int mTimerTime; 76 int mTimerTime;
76 int getFileNameLen( QString ); 77 int getFileNameLen( QString );
77 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp; 78 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp;
78 QDateTime mRunningTimer; 79 QDateTime mRunningTimer;
79 void fillTimerPopUp(); 80 void fillTimerPopUp();
80 QString timerMesssage; 81 QString timerMesssage;
81 QString mCustomText; 82 QString mCustomText;
82 QString mRunningTimerText; 83 QString mRunningTimerText;
83 int mCustomMinutes; 84 int mCustomMinutes;
84 int mTimerPopupConf; 85 int mTimerPopupConf;
85 bool wavAlarm; 86 bool wavAlarm;
86}; 87};
87class KODateLabel : public QLabel 88class KODateLabel : public QLabel
88{ 89{
89 Q_OBJECT 90 Q_OBJECT
90 public: 91 public:
91 KODateLabel( QWidget *parent=0, const char *name=0 ) : 92 KODateLabel( QWidget *parent=0, const char *name=0 ) :
92 QLabel( parent, name ) 93 QLabel( parent, name )
93 { 94 {
94 hour = 0; 95 hour = 0;
95 minutes = 0; 96 minutes = 0;
96 QTimer * ti = new QTimer( this ); 97 QTimer * ti = new QTimer( this );
97 connect ( ti, SIGNAL ( timeout () ), this, SLOT ( updateText() )); 98 connect ( ti, SIGNAL ( timeout () ), this, SLOT ( updateText() ));
98 ti->start( 1000 ); 99 ti->start( 1000 );
99 100
100 } 101 }
101public slots: 102public slots:
102 void slot_minutes( int m ) 103 void slot_minutes( int m )
103 { 104 {
104 minutes = m; updateText(); 105 minutes = m; updateText();
105 } 106 }
106 void slot_hours( int h ) 107 void slot_hours( int h )
107 { 108 {
108 hour = h; updateText(); 109 hour = h; updateText();
109 } 110 }
110private slots: 111private slots:
111 void updateText() 112 void updateText()
112 { 113 {
113 QDateTime dt = QDateTime::currentDateTime(); 114 QDateTime dt = QDateTime::currentDateTime();
114 dt = dt.addSecs( minutes * 60 + hour * 3600 ); 115 dt = dt.addSecs( minutes * 60 + hour * 3600 );
115 setText( dt.time().toString() ); 116 setText( dt.time().toString() );
116 } 117 }
117 int hour, minutes; 118 int hour, minutes;
118}; 119};
119#endif 120#endif