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