Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 552 |
1 files changed, 552 insertions, 0 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp new file mode 100644 index 0000000..2bc6643 --- a/dev/null +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -0,0 +1,552 @@ | |||
1 | /* | ||
2 | This file is part of the KOrganizer alarm daemon. | ||
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include "simplealarmdaemonimpl.h" | ||
25 | |||
26 | #include "alarmdialog.h" | ||
27 | #include <qpopupmenu.h> | ||
28 | #include <qapp.h> | ||
29 | #include <qdir.h> | ||
30 | #include <qfile.h> | ||
31 | #include <qhbox.h> | ||
32 | #include <qtimer.h> | ||
33 | #include <qfile.h> | ||
34 | #include <qlayout.h> | ||
35 | #include <qlineedit.h> | ||
36 | #include <qdialog.h> | ||
37 | #include <qspinbox.h> | ||
38 | #include <qtextstream.h> | ||
39 | #include <qtopia/qcopenvelope_qws.h> | ||
40 | #include <qtopia/alarmserver.h> | ||
41 | |||
42 | #include <stdlib.h> | ||
43 | #include <stdio.h> | ||
44 | #include <unistd.h> | ||
45 | |||
46 | |||
47 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | ||
48 | : QLabel( parent ) | ||
49 | { | ||
50 | mAlarmDialog = new AlarmDialog( 0 ); | ||
51 | mPopUp = new QPopupMenu( 0 ); | ||
52 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); | ||
53 | mPopUp->insertSeparator(); | ||
54 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); | ||
55 | mPopUp->insertSeparator(); | ||
56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); | ||
57 | mPopUp->insertSeparator(); | ||
58 | mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); | ||
59 | mPopUp->insertSeparator(); | ||
60 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); | ||
61 | mPopUp->insertSeparator(); | ||
62 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); | ||
63 | mPopUp->insertSeparator(); | ||
64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); | ||
65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); | ||
66 | mTimerPopUp = new QPopupMenu( mPopUp ); | ||
67 | |||
68 | mBeepPopUp = new QPopupMenu( mPopUp ); | ||
69 | mSoundPopUp = new QPopupMenu( mBeepPopUp ); | ||
70 | mPausePopUp = new QPopupMenu( mBeepPopUp ); | ||
71 | QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp ); | ||
72 | savePopUp->insertItem( "Save", 0 ); | ||
73 | savePopUp->insertItem( "Load", 1 ); | ||
74 | mSoundPopUp->insertItem( "Buzzer", 0 ); | ||
75 | mSoundPopUp->insertItem( "Wav file", 1 ); | ||
76 | mPausePopUp->insertItem( " 1 sec", 1 ); | ||
77 | mPausePopUp->insertItem( " 2 sec", 2 ); | ||
78 | mPausePopUp->insertItem( " 3 sec", 3 ); | ||
79 | mPausePopUp->insertItem( " 5 sec", 5 ); | ||
80 | mPausePopUp->insertItem( "10 sec", 10 ); | ||
81 | mPausePopUp->insertItem( "30 sec", 30 ); | ||
82 | mPausePopUp->insertItem( " 1 min", 60 ); | ||
83 | mPausePopUp->insertItem( " 5 min", 300 ); | ||
84 | mPausePopUp->insertItem( "10 min", 600 ); | ||
85 | mSuspendPopUp = new QPopupMenu( mBeepPopUp ); | ||
86 | mSuspendPopUp->insertItem( "Off", 0 ); | ||
87 | mSuspendPopUp->insertItem( " 1x", 1 ); | ||
88 | mSuspendPopUp->insertItem( " 2x", 2 ); | ||
89 | mSuspendPopUp->insertItem( " 3x", 3 ); | ||
90 | mSuspendPopUp->insertItem( " 5x", 5 ); | ||
91 | mSuspendPopUp->insertItem( "10x", 10 ); | ||
92 | mSuspendPopUp->insertItem( "20x", 20 ); | ||
93 | mSuspendPopUp->insertItem( "30x", 30 ); | ||
94 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | ||
95 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | ||
96 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | ||
97 | mBeepPopUp->insertItem( "Config",savePopUp ); | ||
98 | mBeepPopUp->insertItem( "300", 300 ); | ||
99 | mBeepPopUp->insertItem( "180", 180 ); | ||
100 | mBeepPopUp->insertItem( "60", 60 ); | ||
101 | mBeepPopUp->insertItem( "30", 30 ); | ||
102 | mBeepPopUp->insertItem( "10", 10 ); | ||
103 | mBeepPopUp->insertItem( "3", 3 ); | ||
104 | mBeepPopUp->insertItem( "1", 1 ); | ||
105 | mBeepPopUp->insertItem( "Off", 0 ); | ||
106 | mBeepPopUp->setCheckable( true ); | ||
107 | mPopUp->insertSeparator(); | ||
108 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); | ||
109 | mPopUp->insertSeparator(); | ||
110 | mPopUp->insertItem( "Timer", mTimerPopUp ); | ||
111 | mPopUp->insertSeparator(); | ||
112 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | ||
113 | |||
114 | mPopUp->resize( mPopUp->sizeHint() ); | ||
115 | mPlayBeeps = 60; | ||
116 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | ||
117 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | ||
118 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | ||
119 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | ||
120 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | ||
121 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | ||
122 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | ||
123 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | ||
124 | mTimerTime = 0; | ||
125 | mCustomText = "Custom Text"; | ||
126 | mCustomMinutes = 7; | ||
127 | mTimerPopupConf = 1; | ||
128 | fillTimerPopUp(); | ||
129 | mPausePlay = 0; | ||
130 | confPause( 1 ); | ||
131 | mSuspend = 0; | ||
132 | confSuspend( 0 ); | ||
133 | if ( QApplication::desktop()->width() < 480 ) { | ||
134 | wavAlarm = false; | ||
135 | mSoundPopUp->setItemChecked ( 0, true ); | ||
136 | } | ||
137 | else { | ||
138 | wavAlarm = true; | ||
139 | mSoundPopUp->setItemChecked ( 1, true ); | ||
140 | } | ||
141 | saveSlot( 1 ); | ||
142 | } | ||
143 | |||
144 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | ||
145 | { | ||
146 | delete mPopUp; | ||
147 | delete mAlarmDialog; | ||
148 | } | ||
149 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | ||
150 | { | ||
151 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | ||
152 | //qDebug("save %d ", load ); | ||
153 | QFile file( fileName ); | ||
154 | if ( load ) { | ||
155 | if( !QFile::exists( fileName) ) | ||
156 | return; | ||
157 | if (!file.open( IO_ReadOnly ) ) { | ||
158 | return ; | ||
159 | } | ||
160 | QString line; | ||
161 | bool ok; | ||
162 | int val; | ||
163 | int len; | ||
164 | while ( file.readLine( line, 1024 ) > 0 ) { | ||
165 | //qDebug("read %s ", line.latin1()); | ||
166 | len = line.length(); | ||
167 | if ( line.left(4 ) == "PPAU" ) { | ||
168 | val = line.mid( 4,len-5).toInt( &ok ); | ||
169 | if ( ok ) { | ||
170 | confPause( val ); | ||
171 | } | ||
172 | } | ||
173 | if ( line.left(4 ) == "SUCO" ) { | ||
174 | val = line.mid( 4,len-5).toInt( &ok ); | ||
175 | if ( ok ) | ||
176 | confSuspend ( val ); | ||
177 | } | ||
178 | if ( line.left(4 ) == "WAAL" ) { | ||
179 | val = line.mid( 4,len-5).toInt( &ok ); | ||
180 | if ( ok ) | ||
181 | confSound( val ); | ||
182 | |||
183 | } | ||
184 | if ( line.left(4 ) == "PLBE" ) { | ||
185 | val = line.mid( 4,len-5).toInt( &ok ); | ||
186 | if ( ok ) | ||
187 | slotPlayBeep( val ); | ||
188 | |||
189 | } | ||
190 | if ( line.left(4 ) == "CUTE" ) { | ||
191 | mCustomText = line.mid( 5,len-6); | ||
192 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | ||
193 | |||
194 | } | ||
195 | if ( line.left(4 ) == "CUMI" ) { | ||
196 | val = line.mid( 4,len-5).toInt( &ok ); | ||
197 | if ( ok ) | ||
198 | mCustomMinutes = val; | ||
199 | |||
200 | } | ||
201 | if ( line.left(4 ) == "SUTI" ) { | ||
202 | val = line.mid( 4,len-5).toInt( &ok ); | ||
203 | if ( ok ) | ||
204 | mAlarmDialog->setSuspendTime( val );; | ||
205 | |||
206 | } | ||
207 | } | ||
208 | file.close(); | ||
209 | } else { | ||
210 | if (!file.open( IO_WriteOnly ) ) { | ||
211 | return; | ||
212 | } | ||
213 | QString configString ; | ||
214 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | ||
215 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | ||
216 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | ||
217 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | ||
218 | configString += "CUTE " + mCustomText + "\n"; | ||
219 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | ||
220 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | ||
221 | QTextStream ts( &file ); | ||
222 | ts << configString ; | ||
223 | file.close(); | ||
224 | } | ||
225 | |||
226 | } | ||
227 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | ||
228 | { | ||
229 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | ||
230 | mSuspend = num; | ||
231 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | ||
232 | } | ||
233 | void SimpleAlarmDaemonImpl::confPause( int num ) | ||
234 | { | ||
235 | mPausePopUp->setItemChecked ( mPausePlay,false ); | ||
236 | mPausePlay = num; | ||
237 | mPausePopUp->setItemChecked ( mPausePlay,true ); | ||
238 | } | ||
239 | void SimpleAlarmDaemonImpl::confSound( int num ) | ||
240 | { | ||
241 | if ( num == 0 ) { | ||
242 | wavAlarm = false; | ||
243 | mSoundPopUp->setItemChecked ( 0, true ); | ||
244 | mSoundPopUp->setItemChecked ( 1, false ); | ||
245 | } else { | ||
246 | wavAlarm = true; | ||
247 | mSoundPopUp->setItemChecked ( 0, false ); | ||
248 | mSoundPopUp->setItemChecked ( 1, true ); | ||
249 | } | ||
250 | } | ||
251 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | ||
252 | { | ||
253 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | ||
254 | mPlayBeeps = num; | ||
255 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | ||
256 | } | ||
257 | |||
258 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | ||
259 | { | ||
260 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | ||
261 | QString mess = msg; | ||
262 | mAlarmMessage = mess.mid( 9 ); | ||
263 | QString filename = getenv("QPEDIR") ; | ||
264 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | ||
265 | QString tempfilename; | ||
266 | if ( mess.left( 13 ) == "suspend_alarm") { | ||
267 | bool error = false; | ||
268 | int len = mess.mid( 13 ).find("+++"); | ||
269 | if ( len < 2 ) | ||
270 | error = true; | ||
271 | else { | ||
272 | tempfilename = mess.mid( 13, len ); | ||
273 | if ( !QFile::exists( tempfilename ) ) | ||
274 | error = true; | ||
275 | } | ||
276 | if ( ! error ) { | ||
277 | filename = tempfilename; | ||
278 | } | ||
279 | mAlarmMessage = mess.mid( 13+len+3 ); | ||
280 | //qDebug("suspend file %s ",tempfilename.latin1() ); | ||
281 | startAlarm( mAlarmMessage, filename); | ||
282 | return; | ||
283 | } | ||
284 | if ( mess.left( 11 ) == "timer_alarm") { | ||
285 | mTimerTime = 0; | ||
286 | startAlarm( mess.mid( 11 ), filename ); | ||
287 | return; | ||
288 | } | ||
289 | if ( mess.left( 10 ) == "proc_alarm") { | ||
290 | bool error = false; | ||
291 | int len = mess.mid( 10 ).find("+++"); | ||
292 | if ( len < 2 ) | ||
293 | error = true; | ||
294 | else { | ||
295 | tempfilename = mess.mid( 10, len ); | ||
296 | if ( !QFile::exists( tempfilename ) ) | ||
297 | error = true; | ||
298 | } | ||
299 | if ( error ) { | ||
300 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | ||
301 | mAlarmMessage += mess.mid( 10+len+3+9 ); | ||
302 | } else { | ||
303 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | ||
304 | //qDebug("-----system command %s ",tempfilename.latin1() ); | ||
305 | if ( vfork () == 0 ) { | ||
306 | execl ( tempfilename.latin1(), 0 ); | ||
307 | return; | ||
308 | } | ||
309 | return; | ||
310 | } | ||
311 | |||
312 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | ||
313 | } | ||
314 | if ( mess.left( 11 ) == "audio_alarm") { | ||
315 | bool error = false; | ||
316 | int len = mess.mid( 11 ).find("+++"); | ||
317 | if ( len < 2 ) | ||
318 | error = true; | ||
319 | else { | ||
320 | tempfilename = mess.mid( 11, len ); | ||
321 | if ( !QFile::exists( tempfilename ) ) | ||
322 | error = true; | ||
323 | } | ||
324 | if ( ! error ) { | ||
325 | filename = tempfilename; | ||
326 | } | ||
327 | mAlarmMessage = mess.mid( 11+len+3+9 ); | ||
328 | //qDebug("audio file command %s ",tempfilename.latin1() ); | ||
329 | } | ||
330 | if ( mess.left( 9 ) == "cal_alarm") { | ||
331 | mAlarmMessage = mess.mid( 9 ) ; | ||
332 | } | ||
333 | |||
334 | writeFile(); | ||
335 | startAlarm( mAlarmMessage, filename ); | ||
336 | |||
337 | } | ||
338 | |||
339 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | ||
340 | { | ||
341 | return 0; | ||
342 | } | ||
343 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | ||
344 | { | ||
345 | //mAlarmDialog->show(); | ||
346 | //mAlarmDialog->raise(); | ||
347 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | ||
348 | } | ||
349 | |||
350 | |||
351 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | ||
352 | { | ||
353 | |||
354 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | ||
355 | if ( mTimerPopupConf == mTimerTime ) { | ||
356 | if ( mTimerTime ) { | ||
357 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | ||
358 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | ||
359 | mTimerPopUp->changeItem ( 1 , t.toString()); | ||
360 | } | ||
361 | else { | ||
362 | QString text = mCustomText.stripWhiteSpace (); | ||
363 | int in = text.find( " " ); | ||
364 | text = text.left ( in ); | ||
365 | mTimerPopUp->changeItem ( 3, text ); | ||
366 | } | ||
367 | return; | ||
368 | } | ||
369 | mTimerPopupConf = mTimerTime; | ||
370 | mTimerPopUp->clear(); | ||
371 | if ( mTimerTime ) { | ||
372 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | ||
373 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | ||
374 | mTimerPopUp->insertItem( "Stop", 0 ); | ||
375 | mTimerPopUp->insertItem( t.toString(),1); | ||
376 | } else { | ||
377 | mTimerPopUp->insertItem( "24 h", 1440 ); | ||
378 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | ||
379 | mTimerPopUp->insertItem( " 8 h", 480 ); | ||
380 | mTimerPopUp->insertItem( " 5 h", 300 ); | ||
381 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | ||
382 | mTimerPopUp->insertItem( " 1 h", 60 ); | ||
383 | mTimerPopUp->insertItem( "30 min", 30 ); | ||
384 | mTimerPopUp->insertItem( "15 min", 15 ); | ||
385 | mTimerPopUp->insertItem( "10 min", 10 ); | ||
386 | //mTimerPopUp->insertItem( " 5 min", 5 ); | ||
387 | mTimerPopUp->insertSeparator(); | ||
388 | mTimerPopUp->insertItem( "Pizza", 22 ); | ||
389 | mTimerPopUp->insertItem( "Nap", 45 ); | ||
390 | mTimerPopUp->insertItem( "Tea", 5 ); | ||
391 | QString text = mCustomText.stripWhiteSpace (); | ||
392 | int in = text.find( " " ); | ||
393 | text = text.left ( in ); | ||
394 | mTimerPopUp->insertItem( text, 3 ); | ||
395 | mTimerPopUp->insertSeparator(); | ||
396 | mTimerPopUp->insertItem( "Customize", 2 ); | ||
397 | } | ||
398 | |||
399 | } | ||
400 | |||
401 | void SimpleAlarmDaemonImpl::showTimer() | ||
402 | { | ||
403 | fillTimerPopUp(); | ||
404 | } | ||
405 | |||
406 | void SimpleAlarmDaemonImpl::confTimer( int time ) | ||
407 | { | ||
408 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | ||
409 | int minutes = time; | ||
410 | if ( minutes == 0 ) { | ||
411 | if ( ! mTimerTime ) | ||
412 | return; | ||
413 | |||
414 | QDialog dia ( 0, ("Stop Timer" ), true ); | ||
415 | QLabel lab (("Really stop the timer?"), &dia ); | ||
416 | dia.setCaption(("KO/Pi Timer Stop" )); | ||
417 | QVBoxLayout lay( &dia ); | ||
418 | lay.setMargin(5); | ||
419 | lay.setSpacing(5); | ||
420 | lay.addWidget( &lab); | ||
421 | dia.resize( 200, dia.sizeHint().height() ); | ||
422 | |||
423 | if ( !dia.exec() ) | ||
424 | return; | ||
425 | |||
426 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | ||
427 | mTimerTime = 0; | ||
428 | return; | ||
429 | } | ||
430 | if ( mTimerTime ) | ||
431 | return; | ||
432 | if ( minutes == 1 ) { | ||
433 | return; | ||
434 | } | ||
435 | QString mess = "timer_alarm"; | ||
436 | mess += ("Timer Alarm!\n"); | ||
437 | if ( minutes == 22 ) | ||
438 | mess += ( "Pizza is ready"); | ||
439 | else if ( minutes == 45 ) | ||
440 | mess += ( "Please wake up!"); | ||
441 | else if ( minutes == 5 ) | ||
442 | mess += ( "Tea is ready"); | ||
443 | else if ( minutes == 3 ) { | ||
444 | mess += mCustomText; | ||
445 | minutes = mCustomMinutes ; | ||
446 | } | ||
447 | else { | ||
448 | if ( minutes == 2 ) { | ||
449 | // ask time | ||
450 | QDialog dia ( 0, ("Customize Timer" ), true ); | ||
451 | QLabel lab (("Message Text:"), &dia ); | ||
452 | dia.setCaption(("KO/Pi Timer" )); | ||
453 | QVBoxLayout lay( &dia ); | ||
454 | lay.setMargin(5); | ||
455 | lay.setSpacing(5); | ||
456 | lay.addWidget( &lab); | ||
457 | QLineEdit lEdit( mCustomText, &dia ); | ||
458 | lay.addWidget( &lEdit); | ||
459 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | ||
460 | lay.addWidget( &lab2); | ||
461 | QHBox hbox ( &dia ); | ||
462 | QLabel lab3 (("h:"), &hbox ); | ||
463 | QSpinBox spinh( 0, 24, 1,& hbox ); | ||
464 | QLabel lab4 ((" min:"), &hbox ); | ||
465 | QSpinBox spinm( 0, 59, 1,&hbox ); | ||
466 | spinh.setValue( mCustomMinutes/60 ); | ||
467 | spinm.setValue( mCustomMinutes%60 ); | ||
468 | lay.addWidget( &hbox); | ||
469 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | ||
470 | if ( !dia.exec() ) | ||
471 | return; | ||
472 | mCustomText = lEdit.text(); | ||
473 | mCustomMinutes = spinh.value()*60+spinm.value(); | ||
474 | if ( mCustomMinutes == 0 ) | ||
475 | mCustomMinutes = 1; | ||
476 | if ( mCustomMinutes > 1440 ) | ||
477 | mCustomMinutes = 1440; | ||
478 | mess += mCustomText; | ||
479 | minutes = mCustomMinutes; | ||
480 | } | ||
481 | else | ||
482 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | ||
483 | } | ||
484 | //minutes = 1; | ||
485 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | ||
486 | timerMesssage = mess; | ||
487 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); | ||
488 | mTimerTime = 1; | ||
489 | } | ||
490 | |||
491 | void SimpleAlarmDaemonImpl::writeFile() | ||
492 | { | ||
493 | QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | ||
494 | } | ||
495 | void SimpleAlarmDaemonImpl::showWN() | ||
496 | { | ||
497 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | ||
498 | } | ||
499 | void SimpleAlarmDaemonImpl::newTodo() | ||
500 | { | ||
501 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | ||
502 | } | ||
503 | |||
504 | void SimpleAlarmDaemonImpl::newEvent() | ||
505 | { | ||
506 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | ||
507 | |||
508 | } | ||
509 | |||
510 | void SimpleAlarmDaemonImpl::showAdd() | ||
511 | { | ||
512 | QCopEnvelope e("QPE/Application/kapi", " "); | ||
513 | } | ||
514 | void SimpleAlarmDaemonImpl::ringSync() | ||
515 | { | ||
516 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | ||
517 | |||
518 | } | ||
519 | void SimpleAlarmDaemonImpl::newCountdown() | ||
520 | { | ||
521 | //recieve("cal_alarm", 10 ); | ||
522 | } | ||
523 | void SimpleAlarmDaemonImpl::simulate() | ||
524 | { | ||
525 | writeFile(); | ||
526 | QString filename = getenv("QPEDIR") ; | ||
527 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | ||
528 | startAlarm("Alarm simulation", filename ); | ||
529 | } | ||
530 | void SimpleAlarmDaemonImpl::showKO() | ||
531 | { | ||
532 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | ||
533 | |||
534 | } | ||
535 | void SimpleAlarmDaemonImpl::showTodo() | ||
536 | { | ||
537 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | ||
538 | |||
539 | } | ||
540 | void SimpleAlarmDaemonImpl::writeJournal() | ||
541 | { | ||
542 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | ||
543 | |||
544 | } | ||
545 | |||
546 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | ||
547 | { | ||
548 | |||
549 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | ||
550 | |||
551 | } | ||
552 | |||