summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp12
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp11
-rw-r--r--korganizer/mainwindow.cpp13
3 files changed, 22 insertions, 14 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index ddb125a..18ce9da 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -206,118 +206,122 @@ void AlarmDialog::slotSuspend()
206 mess +=mMessage->text(); 206 mess +=mMessage->text();
207#ifndef DESKTOP_VERSION 207#ifndef DESKTOP_VERSION
208 if ( mServerNotification ) 208 if ( mServerNotification )
209 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); 209 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1());
210#endif 210#endif
211 emit addAlarm( nextA , mess ); 211 emit addAlarm( nextA , mess );
212 slotOk(); 212 slotOk();
213} 213}
214 214
215void AlarmDialog::setServerNotification( bool b ) 215void AlarmDialog::setServerNotification( bool b )
216{ 216{
217 mServerNotification = b; 217 mServerNotification = b;
218} 218}
219int AlarmDialog::getSuspendTime( ) 219int AlarmDialog::getSuspendTime( )
220{ 220{
221 return mSuspendSpin->value(); 221 return mSuspendSpin->value();
222 222
223} 223}
224void AlarmDialog::setSuspendTime( int val ) 224void AlarmDialog::setSuspendTime( int val )
225{ 225{
226 mSuspendSpin->setValue( val ); 226 mSuspendSpin->setValue( val );
227} 227}
228bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) 228bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes)
229{ 229{
230 if ( mess.left( 9) != "Suspended" ) 230 if ( mess.left( 9) != "Suspended" )
231 mSuspendCounter = suspendtimes; 231 mSuspendCounter = suspendtimes;
232 mPauseCount = pause; 232 mPauseCount = pause;
233 mFileName = fn; 233 mFileName = fn;
234 mPlayWav = playwav; 234 mPlayWav = playwav;
235 if ( !QFile::exists( fn ) ) 235 if ( !QFile::exists( fn ) )
236 mFileName = ""; 236 mFileName = "";
237 alarmCounter = 0 ; 237 alarmCounter = 0 ;
238 maxAlarmReplay = replay ; 238 maxAlarmReplay = replay ;
239 mStopAlarm = false; 239 mStopAlarm = false;
240 mSilent = false; 240 mSilent = false;
241 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { 241 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) {
242 mMissedAlarmsCombo->show(); 242 mMissedAlarmsCombo->show();
243 QString newItem = mMessage->text().stripWhiteSpace(); 243 QString newItem = mMessage->text().stripWhiteSpace();
244 newItem.replace( QRegExp("\n"), QString(" ") ); 244 newItem.replace( QRegExp("\n"), QString(" ") );
245 mMissedAlarmsCombo->insertItem( newItem ); 245 mMissedAlarmsCombo->insertItem( newItem );
246 mMissedAlarms->setText( "Missed alarms:"); 246 mMissedAlarms->setText( "Missed alarms:");
247 } else 247 } else
248 mMissedAlarmsCombo->hide(); 248 mMissedAlarmsCombo->hide();
249 mMessage->setText(mess); 249 mMessage->setText(mess);
250 int w = minimumSizeHint().width() ; 250 int w = minimumSizeHint().width() ;
251 int h = minimumSizeHint().height() ; 251 int h = minimumSizeHint().height() ;
252 int dw = QApplication::desktop()->width(); 252 int dw = QApplication::desktop()->width();
253 int dh = QApplication::desktop()->height(); 253 int dh = QApplication::desktop()->height();
254 if ( w < 220 ) w = 220;
255 if ( h < 220 ) h = 220;
254 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 256 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
255 hide(); 257 showNormal();
258 setActiveWindow();
259 raise();
260 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
261 //hide();
256 262
257#ifndef _WIN32_ 263#ifndef _WIN32_
258 if ( fd_led > 0 ) { 264 if ( fd_led > 0 ) {
259 statusLED.status = LED_SALARM_ON ; 265 statusLED.status = LED_SALARM_ON ;
260 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 266 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
261 } 267 }
262#endif 268#endif
263 okbut->setDefault( true ); 269 okbut->setDefault( true );
264 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); 270 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) );
265 // playSoundTimer->start( 1000, true ); 271 // playSoundTimer->start( 1000, true );
266 return true; 272 return true;
267 273
268} 274}
269 275
270void AlarmDialog::forceRepaint() 276void AlarmDialog::forceRepaint()
271{ 277{
272
273 showNormal();
274 setActiveWindow(); 278 setActiveWindow();
275 raise(); 279 repaint();
276 mSuspendSpin->setFocus(); 280 mSuspendSpin->setFocus();
277 playSoundTimer->start( 1000, true ); 281 playSoundTimer->start( 1000, true );
278 282
279} 283}
280void AlarmDialog::spinBoxChanged( int v ) 284void AlarmDialog::spinBoxChanged( int v )
281{ 285{
282 okbut->setDefault( false ); 286 okbut->setDefault( false );
283 mSilent = true; 287 mSilent = true;
284} 288}
285 289
286void AlarmDialog::playSound () 290void AlarmDialog::playSound ()
287{ 291{
288 292
289 if (mStopAlarm ) 293 if (mStopAlarm )
290 return; 294 return;
291 if ( mSilent ) 295 if ( mSilent )
292 return; 296 return;
293 //showNormal(); 297 //showNormal();
294 setActiveWindow(); 298 setActiveWindow();
295 //raise(); 299 //raise();
296 mSuspendSpin->setFocus(); 300 mSuspendSpin->setFocus();
297 if ( alarmCounter < maxAlarmReplay && ! mSilent) { 301 if ( alarmCounter < maxAlarmReplay && ! mSilent) {
298 ++alarmCounter; 302 ++alarmCounter;
299#ifdef DESKTOP_VERSION 303#ifdef DESKTOP_VERSION
300 mPlayWav = true; 304 mPlayWav = true;
301#endif 305#endif
302 if ( !mPlayWav || mFileName.length() < 2 ) { 306 if ( !mPlayWav || mFileName.length() < 2 ) {
303 307
304#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
305 qDebug("Sound play not possible - file not found"); 309 qDebug("Sound play not possible - file not found");
306#else 310#else
307 Sound::soundAlarm (); 311 Sound::soundAlarm ();
308#endif 312#endif
309 } else 313 } else
310 314
311 { 315 {
312#ifdef DESKTOP_VERSION 316#ifdef DESKTOP_VERSION
313#ifdef _WIN32_ 317#ifdef _WIN32_
314 QSound::play ( mFileName ); 318 QSound::play ( mFileName );
315#else 319#else
316 320
317 QString command = "playwave -r 22050 " + mFileName; 321 QString command = "playwave -r 22050 " + mFileName;
318 qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); 322 qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() );
319 int ret = system ( command.latin1() ); 323 int ret = system ( command.latin1() );
320 if ( ret != 0 ) { 324 if ( ret != 0 ) {
321 qDebug("Sound play command failed: %s ",command.latin1() ); 325 qDebug("Sound play command failed: %s ",command.latin1() );
322 } 326 }
323 327
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index a0ac232..8ea8a73 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -22,96 +22,101 @@
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
@@ -268,123 +273,123 @@ void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
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 );
@@ -597,78 +602,78 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 98d3e35..fb0b4ad 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -263,235 +263,234 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) :
263 tbd = Top; 263 tbd = Top;
264 } 264 }
265 else { 265 else {
266 if ( p->mToolBarUpV ) 266 if ( p->mToolBarUpV )
267 tbd = Right; 267 tbd = Right;
268 else 268 else
269 tbd = Left; 269 tbd = Left;
270 } 270 }
271 viewToolBar = new QPEToolBar( this ); 271 viewToolBar = new QPEToolBar( this );
272 addToolBar (viewToolBar , tbd ); 272 addToolBar (viewToolBar , tbd );
273 if ( p->mToolBarHorN ) { 273 if ( p->mToolBarHorN ) {
274 if ( p->mToolBarUpN ) 274 if ( p->mToolBarUpN )
275 tbd = Bottom; 275 tbd = Bottom;
276 else 276 else
277 tbd = Top; 277 tbd = Top;
278 } 278 }
279 else { 279 else {
280 if ( p->mToolBarUpN ) 280 if ( p->mToolBarUpN )
281 tbd = Right; 281 tbd = Right;
282 else 282 else
283 tbd = Left; 283 tbd = Left;
284 } 284 }
285 navigatorToolBar = new QPEToolBar( this ); 285 navigatorToolBar = new QPEToolBar( this );
286 addToolBar (navigatorToolBar , tbd ); 286 addToolBar (navigatorToolBar , tbd );
287 } 287 }
288 288
289 289
290 290
291 mCalendarModifiedFlag = false; 291 mCalendarModifiedFlag = false;
292 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 292 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
293 //splash->setAlignment ( AlignCenter ); 293 //splash->setAlignment ( AlignCenter );
294 //setCentralWidget( splash ); 294 //setCentralWidget( splash );
295#ifndef DESKTOP_VERSION 295#ifndef DESKTOP_VERSION
296 //showMaximized(); 296 //showMaximized();
297#endif 297#endif
298 298
299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
300 setDefaultPreferences(); 300 setDefaultPreferences();
301 mCalendar = new CalendarLocal(); 301 mCalendar = new CalendarLocal();
302 mView = new CalendarView( mCalendar, this,"mCalendar " ); 302 mView = new CalendarView( mCalendar, this,"mCalendar " );
303 setCentralWidget( mView ); 303 setCentralWidget( mView );
304 //mView->hide(); 304 //mView->hide();
305 //mView->resize(splash->size() ); 305 //mView->resize(splash->size() );
306 initActions(); 306 initActions();
307 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 307 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
308 mSyncManager->setBlockSave(false); 308 mSyncManager->setBlockSave(false);
309 mView->setSyncManager(mSyncManager); 309 mView->setSyncManager(mSyncManager);
310#ifndef DESKTOP_VERSION 310#ifndef DESKTOP_VERSION
311 iconToolBar->show(); 311 //iconToolBar->show();
312 qApp->processEvents(); 312 //qApp->processEvents();
313#endif 313#endif
314 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 314 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
315 int vh = height() ; 315 int vh = height() ;
316 int vw = width(); 316 int vw = width();
317 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 317 //qDebug("Toolbar hei %d ",iconToolBar->height() );
318 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 318 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
319 vh -= iconToolBar->height(); 319 vh -= iconToolBar->height();
320 } else { 320 } else {
321 vw -= iconToolBar->height(); 321 vw -= iconToolBar->height();
322 } 322 }
323 //mView->setMaximumSize( splash->size() ); 323 //mView->setMaximumSize( splash->size() );
324 //mView->resize( splash->size() ); 324 //mView->resize( splash->size() );
325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
326 mView->readSettings(); 326 mView->readSettings();
327 bool newFile = false; 327 bool newFile = false;
328 if( !QFile::exists( defaultFileName() ) ) { 328 if( !QFile::exists( defaultFileName() ) ) {
329 QFileInfo finfo ( defaultFileName() ); 329 QFileInfo finfo ( defaultFileName() );
330 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 330 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
331 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 331 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
332 finfo.setFile( oldFile ); 332 finfo.setFile( oldFile );
333 if (finfo.exists() ) { 333 if (finfo.exists() ) {
334 KMessageBox::information( this, message); 334 KMessageBox::information( this, message);
335 mView->openCalendar( oldFile ); 335 mView->openCalendar( oldFile );
336 qApp->processEvents(); 336 qApp->processEvents();
337 } else { 337 } else {
338 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 338 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
339 finfo.setFile( oldFile ); 339 finfo.setFile( oldFile );
340 if (finfo.exists() ) { 340 if (finfo.exists() ) {
341 KMessageBox::information( this, message); 341 KMessageBox::information( this, message);
342 mView->openCalendar( oldFile ); 342 mView->openCalendar( oldFile );
343 qApp->processEvents(); 343 qApp->processEvents();
344 } 344 }
345 } 345 }
346 mView->saveCalendar( defaultFileName() ); 346 mView->saveCalendar( defaultFileName() );
347 newFile = true; 347 newFile = true;
348 } 348 }
349 349
350 //QTime neededSaveTime = QDateTime::currentDateTime().time(); 350 //QTime neededSaveTime = QDateTime::currentDateTime().time();
351 //mView->loadCalendars(); 351 //mView->loadCalendars();
352 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 352 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
353 //qDebug("KO: Calendar loading time: %d ms",msNeeded ); 353 //qDebug("KO: Calendar loading time: %d ms",msNeeded );
354 354
355 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 355 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
356 KOPrefs::instance()->setAllDefaults(); 356 KOPrefs::instance()->setAllDefaults();
357 } 357 }
358 358
359 359
360 connect( mView, SIGNAL( tempDisableBR(bool) ), 360 connect( mView, SIGNAL( tempDisableBR(bool) ),
361 SLOT( disableBR(bool) ) ); 361 SLOT( disableBR(bool) ) );
362 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 362 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
363 setCentralWidget( mView ); 363 setCentralWidget( mView );
364 globalFlagBlockStartup = 0; 364 globalFlagBlockStartup = 0;
365 //mView->show(); 365 //mView->show();
366 //delete splash; 366 //delete splash;
367 if ( newFile ) 367 if ( newFile )
368 mView->updateConfig(); 368 mView->updateConfig();
369 // qApp->processEvents(); 369 // qApp->processEvents();
370 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 370 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
371 //fillSyncMenu(); 371 //fillSyncMenu();
372 372
373 373
374 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 374 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
378 mSyncManager->setDefaultFileName( sentSyncFile()); 378 mSyncManager->setDefaultFileName( sentSyncFile());
379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
380 mSyncManager->fillSyncMenu(); 380 mSyncManager->fillSyncMenu();
381 381
382 382
383 383
384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
385 if ( showWarning ) { 385 if ( showWarning ) {
386 KMessageBox::information( this, 386 KMessageBox::information( this,
387 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 387 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
388 qApp->processEvents(); 388 //qApp->processEvents();
389 mView->dialogManager()->showSyncOptions(); 389 mView->dialogManager()->showSyncOptions();
390 } 390 }
391 391
392 //US listen for result adressed from Ka/Pi 392 //US listen for result adressed from Ka/Pi
393 393
394#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
395 infrared = 0; 395 infrared = 0;
396#endif 396#endif
397 updateFilterToolbar(); 397 updateFilterToolbar();
398 updateWeek( mView->startDate() ); 398 updateWeek( mView->startDate() );
399 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 399 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
400 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 400 SLOT( updateWeekNum( const KCal::DateList & ) ) );
401 mBRdisabled = false; 401 mBRdisabled = false;
402 //toggleBeamReceive(); 402 //toggleBeamReceive();
403 403
404 setCaption(i18n("Loading calendar files ... please wait" )); 404 setCaption(i18n("Loading calendar files ... please wait" ));
405 mSaveDelay = 0; 405 mSaveDelay = 0;
406 QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); 406 QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() ));
407} 407}
408MainWindow::~MainWindow() 408MainWindow::~MainWindow()
409{ 409{
410 //qDebug("MainWindow::~MainWindow() "); 410 //qDebug("MainWindow::~MainWindow() ");
411 //save toolbar location 411 //save toolbar location
412 delete mCalendar; 412 delete mCalendar;
413 delete mSyncManager; 413 delete mSyncManager;
414#ifndef DESKTOP_VERSION 414#ifndef DESKTOP_VERSION
415 if ( infrared ) 415 if ( infrared )
416 delete infrared; 416 delete infrared;
417#endif 417#endif
418 418
419 419
420} 420}
421 421
422void MainWindow::loadDataAfterStart() 422void MainWindow::loadDataAfterStart()
423{ 423{
424 424
425 qDebug("KO: Start loading files..." ); 425 qDebug("KO: Start loading files..." );
426 QTime neededSaveTime = QDateTime::currentDateTime().time(); 426 QTime neededSaveTime = QDateTime::currentDateTime().time();
427 mView->loadCalendars(); 427 mView->loadCalendars();
428 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 428 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
429 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 429 qDebug("KO: Calendar loading time: %d ms",msNeeded );
430 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 430 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
431 mView->setModified( false ); 431 mView->setModified( false );
432 mBlockAtStartup = false; 432 mBlockAtStartup = false;
433 mView->setModified( false ); 433 mView->setModified( false );
434 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 434 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
435 processIncidenceSelection( 0 ); 435 processIncidenceSelection( 0 );
436 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 436 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
437 SLOT( processIncidenceSelection( Incidence * ) ) ); 437 SLOT( processIncidenceSelection( Incidence * ) ) );
438 connect( mView, SIGNAL( modifiedChanged( bool ) ), 438 connect( mView, SIGNAL( modifiedChanged( bool ) ),
439 SLOT( slotModifiedChanged( bool ) ) ); 439 SLOT( slotModifiedChanged( bool ) ) );
440 440
441#ifndef DESKTOP_VERSION 441#ifndef DESKTOP_VERSION
442 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 442 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
443 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); 443 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& )));
444 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); 444 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& )));
445 ((QPEApplication*) qApp)->showMainWidget( this );
445 if ( !mCStringMess.isEmpty() ) 446 if ( !mCStringMess.isEmpty() )
446 recieve( mCStringMess, mByteData ); 447 recieve( mCStringMess, mByteData );
447#endif 448#endif
448
449
450 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 449 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
451} 450}
452 451
453void MainWindow::slotResetFocus() 452void MainWindow::slotResetFocus()
454{ 453{
455 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 454 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
456 mFocusLoop = 3; 455 mFocusLoop = 3;
457 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 456 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
458} 457}
459void MainWindow::slotResetFocusLoop() 458void MainWindow::slotResetFocusLoop()
460{ 459{
461 --mFocusLoop; 460 --mFocusLoop;
462 QWidget* fw = mView->viewManager()->currentView(); 461 QWidget* fw = mView->viewManager()->currentView();
463 if ( fw ) { 462 if ( fw ) {
464 //qDebug("loop "); 463 //qDebug("loop ");
465 fw->setFocus(); 464 fw->setFocus();
466 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 465 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
467 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 466 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
468 } 467 }
469 468
470} 469}
471void MainWindow::disableBR(bool b) 470void MainWindow::disableBR(bool b)
472{ 471{
473#ifndef DESKTOP_VERSION 472#ifndef DESKTOP_VERSION
474 if ( b ) { 473 if ( b ) {
475 if ( infrared ) { 474 if ( infrared ) {
476 toggleBeamReceive(); 475 toggleBeamReceive();
477 mBRdisabled = true; 476 mBRdisabled = true;
478 } 477 }
479 mBRdisabled = true; 478 mBRdisabled = true;
480 } else { 479 } else {
481 if ( mBRdisabled ) { 480 if ( mBRdisabled ) {
482 mBRdisabled = false; 481 mBRdisabled = false;
483 //makes no sense,because other cal ap is probably running 482 //makes no sense,because other cal ap is probably running
484 // toggleBeamReceive(); 483 // toggleBeamReceive();
485 } 484 }
486 } 485 }
487#endif 486#endif
488 487
489} 488}
490bool MainWindow::beamReceiveEnabled() 489bool MainWindow::beamReceiveEnabled()
491{ 490{
492#ifndef DESKTOP_VERSION 491#ifndef DESKTOP_VERSION
493 return ( infrared != 0 ); 492 return ( infrared != 0 );
494#endif 493#endif
495 return false; 494 return false;
496} 495}
497 496
@@ -1999,98 +1998,98 @@ void MainWindow::saveStopTimer()
1999{ 1998{
2000 mSaveTimer.stop(); 1999 mSaveTimer.stop();
2001} 2000}
2002void MainWindow::backupAllFiles() 2001void MainWindow::backupAllFiles()
2003{ 2002{
2004 QDate reference ( 2000,1,1); 2003 QDate reference ( 2000,1,1);
2005 int daysTo = reference.daysTo ( QDate::currentDate() ); 2004 int daysTo = reference.daysTo ( QDate::currentDate() );
2006 setCaption(i18n("Creating backup ... please wait ..." )); 2005 setCaption(i18n("Creating backup ... please wait ..." ));
2007 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 2006 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
2008 // we need the file path, the backup dir and the number of bups as param 2007 // we need the file path, the backup dir and the number of bups as param
2009 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2008 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2010 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2009 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2011 bupDir = KGlobalSettings::backupDataDir(); 2010 bupDir = KGlobalSettings::backupDataDir();
2012 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2011 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2013 if ( retval == 0 ) { 2012 if ( retval == 0 ) {
2014 setCaption(i18n("Backup cancelled" )); 2013 setCaption(i18n("Backup cancelled" ));
2015 qDebug("KO: Backup cancelled. Will try again tomorrow "); 2014 qDebug("KO: Backup cancelled. Will try again tomorrow ");
2016 // retval == 0 : backup skipped for today, try again tomorrow 2015 // retval == 0 : backup skipped for today, try again tomorrow
2017 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 2016 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
2018 } else if ( retval == 1 ){ 2017 } else if ( retval == 1 ){
2019 qDebug("KO: Backup created."); 2018 qDebug("KO: Backup created.");
2020 // backup ok 2019 // backup ok
2021 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2020 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2022 KopiCalendarFile * cal = calendars.first(); 2021 KopiCalendarFile * cal = calendars.first();
2023 cal = calendars.next(); 2022 cal = calendars.next();
2024 while ( cal ) { 2023 while ( cal ) {
2025 if ( !cal->mErrorOnLoad ) { 2024 if ( !cal->mErrorOnLoad ) {
2026 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2025 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2027 } 2026 }
2028 cal = calendars.next(); 2027 cal = calendars.next();
2029 } 2028 }
2030 KOPrefs::instance()->mLastBackupDate = daysTo; 2029 KOPrefs::instance()->mLastBackupDate = daysTo;
2031 setCaption(i18n("Backup succesfully finished" )); 2030 setCaption(i18n("Backup succesfully finished" ));
2032 } else if ( retval == 2 ){ 2031 } else if ( retval == 2 ){
2033 setCaption(i18n("Backup globally disabled" )); 2032 setCaption(i18n("Backup globally disabled" ));
2034 qDebug("KO: Backup globally cancelled."); 2033 qDebug("KO: Backup globally cancelled.");
2035 // backup globally cancelled 2034 // backup globally cancelled
2036 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2035 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2037 } 2036 }
2038 // retval == 3: do nothing, try again later 2037 // retval == 3: do nothing, try again later
2039} 2038}
2040void MainWindow::save() 2039void MainWindow::save()
2041{ 2040{
2042 if ( mSaveDelay ) { 2041 if ( mSaveDelay ) {
2043 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); 2042 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() );
2044 if ( mSaveDelay < elapsed ) { 2043 if ( mSaveDelay < elapsed ) {
2045 qDebug("KO: Pending save after wakeup from suspend detected."); 2044 qDebug("KO: Pending save after wakeup from suspend detected.");
2046 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); 2045 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed );
2047 qDebug("KO: Restarting save timer to save in 15 sec."); 2046 qDebug("KO: Restarting save timer to save in 10 sec.");
2048 int msec = 15000; 2047 int msec = 10000;
2049 mSaveTimer.start( msec, true ); 2048 mSaveTimer.start( msec, true );
2050 mSaveTimerStart = QDateTime::currentDateTime(); 2049 mSaveTimerStart = QDateTime::currentDateTime();
2051 mSaveDelay = msec/1000; 2050 mSaveDelay = msec/1000;
2052 return; 2051 return;
2053 } 2052 }
2054 } 2053 }
2055 2054
2056 if ( mView->viewManager()->journalView() ) 2055 if ( mView->viewManager()->journalView() )
2057 mView->viewManager()->journalView()->checkModified(); 2056 mView->viewManager()->journalView()->checkModified();
2058 if ( !mCalendarModifiedFlag ) { 2057 if ( !mCalendarModifiedFlag ) {
2059 qDebug("KO: Calendar not modified. Nothing saved."); 2058 qDebug("KO: Calendar not modified. Nothing saved.");
2060 return; 2059 return;
2061 } 2060 }
2062 if ( mSyncManager->blockSave() ) { 2061 if ( mSyncManager->blockSave() ) {
2063 slotModifiedChanged( true ); 2062 slotModifiedChanged( true );
2064 return; 2063 return;
2065 } 2064 }
2066 mSaveDelay = 0; 2065 mSaveDelay = 0;
2067 mSyncManager->setBlockSave(true); 2066 mSyncManager->setBlockSave(true);
2068 if ( mView->checkAllFileVersions() ) { 2067 if ( mView->checkAllFileVersions() ) {
2069 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 2068 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
2070 QDate reference ( 2000,1,1); 2069 QDate reference ( 2000,1,1);
2071 int daysTo = reference.daysTo ( QDate::currentDate() ); 2070 int daysTo = reference.daysTo ( QDate::currentDate() );
2072 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 2071 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
2073 backupAllFiles(); 2072 backupAllFiles();
2074 } 2073 }
2075 ; // KPimGlobalPrefs::instance()->mLastBackupDate 2074 ; // KPimGlobalPrefs::instance()->mLastBackupDate
2076 } 2075 }
2077 QTime neededSaveTime; 2076 QTime neededSaveTime;
2078 neededSaveTime.start(); 2077 neededSaveTime.start();
2079 if ( !isMinimized () ) 2078 if ( !isMinimized () )
2080 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 2079 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
2081 qDebug("KO: Start saving data to file!"); 2080 qDebug("KO: Start saving data to file!");
2082 if ( mView->saveCalendars() ) 2081 if ( mView->saveCalendars() )
2083 mCalendarModifiedFlag = false; 2082 mCalendarModifiedFlag = false;
2084 int msNeeded = neededSaveTime.elapsed(); 2083 int msNeeded = neededSaveTime.elapsed();
2085 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2084 qDebug("KO: Needed %d ms for saving.",msNeeded );
2086 QString savemes; 2085 QString savemes;
2087 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2086 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2088 if ( !isMinimized () ) 2087 if ( !isMinimized () )
2089 setCaption(savemes); 2088 setCaption(savemes);
2090 else 2089 else
2091 qDebug(savemes); 2090 qDebug(savemes);
2092 } else { 2091 } else {
2093 setCaption(i18n("Saving cancelled!")); 2092 setCaption(i18n("Saving cancelled!"));
2094 mCalendarModifiedFlag = false; 2093 mCalendarModifiedFlag = false;
2095 slotModifiedChanged( true ); 2094 slotModifiedChanged( true );
2096 } 2095 }