summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
Unidiff
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 18e4299..4ff6861 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -51,557 +51,557 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
51 mPopUp = new QPopupMenu( 0 ); 51 mPopUp = new QPopupMenu( 0 );
52 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); 52 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
53 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); 53 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
54 mPopUp->insertSeparator(); 54 mPopUp->insertSeparator();
55 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); 55 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) );
56 mPopUp->insertSeparator(); 56 mPopUp->insertSeparator();
57 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); 57 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
58 mPopUp->insertSeparator(); 58 mPopUp->insertSeparator();
59 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); 59 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
60 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); 60 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
61 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); 61 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
62 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); 62 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) );
63 mPopUp->insertSeparator(); 63 mPopUp->insertSeparator();
64 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); 64 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
65 mTimerPopUp = new QPopupMenu( mPopUp ); 65 mTimerPopUp = new QPopupMenu( mPopUp );
66 66
67 mBeepPopUp = new QPopupMenu( mPopUp ); 67 mBeepPopUp = new QPopupMenu( mPopUp );
68 mSoundPopUp = new QPopupMenu( mBeepPopUp ); 68 mSoundPopUp = new QPopupMenu( mBeepPopUp );
69 mPausePopUp = new QPopupMenu( mBeepPopUp ); 69 mPausePopUp = new QPopupMenu( mBeepPopUp );
70 QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp ); 70 QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp );
71 savePopUp->insertItem( "Save", 0 ); 71 savePopUp->insertItem( "Save", 0 );
72 savePopUp->insertItem( "Load", 1 ); 72 savePopUp->insertItem( "Load", 1 );
73 mSoundPopUp->insertItem( "Buzzer", 0 ); 73 mSoundPopUp->insertItem( "Buzzer", 0 );
74 mSoundPopUp->insertItem( "Wav file", 1 ); 74 mSoundPopUp->insertItem( "Wav file", 1 );
75 mPausePopUp->insertItem( " 1 sec", 1 ); 75 mPausePopUp->insertItem( " 1 sec", 1 );
76 mPausePopUp->insertItem( " 2 sec", 2 ); 76 mPausePopUp->insertItem( " 2 sec", 2 );
77 mPausePopUp->insertItem( " 3 sec", 3 ); 77 mPausePopUp->insertItem( " 3 sec", 3 );
78 mPausePopUp->insertItem( " 5 sec", 5 ); 78 mPausePopUp->insertItem( " 5 sec", 5 );
79 mPausePopUp->insertItem( "10 sec", 10 ); 79 mPausePopUp->insertItem( "10 sec", 10 );
80 mPausePopUp->insertItem( "30 sec", 30 ); 80 mPausePopUp->insertItem( "30 sec", 30 );
81 mPausePopUp->insertItem( " 1 min", 60 ); 81 mPausePopUp->insertItem( " 1 min", 60 );
82 mPausePopUp->insertItem( " 5 min", 300 ); 82 mPausePopUp->insertItem( " 5 min", 300 );
83 mPausePopUp->insertItem( "10 min", 600 ); 83 mPausePopUp->insertItem( "10 min", 600 );
84 mSuspendPopUp = new QPopupMenu( mBeepPopUp ); 84 mSuspendPopUp = new QPopupMenu( mBeepPopUp );
85 mSuspendPopUp->insertItem( "Off", 0 ); 85 mSuspendPopUp->insertItem( "Off", 0 );
86 mSuspendPopUp->insertItem( " 1x", 1 ); 86 mSuspendPopUp->insertItem( " 1x", 1 );
87 mSuspendPopUp->insertItem( " 2x", 2 ); 87 mSuspendPopUp->insertItem( " 2x", 2 );
88 mSuspendPopUp->insertItem( " 3x", 3 ); 88 mSuspendPopUp->insertItem( " 3x", 3 );
89 mSuspendPopUp->insertItem( " 5x", 5 ); 89 mSuspendPopUp->insertItem( " 5x", 5 );
90 mSuspendPopUp->insertItem( "10x", 10 ); 90 mSuspendPopUp->insertItem( "10x", 10 );
91 mSuspendPopUp->insertItem( "20x", 20 ); 91 mSuspendPopUp->insertItem( "20x", 20 );
92 mSuspendPopUp->insertItem( "30x", 30 ); 92 mSuspendPopUp->insertItem( "30x", 30 );
93 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 93 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
94 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 94 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
95 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 95 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
96 mBeepPopUp->insertItem( "Config",savePopUp ); 96 mBeepPopUp->insertItem( "Config",savePopUp );
97 mBeepPopUp->insertItem( "300", 300 ); 97 mBeepPopUp->insertItem( "300", 300 );
98 mBeepPopUp->insertItem( "180", 180 ); 98 mBeepPopUp->insertItem( "180", 180 );
99 mBeepPopUp->insertItem( "60", 60 ); 99 mBeepPopUp->insertItem( "60", 60 );
100 mBeepPopUp->insertItem( "30", 30 ); 100 mBeepPopUp->insertItem( "30", 30 );
101 mBeepPopUp->insertItem( "10", 10 ); 101 mBeepPopUp->insertItem( "10", 10 );
102 mBeepPopUp->insertItem( "3", 3 ); 102 mBeepPopUp->insertItem( "3", 3 );
103 mBeepPopUp->insertItem( "1", 1 ); 103 mBeepPopUp->insertItem( "1", 1 );
104 mBeepPopUp->insertItem( "Off", 0 ); 104 mBeepPopUp->insertItem( "Off", 0 );
105 mBeepPopUp->setCheckable( true ); 105 mBeepPopUp->setCheckable( true );
106 mPopUp->insertSeparator(); 106 mPopUp->insertSeparator();
107 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 107 mPopUp->insertItem( "Play beeps", mBeepPopUp );
108 mPopUp->insertSeparator(); 108 mPopUp->insertSeparator();
109 mPopUp->insertItem( "Timer", mTimerPopUp ); 109 mPopUp->insertItem( "Timer", mTimerPopUp );
110 mPopUp->insertSeparator(); 110 mPopUp->insertSeparator();
111 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 111 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
112 112
113 mPopUp->resize( mPopUp->sizeHint() ); 113 mPopUp->resize( mPopUp->sizeHint() );
114 mPlayBeeps = 60; 114 mPlayBeeps = 60;
115 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 115 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
116 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 116 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
117 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 117 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
118 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 118 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
119 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 119 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
120 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 120 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
121 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 121 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
122 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 122 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
123 mTimerTime = 0; 123 mTimerTime = 0;
124 mCustomText = "Custom Text"; 124 mCustomText = "Custom Text";
125 mCustomMinutes = 7; 125 mCustomMinutes = 7;
126 mTimerPopupConf = 1; 126 mTimerPopupConf = 1;
127 fillTimerPopUp(); 127 fillTimerPopUp();
128 mPausePlay = 0; 128 mPausePlay = 0;
129 confPause( 1 ); 129 confPause( 1 );
130 mSuspend = 0; 130 mSuspend = 0;
131 confSuspend( 0 ); 131 confSuspend( 0 );
132 if ( QApplication::desktop()->width() < 480 ) { 132 if ( QApplication::desktop()->width() < 480 ) {
133 wavAlarm = false; 133 wavAlarm = false;
134 mSoundPopUp->setItemChecked ( 0, true ); 134 mSoundPopUp->setItemChecked ( 0, true );
135 } 135 }
136 else { 136 else {
137 wavAlarm = true; 137 wavAlarm = true;
138 mSoundPopUp->setItemChecked ( 1, true ); 138 mSoundPopUp->setItemChecked ( 1, true );
139 } 139 }
140 saveSlot( 1 ); 140 saveSlot( 1 );
141} 141}
142 142
143SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 143SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
144{ 144{
145 delete mPopUp; 145 delete mPopUp;
146 delete mAlarmDialog; 146 delete mAlarmDialog;
147} 147}
148void SimpleAlarmDaemonImpl::saveSlot( int load ) 148void SimpleAlarmDaemonImpl::saveSlot( int load )
149{ 149{
150 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 150 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
151 //qDebug("save %d ", load ); 151 //qDebug("save %d ", load );
152 QFile file( fileName ); 152 QFile file( fileName );
153 if ( load ) { 153 if ( load ) {
154 if( !QFile::exists( fileName) ) 154 if( !QFile::exists( fileName) )
155 return; 155 return;
156 if (!file.open( IO_ReadOnly ) ) { 156 if (!file.open( IO_ReadOnly ) ) {
157 return ; 157 return ;
158 } 158 }
159 QString line; 159 QString line;
160 bool ok; 160 bool ok;
161 int val; 161 int val;
162 int len; 162 int len;
163 while ( file.readLine( line, 1024 ) > 0 ) { 163 while ( file.readLine( line, 1024 ) > 0 ) {
164 //qDebug("read %s ", line.latin1()); 164 //qDebug("read %s ", line.latin1());
165 len = line.length(); 165 len = line.length();
166 if ( line.left(4 ) == "PPAU" ) { 166 if ( line.left(4 ) == "PPAU" ) {
167 val = line.mid( 4,len-5).toInt( &ok ); 167 val = line.mid( 4,len-5).toInt( &ok );
168 if ( ok ) { 168 if ( ok ) {
169 confPause( val ); 169 confPause( val );
170 } 170 }
171 } 171 }
172 if ( line.left(4 ) == "SUCO" ) { 172 if ( line.left(4 ) == "SUCO" ) {
173 val = line.mid( 4,len-5).toInt( &ok ); 173 val = line.mid( 4,len-5).toInt( &ok );
174 if ( ok ) 174 if ( ok )
175 confSuspend ( val ); 175 confSuspend ( val );
176 } 176 }
177 if ( line.left(4 ) == "WAAL" ) { 177 if ( line.left(4 ) == "WAAL" ) {
178 val = line.mid( 4,len-5).toInt( &ok ); 178 val = line.mid( 4,len-5).toInt( &ok );
179 if ( ok ) 179 if ( ok )
180 confSound( val ); 180 confSound( val );
181 181
182 } 182 }
183 if ( line.left(4 ) == "PLBE" ) { 183 if ( line.left(4 ) == "PLBE" ) {
184 val = line.mid( 4,len-5).toInt( &ok ); 184 val = line.mid( 4,len-5).toInt( &ok );
185 if ( ok ) 185 if ( ok )
186 slotPlayBeep( val ); 186 slotPlayBeep( val );
187 187
188 } 188 }
189 if ( line.left(4 ) == "CUTE" ) { 189 if ( line.left(4 ) == "CUTE" ) {
190 mCustomText = line.mid( 5,len-6); 190 mCustomText = line.mid( 5,len-6);
191 // qDebug("text ***%s*** ",mCustomText.latin1() ); 191 // qDebug("text ***%s*** ",mCustomText.latin1() );
192 192
193 } 193 }
194 if ( line.left(4 ) == "CUMI" ) { 194 if ( line.left(4 ) == "CUMI" ) {
195 val = line.mid( 4,len-5).toInt( &ok ); 195 val = line.mid( 4,len-5).toInt( &ok );
196 if ( ok ) 196 if ( ok )
197 mCustomMinutes = val; 197 mCustomMinutes = val;
198 198
199 } 199 }
200 if ( line.left(4 ) == "SUTI" ) { 200 if ( line.left(4 ) == "SUTI" ) {
201 val = line.mid( 4,len-5).toInt( &ok ); 201 val = line.mid( 4,len-5).toInt( &ok );
202 if ( ok ) 202 if ( ok )
203 mAlarmDialog->setSuspendTime( val );; 203 mAlarmDialog->setSuspendTime( val );;
204 204
205 } 205 }
206 } 206 }
207 file.close(); 207 file.close();
208 } else { 208 } else {
209 if (!file.open( IO_WriteOnly ) ) { 209 if (!file.open( IO_WriteOnly ) ) {
210 return; 210 return;
211 } 211 }
212 QString configString ; 212 QString configString ;
213 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 213 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
214 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 214 configString += "SUCO " + QString::number( mSuspend ) + "\n";
215 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 215 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
216 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 216 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
217 configString += "CUTE " + mCustomText + "\n"; 217 configString += "CUTE " + mCustomText + "\n";
218 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 218 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
219 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 219 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
220 QTextStream ts( &file ); 220 QTextStream ts( &file );
221 ts << configString ; 221 ts << configString ;
222 file.close(); 222 file.close();
223 } 223 }
224 224
225} 225}
226void SimpleAlarmDaemonImpl::confSuspend( int num ) 226void SimpleAlarmDaemonImpl::confSuspend( int num )
227{ 227{
228 mSuspendPopUp->setItemChecked ( mSuspend,false ); 228 mSuspendPopUp->setItemChecked ( mSuspend,false );
229 mSuspend = num; 229 mSuspend = num;
230 mSuspendPopUp->setItemChecked ( mSuspend,true ); 230 mSuspendPopUp->setItemChecked ( mSuspend,true );
231} 231}
232void SimpleAlarmDaemonImpl::confPause( int num ) 232void SimpleAlarmDaemonImpl::confPause( int num )
233{ 233{
234 mPausePopUp->setItemChecked ( mPausePlay,false ); 234 mPausePopUp->setItemChecked ( mPausePlay,false );
235 mPausePlay = num; 235 mPausePlay = num;
236 mPausePopUp->setItemChecked ( mPausePlay,true ); 236 mPausePopUp->setItemChecked ( mPausePlay,true );
237} 237}
238void SimpleAlarmDaemonImpl::confSound( int num ) 238void SimpleAlarmDaemonImpl::confSound( int num )
239{ 239{
240 if ( num == 0 ) { 240 if ( num == 0 ) {
241 wavAlarm = false; 241 wavAlarm = false;
242 mSoundPopUp->setItemChecked ( 0, true ); 242 mSoundPopUp->setItemChecked ( 0, true );
243 mSoundPopUp->setItemChecked ( 1, false ); 243 mSoundPopUp->setItemChecked ( 1, false );
244 } else { 244 } else {
245 wavAlarm = true; 245 wavAlarm = true;
246 mSoundPopUp->setItemChecked ( 0, false ); 246 mSoundPopUp->setItemChecked ( 0, false );
247 mSoundPopUp->setItemChecked ( 1, true ); 247 mSoundPopUp->setItemChecked ( 1, true );
248 } 248 }
249} 249}
250void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 250void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
251{ 251{
252 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 252 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
253 mPlayBeeps = num; 253 mPlayBeeps = num;
254 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 254 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
255} 255}
256 256
257void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 257void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
258{ 258{
259 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 259 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
260 QString mess = msg; 260 QString mess = msg;
261 mAlarmMessage = mess.mid( 9 ); 261 mAlarmMessage = mess.mid( 9 );
262 QString filename = getenv("QPEDIR") ; 262 QString filename = getenv("QPEDIR") ;
263 filename += "/pics/kdepim/korganizer/koalarm.wav"; 263 filename += "/pics/kdepim/korganizer/koalarm.wav";
264 QString tempfilename; 264 QString tempfilename;
265 if ( mess.left( 13 ) == "suspend_alarm") { 265 if ( mess.left( 13 ) == "suspend_alarm") {
266 bool error = false; 266 bool error = false;
267 int len = mess.mid( 13 ).find("+++"); 267 int len = mess.mid( 13 ).find("+++");
268 if ( len < 2 ) 268 if ( len < 2 )
269 error = true; 269 error = true;
270 else { 270 else {
271 tempfilename = mess.mid( 13, len ); 271 tempfilename = mess.mid( 13, len );
272 if ( !QFile::exists( tempfilename ) ) 272 if ( !QFile::exists( tempfilename ) )
273 error = true; 273 error = true;
274 } 274 }
275 if ( ! error ) { 275 if ( ! error ) {
276 filename = tempfilename; 276 filename = tempfilename;
277 } 277 }
278 mAlarmMessage = mess.mid( 13+len+3 ); 278 mAlarmMessage = mess.mid( 13+len+3 );
279 //qDebug("suspend file %s ",tempfilename.latin1() ); 279 //qDebug("suspend file %s ",tempfilename.latin1() );
280 startAlarm( mAlarmMessage, filename); 280 startAlarm( mAlarmMessage, filename);
281 return; 281 return;
282 } 282 }
283 if ( mess.left( 11 ) == "timer_alarm") { 283 if ( mess.left( 11 ) == "timer_alarm") {
284 mTimerTime = 0; 284 mTimerTime = 0;
285 startAlarm( mess.mid( 11 ), filename ); 285 startAlarm( mess.mid( 11 ), filename );
286 return; 286 return;
287 } 287 }
288 if ( mess.left( 10 ) == "proc_alarm") { 288 if ( mess.left( 10 ) == "proc_alarm") {
289 bool error = false; 289 bool error = false;
290 int len = mess.mid( 10 ).find("+++"); 290 int len = mess.mid( 10 ).find("+++");
291 if ( len < 2 ) 291 if ( len < 2 )
292 error = true; 292 error = true;
293 else { 293 else {
294 tempfilename = mess.mid( 10, len ); 294 tempfilename = mess.mid( 10, len );
295 if ( !QFile::exists( tempfilename ) ) 295 if ( !QFile::exists( tempfilename ) )
296 error = true; 296 error = true;
297 } 297 }
298 if ( error ) { 298 if ( error ) {
299 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 299 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
300 mAlarmMessage += mess.mid( 10+len+3+9 ); 300 mAlarmMessage += mess.mid( 10+len+3+9 );
301 } else { 301 } else {
302 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 302 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
303 //qDebug("-----system command %s ",tempfilename.latin1() ); 303 //qDebug("-----system command %s ",tempfilename.latin1() );
304 if ( vfork () == 0 ) { 304 if ( vfork () == 0 ) {
305 execl ( tempfilename.latin1(), 0 ); 305 execl ( tempfilename.latin1(), 0 );
306 return; 306 return;
307 } 307 }
308 return; 308 return;
309 } 309 }
310 310
311 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 311 //qDebug("+++++++system command %s ",tempfilename.latin1() );
312 } 312 }
313 if ( mess.left( 11 ) == "audio_alarm") { 313 if ( mess.left( 11 ) == "audio_alarm") {
314 bool error = false; 314 bool error = false;
315 int len = mess.mid( 11 ).find("+++"); 315 int len = mess.mid( 11 ).find("+++");
316 if ( len < 2 ) 316 if ( len < 2 )
317 error = true; 317 error = true;
318 else { 318 else {
319 tempfilename = mess.mid( 11, len ); 319 tempfilename = mess.mid( 11, len );
320 if ( !QFile::exists( tempfilename ) ) 320 if ( !QFile::exists( tempfilename ) )
321 error = true; 321 error = true;
322 } 322 }
323 if ( ! error ) { 323 if ( ! error ) {
324 filename = tempfilename; 324 filename = tempfilename;
325 } 325 }
326 mAlarmMessage = mess.mid( 11+len+3+9 ); 326 mAlarmMessage = mess.mid( 11+len+3+9 );
327 //qDebug("audio file command %s ",tempfilename.latin1() ); 327 //qDebug("audio file command %s ",tempfilename.latin1() );
328 } 328 }
329 if ( mess.left( 9 ) == "cal_alarm") { 329 if ( mess.left( 9 ) == "cal_alarm") {
330 mAlarmMessage = mess.mid( 9 ) ; 330 mAlarmMessage = mess.mid( 9 ) ;
331 } 331 }
332 332
333 writeFile(); 333 writeFile();
334 startAlarm( mAlarmMessage, filename ); 334 startAlarm( mAlarmMessage, filename );
335 335
336} 336}
337 337
338int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 338int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
339{ 339{
340 return 0; 340 return 0;
341} 341}
342void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 342void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
343{ 343{
344 //mAlarmDialog->show(); 344 //mAlarmDialog->show();
345 //mAlarmDialog->raise(); 345 //mAlarmDialog->raise();
346 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 346 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
347} 347}
348 348
349 349
350void SimpleAlarmDaemonImpl::fillTimerPopUp() 350void SimpleAlarmDaemonImpl::fillTimerPopUp()
351{ 351{
352 352
353 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 353 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
354 if ( mTimerPopupConf == mTimerTime ) { 354 if ( mTimerPopupConf == mTimerTime ) {
355 if ( mTimerTime ) { 355 if ( mTimerTime ) {
356 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 356 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
357 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 357 QTime t ( secs/3600, (secs/60)%60, secs%60 );
358 mTimerPopUp->changeItem ( 1 , t.toString()); 358 mTimerPopUp->changeItem ( 1 , t.toString());
359 } 359 }
360 else { 360 else {
361 QString text = mCustomText.stripWhiteSpace (); 361 QString text = mCustomText.stripWhiteSpace ();
362 int in = text.find( " " ); 362 int in = text.find( " " );
363 text = text.left ( in ); 363 text = text.left ( in );
364 mTimerPopUp->changeItem ( 3, text ); 364 mTimerPopUp->changeItem ( 3, text );
365 } 365 }
366 return; 366 return;
367 } 367 }
368 mTimerPopupConf = mTimerTime; 368 mTimerPopupConf = mTimerTime;
369 mTimerPopUp->clear(); 369 mTimerPopUp->clear();
370 if ( mTimerTime ) { 370 if ( mTimerTime ) {
371 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 371 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
372 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 372 QTime t ( secs/3600, (secs/60)%60, secs%60 );
373 mTimerPopUp->insertItem( "Stop", 0 ); 373 mTimerPopUp->insertItem( "Stop", 0 );
374 mTimerPopUp->insertItem( t.toString(),1); 374 mTimerPopUp->insertItem( t.toString(),1);
375 } else { 375 } else {
376 376
377 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 377 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
378 QFile file( fileName ); 378 QFile file( fileName );
379 if( !QFile::exists( fileName) ) { 379 if( !QFile::exists( fileName) ) {
380 // write defaults 380 // write defaults
381 if (!file.open( IO_WriteOnly ) ) { 381 if (!file.open( IO_WriteOnly ) ) {
382 return; 382 return;
383 } 383 }
384 QString configString ; 384 QString configString ;
385 configString += "#config file for kopi alarm timer\n"; 385 configString += "#config file for kopi alarm timer\n";
386 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 386 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
387 configString += "#NOTE: minimum value for timer are 3 minutes!\n"; 387 configString += "#NOTE: minimum value for timer are 3 minutes!\n";
388 configString += "24 h; 1440\n"; 388 configString += "24 h; 1440\n";
389 configString += " 8 h; 480\n"; 389 configString += " 8 h; 480\n";
390 configString += " 5 h; 300\n"; 390 configString += " 5 h; 300\n";
391 configString += " 1 h; 60\n"; 391 configString += " 1 h; 60\n";
392 configString += "30 min; 30\n"; 392 configString += "30 min; 30\n";
393 configString += "15 min; 15\n"; 393 configString += "15 min; 15\n";
394 configString += "SEPARATOR\n"; 394 configString += "SEPARATOR\n";
395 configString += "Pizza; 22\n"; 395 configString += "Pizza; 22\n";
396 configString += "Nap; 45\n"; 396 configString += "Nap; 45\n";
397 configString += "Tea; 5\n"; 397 configString += "Tea; 5\n";
398 QTextStream ts( &file ); 398 QTextStream ts( &file );
399 ts << configString ; 399 ts << configString ;
400 file.close(); 400 file.close();
401 } 401 }
402 402
403 if (!file.open( IO_ReadOnly ) ) { 403 if (!file.open( IO_ReadOnly ) ) {
404 return ; 404 return ;
405 } 405 }
406 QString line; 406 QString line;
407 bool ok; 407 bool ok;
408 while ( file.readLine( line, 1024 ) > 0 ) { 408 while ( file.readLine( line, 1024 ) > 0 ) {
409 //qDebug("read %s ", line.latin1()); 409 //qDebug("read %s ", line.latin1());
410 if ( line.left(1 ) != "#" ) { 410 if ( line.left(1 ) != "#" ) {
411 // no comment 411 // no comment
412 if ( line.left(9 ) == "SEPARATOR" ) { 412 if ( line.left(9 ) == "SEPARATOR" ) {
413 mTimerPopUp->insertSeparator(); 413 mTimerPopUp->insertSeparator();
414 } else { 414 } else {
415 QStringList li = QStringList::split(";",line); 415 QStringList li = QStringList::split(";",line);
416 ok = false; 416 ok = false;
417 if ( li.count() == 2 ) { 417 if ( li.count() == 2 ) {
418 int val = li[1].toInt( &ok ); 418 int val = li[1].toInt( &ok );
419 if ( ok && val > 2 ) { 419 if ( ok && val > 2 ) {
420 mTimerPopUp->insertItem( li[0], val); 420 mTimerPopUp->insertItem( li[0], val);
421 } 421 }
422 } 422 }
423 } 423 }
424 } 424 }
425 } 425 }
426 file.close(); 426 file.close();
427#if 0 427#if 0
428 mTimerPopUp->insertItem( "24 h", 1440 ); 428 mTimerPopUp->insertItem( "24 h", 1440 );
429 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 429 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
430 mTimerPopUp->insertItem( " 8 h", 480 ); 430 mTimerPopUp->insertItem( " 8 h", 480 );
431 mTimerPopUp->insertItem( " 5 h", 300 ); 431 mTimerPopUp->insertItem( " 5 h", 300 );
432 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 432 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
433 mTimerPopUp->insertItem( " 1 h", 60 ); 433 mTimerPopUp->insertItem( " 1 h", 60 );
434 mTimerPopUp->insertItem( "30 min", 30 ); 434 mTimerPopUp->insertItem( "30 min", 30 );
435 mTimerPopUp->insertItem( "15 min", 15 ); 435 mTimerPopUp->insertItem( "15 min", 15 );
436 mTimerPopUp->insertItem( "10 min", 10 ); 436 mTimerPopUp->insertItem( "10 min", 10 );
437 //mTimerPopUp->insertItem( " 5 min", 5 ); 437 //mTimerPopUp->insertItem( " 5 min", 5 );
438 mTimerPopUp->insertSeparator(); 438 mTimerPopUp->insertSeparator();
439 mTimerPopUp->insertItem( "Pizza", 22 ); 439 mTimerPopUp->insertItem( "Pizza", 22 );
440 mTimerPopUp->insertItem( "Nap", 45 ); 440 mTimerPopUp->insertItem( "Nap", 45 );
441 mTimerPopUp->insertItem( "Tea", 5 ); 441 mTimerPopUp->insertItem( "Tea", 5 );
442#endif 442#endif
443 QString text = mCustomText.stripWhiteSpace (); 443 QString text = mCustomText.stripWhiteSpace ();
444 int in = text.find( " " ); 444 int in = text.find( " " );
445 text = text.left ( in ); 445 text = text.left ( in );
446 mTimerPopUp->insertItem( text, 3 ); 446 mTimerPopUp->insertItem( text, 3 );
447 mTimerPopUp->insertSeparator(); 447 mTimerPopUp->insertSeparator();
448 mTimerPopUp->insertItem( "Customize", 2 ); 448 mTimerPopUp->insertItem( "Customize", 2 );
449 } 449 }
450 450
451} 451}
452 452
453void SimpleAlarmDaemonImpl::showTimer() 453void SimpleAlarmDaemonImpl::showTimer()
454{ 454{
455 fillTimerPopUp(); 455 fillTimerPopUp();
456} 456}
457 457
458void SimpleAlarmDaemonImpl::confTimer( int time ) 458void SimpleAlarmDaemonImpl::confTimer( int time )
459{ 459{
460 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 460 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
461 int minutes = time; 461 int minutes = time;
462 if ( minutes == 0 ) { 462 if ( minutes == 0 ) {
463 if ( ! mTimerTime ) 463 if ( ! mTimerTime )
464 return; 464 return;
465 465
466 QDialog dia ( 0, ("Stop Timer" ), true ); 466 QDialog dia ( 0, ("Stop Timer" ), true );
467 QLabel lab (("Really stop the timer?"), &dia ); 467 QLabel lab (("Really stop the timer?"), &dia );
468 dia.setCaption(("KO/Pi Timer Stop" )); 468 dia.setCaption(("KO/Pi Timer Stop" ));
469 QVBoxLayout lay( &dia ); 469 QVBoxLayout lay( &dia );
470 lay.setMargin(5); 470 lay.setMargin(5);
471 lay.setSpacing(5); 471 lay.setSpacing(5);
472 lay.addWidget( &lab); 472 lay.addWidget( &lab);
473 dia.resize( 200, dia.sizeHint().height() ); 473 dia.resize( 200, dia.sizeHint().height() );
474 474
475 if ( !dia.exec() ) 475 if ( !dia.exec() )
476 return; 476 return;
477 477
478 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); 478 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() );
479 mTimerTime = 0; 479 mTimerTime = 0;
480 return; 480 return;
481 } 481 }
482 if ( mTimerTime ) 482 if ( mTimerTime )
483 return; 483 return;
484 if ( minutes == 1 ) { 484 if ( minutes == 1 ) {
485 return; 485 return;
486 } 486 }
487 QString mess = "timer_alarm"; 487 QString mess = "timer_alarm";
488 mess += ("Timer Alarm!\n"); 488 mess += ("Timer Alarm!\n");
489 if ( minutes == 22 ) 489 if ( minutes == 22 )
490 mess += ( "Pizza is ready"); 490 mess += ( "Pizza is ready");
491 else if ( minutes == 45 ) 491 else if ( minutes == 45 )
492 mess += ( "Please wake up!"); 492 mess += ( "Please wake up!");
493 else if ( minutes == 5 ) 493 else if ( minutes == 5 )
494 mess += ( "Tea is ready"); 494 mess += ( "Tea is ready");
495 else if ( minutes == 3 ) { 495 else if ( minutes == 3 ) {
496 mess += mCustomText; 496 mess += mCustomText;
497 minutes = mCustomMinutes ; 497 minutes = mCustomMinutes ;
498 } 498 }
499 else { 499 else {
500 if ( minutes == 2 ) { 500 if ( minutes == 2 ) {
501 // ask time 501 // ask time
502 QDialog dia ( 0, ("Customize Timer" ), true ); 502 QDialog dia ( 0, ("Customize Timer" ), true );
503 QLabel lab (("Message Text:"), &dia ); 503 QLabel lab (("Message Text:"), &dia );
504 dia.setCaption(("KO/Pi Timer" )); 504 dia.setCaption(("KO/Pi Timer" ));
505 QVBoxLayout lay( &dia ); 505 QVBoxLayout lay( &dia );
506 lay.setMargin(5); 506 lay.setMargin(5);
507 lay.setSpacing(5); 507 lay.setSpacing(5);
508 lay.addWidget( &lab); 508 lay.addWidget( &lab);
509 QLineEdit lEdit( mCustomText, &dia ); 509 QLineEdit lEdit( mCustomText, &dia );
510 lay.addWidget( &lEdit); 510 lay.addWidget( &lEdit);
511 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 511 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
512 lay.addWidget( &lab2); 512 lay.addWidget( &lab2);
513 QHBox hbox ( &dia ); 513 QHBox hbox ( &dia );
514 QLabel lab3 (("h:"), &hbox ); 514 QLabel lab3 (("h:"), &hbox );
515 QSpinBox spinh( 0, 24, 1,& hbox ); 515 QSpinBox spinh( 0, 24, 1,& hbox );
516 QLabel lab4 ((" min:"), &hbox ); 516 QLabel lab4 ((" min:"), &hbox );
517 QSpinBox spinm( 0, 59, 1,&hbox ); 517 QSpinBox spinm( 0, 59, 1,&hbox );
518 spinh.setValue( mCustomMinutes/60 ); 518 spinh.setValue( mCustomMinutes/60 );
519 spinm.setValue( mCustomMinutes%60 ); 519 spinm.setValue( mCustomMinutes%60 );
520 lay.addWidget( &hbox); 520 lay.addWidget( &hbox);
521 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 521 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
522 if ( !dia.exec() ) 522 if ( !dia.exec() )
523 return; 523 return;
524 mCustomText = lEdit.text(); 524 mCustomText = lEdit.text();
525 mCustomMinutes = spinh.value()*60+spinm.value(); 525 mCustomMinutes = spinh.value()*60+spinm.value();
526 if ( mCustomMinutes == 0 ) 526 if ( mCustomMinutes == 0 )
527 mCustomMinutes = 1; 527 mCustomMinutes = 1;
528 if ( mCustomMinutes > 1440 ) 528 if ( mCustomMinutes > 1440 )
529 mCustomMinutes = 1440; 529 mCustomMinutes = 1440;
530 mess += mCustomText; 530 mess += mCustomText;
531 minutes = mCustomMinutes; 531 minutes = mCustomMinutes;
532 } 532 }
533 else 533 else
534 mess+= QString::number ( minutes ) + ( " minutes are past!"); 534 mess+= QString::number ( minutes ) + ( " minutes are past!");
535 } 535 }
536 //minutes = 1; 536 //minutes = 1;
537 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 537 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
538 timerMesssage = mess; 538 timerMesssage = mess;
539 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 539 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
540 mTimerTime = 1; 540 mTimerTime = 1;
541} 541}
542 542
543void SimpleAlarmDaemonImpl::writeFile() 543void SimpleAlarmDaemonImpl::writeFile()
544{ 544{
545 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 545 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
546} 546}
547void SimpleAlarmDaemonImpl::showWN() 547void SimpleAlarmDaemonImpl::showWN()
548{ 548{
549 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 549 QCopEnvelope e("QPE/Application/kopi", "-showWN");
550} 550}
551void SimpleAlarmDaemonImpl::newTodo() 551void SimpleAlarmDaemonImpl::newTodo()
552{ 552{
553 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 553 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
554} 554}
555 555
556void SimpleAlarmDaemonImpl::newEvent() 556void SimpleAlarmDaemonImpl::newEvent()
557{ 557{
558 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 558 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
559 559
560} 560}
561void SimpleAlarmDaemonImpl::newMail() 561void SimpleAlarmDaemonImpl::newMail()
562{ 562{
563 QCopEnvelope e("QPE/Application/kmpi", "newMail()"); 563 QCopEnvelope e("QPE/Application/ompi", "newMail()");
564} 564}
565void SimpleAlarmDaemonImpl::showAdd() 565void SimpleAlarmDaemonImpl::showAdd()
566{ 566{
567 QCopEnvelope e("QPE/Application/kapi", " "); 567 QCopEnvelope e("QPE/Application/kapi", " ");
568} 568}
569void SimpleAlarmDaemonImpl::ringSync() 569void SimpleAlarmDaemonImpl::ringSync()
570{ 570{
571 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 571 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
572 572
573} 573}
574void SimpleAlarmDaemonImpl::newCountdown() 574void SimpleAlarmDaemonImpl::newCountdown()
575{ 575{
576 //recieve("cal_alarm", 10 ); 576 //recieve("cal_alarm", 10 );
577} 577}
578void SimpleAlarmDaemonImpl::simulate() 578void SimpleAlarmDaemonImpl::simulate()
579{ 579{
580 writeFile(); 580 writeFile();
581 QString filename = getenv("QPEDIR") ; 581 QString filename = getenv("QPEDIR") ;
582 filename += "/pics/kdepim/korganizer/koalarm.wav"; 582 filename += "/pics/kdepim/korganizer/koalarm.wav";
583 startAlarm("Alarm simulation", filename ); 583 startAlarm("Alarm simulation", filename );
584} 584}
585void SimpleAlarmDaemonImpl::showKO() 585void SimpleAlarmDaemonImpl::showKO()
586{ 586{
587 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 587 QCopEnvelope e("QPE/Application/kopi", "-showKO");
588 588
589} 589}
590void SimpleAlarmDaemonImpl::showTodo() 590void SimpleAlarmDaemonImpl::showTodo()
591{ 591{
592 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 592 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
593 593
594} 594}
595void SimpleAlarmDaemonImpl::writeJournal() 595void SimpleAlarmDaemonImpl::writeJournal()
596{ 596{
597 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 597 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
598 598
599} 599}
600 600
601void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 601void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
602{ 602{
603 603
604 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 604 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
605 605
606} 606}
607 607