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