summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
authorzautrix <zautrix>2005-09-18 23:40:38 (UTC)
committer zautrix <zautrix>2005-09-18 23:40:38 (UTC)
commit2d346e4052fd726e657daee4ac3f2bcc7103f5fb (patch) (unidiff)
tree9952b888e0790bc032ba4e0c3c4165ec283a4139 /kalarmd/simplealarmdaemonimpl.cpp
parent06ebec95579816144ee65981835e6e3482e20a28 (diff)
downloadkdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.zip
kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.gz
kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.bz2
wn
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index a0ac232..8ea8a73 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -6,128 +6,133 @@
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;
@@ -252,155 +257,155 @@ void SimpleAlarmDaemonImpl::confSound( int num )
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";
@@ -581,94 +586,94 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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