-rw-r--r-- | libkcal/phoneformat.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 900fc04..794e4b4 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,57 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <q3ptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <q3textstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <QDesktopWidget> | ||
34 | 35 | ||
35 | #include <kdebug.h> | 36 | #include <kdebug.h> |
36 | #include <klocale.h> | 37 | #include <klocale.h> |
37 | #include <kglobal.h> | 38 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
39 | #include <phoneaccess.h> | 40 | #include <phoneaccess.h> |
40 | 41 | ||
41 | #include "calendar.h" | 42 | #include "calendar.h" |
42 | #include "alarm.h" | 43 | #include "alarm.h" |
43 | #include "recurrence.h" | 44 | #include "recurrence.h" |
44 | #include "calendarlocal.h" | 45 | #include "calendarlocal.h" |
45 | 46 | ||
46 | #include "phoneformat.h" | 47 | #include "phoneformat.h" |
47 | #include "syncdefines.h" | 48 | #include "syncdefines.h" |
48 | 49 | ||
49 | using namespace KCal; | 50 | using namespace KCal; |
50 | class PhoneParser : public QObject | 51 | class PhoneParser : public QObject |
51 | { | 52 | { |
52 | public: | 53 | public: |
53 | PhoneParser( ) { | 54 | PhoneParser( ) { |
54 | ; | 55 | ; |
55 | } | 56 | } |
56 | 57 | ||
57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 58 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
@@ -180,89 +181,89 @@ ulong PhoneFormat::getCsumEvent( Event* event ) | |||
180 | list.append( QString::number( rec->frequency()) );//12 | 181 | list.append( QString::number( rec->frequency()) );//12 |
181 | list.append( "0" ); | 182 | list.append( "0" ); |
182 | { | 183 | { |
183 | int days = 0; | 184 | int days = 0; |
184 | QBitArray weekDays = rec->days(); | 185 | QBitArray weekDays = rec->days(); |
185 | int i; | 186 | int i; |
186 | for( i = 1; i <= 7; ++i ) { | 187 | for( i = 1; i <= 7; ++i ) { |
187 | if ( weekDays[i-1] ) { | 188 | if ( weekDays[i-1] ) { |
188 | days += 1 << (i-1); | 189 | days += 1 << (i-1); |
189 | } | 190 | } |
190 | } | 191 | } |
191 | list.append( QString::number( days ) ); | 192 | list.append( QString::number( days ) ); |
192 | } | 193 | } |
193 | //pending weekdays | 194 | //pending weekdays |
194 | writeEndDate = true; | 195 | writeEndDate = true; |
195 | 196 | ||
196 | break; | 197 | break; |
197 | case Recurrence::rMonthlyPos:// 2 | 198 | case Recurrence::rMonthlyPos:// 2 |
198 | list.append( "2" ); | 199 | list.append( "2" ); |
199 | list.append( QString::number( rec->frequency()) );//12 | 200 | list.append( QString::number( rec->frequency()) );//12 |
200 | 201 | ||
201 | writeEndDate = true; | 202 | writeEndDate = true; |
202 | { | 203 | { |
203 | int count = 1; | 204 | int count = 1; |
204 | QPtrList<Recurrence::rMonthPos> rmp; | 205 | Q3PtrList<Recurrence::rMonthPos> rmp; |
205 | rmp = rec->monthPositions(); | 206 | rmp = rec->monthPositions(); |
206 | if ( rmp.first()->negative ) | 207 | if ( rmp.first()->negative ) |
207 | count = 5 - rmp.first()->rPos - 1; | 208 | count = 5 - rmp.first()->rPos - 1; |
208 | else | 209 | else |
209 | count = rmp.first()->rPos - 1; | 210 | count = rmp.first()->rPos - 1; |
210 | list.append( QString::number( count ) ); | 211 | list.append( QString::number( count ) ); |
211 | 212 | ||
212 | } | 213 | } |
213 | 214 | ||
214 | list.append( "0" ); | 215 | list.append( "0" ); |
215 | break; | 216 | break; |
216 | case Recurrence::rMonthlyDay:// 3 | 217 | case Recurrence::rMonthlyDay:// 3 |
217 | list.append( "3" ); | 218 | list.append( "3" ); |
218 | list.append( QString::number( rec->frequency()) );//12 | 219 | list.append( QString::number( rec->frequency()) );//12 |
219 | list.append( "0" ); | 220 | list.append( "0" ); |
220 | list.append( "0" ); | 221 | list.append( "0" ); |
221 | writeEndDate = true; | 222 | writeEndDate = true; |
222 | break; | 223 | break; |
223 | case Recurrence::rYearlyMonth://4 | 224 | case Recurrence::rYearlyMonth://4 |
224 | list.append( "4" ); | 225 | list.append( "4" ); |
225 | list.append( QString::number( rec->frequency()) );//12 | 226 | list.append( QString::number( rec->frequency()) );//12 |
226 | list.append( "0" ); | 227 | list.append( "0" ); |
227 | list.append( "0" ); | 228 | list.append( "0" ); |
228 | writeEndDate = true; | 229 | writeEndDate = true; |
229 | break; | 230 | break; |
230 | 231 | ||
231 | default: | 232 | default: |
232 | list.append( "255" ); | 233 | list.append( "255" ); |
233 | list.append( QString() ); | 234 | list.append( QString() ); |
234 | list.append( "0" ); | 235 | list.append( "0" ); |
235 | list.append( QString() ); | 236 | list.append( QString() ); |
236 | list.append( "0" ); | 237 | list.append( "0" ); |
237 | list.append( "20991231T000000" ); | 238 | list.append( "20991231T000000" ); |
238 | break; | 239 | break; |
239 | } | 240 | } |
240 | if ( writeEndDate ) { | 241 | if ( writeEndDate ) { |
241 | 242 | ||
242 | if ( rec->endDate().isValid() ) { // 15 + 16 | 243 | if ( rec->endDate().isValid() ) { // 15 + 16 |
243 | list.append( "1" ); | 244 | list.append( "1" ); |
244 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 245 | list.append( PhoneParser::dtToString( (QDateTime)rec->endDate()) ); |
245 | } else { | 246 | } else { |
246 | list.append( "0" ); | 247 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 248 | list.append( "20991231T000000" ); |
248 | } | 249 | } |
249 | 250 | ||
250 | } | 251 | } |
251 | attList << list.join(""); | 252 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 253 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 254 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 255 | ||
255 | attList << event->secrecyStr(); | 256 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 257 | return PhoneFormat::getCsum(attList ); |
257 | } | 258 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 259 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 260 | { |
260 | int max = attList.count(); | 261 | int max = attList.count(); |
261 | ulong cSum = 0; | 262 | ulong cSum = 0; |
262 | int j,k,i; | 263 | int j,k,i; |
263 | int add; | 264 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 265 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 266 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 267 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 268 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 269 | for ( k = 0; k < j; ++k ) { |
@@ -284,84 +285,84 @@ ulong PhoneFormat::getCsum( const QStringList & attList) | |||
284 | 285 | ||
285 | } | 286 | } |
286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 287 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
287 | #include <stdlib.h> | 288 | #include <stdlib.h> |
288 | #define DEBUGMODE false | 289 | #define DEBUGMODE false |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 290 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
290 | { | 291 | { |
291 | 292 | ||
292 | QString fileName; | 293 | QString fileName; |
293 | #ifdef DESKTOP_VERSION | 294 | #ifdef DESKTOP_VERSION |
294 | fileName = locateLocal("tmp", "phonefile.vcs"); | 295 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 296 | #else |
296 | fileName = "/tmp/phonefile.vcs"; | 297 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 298 | #endif |
298 | QString command; | 299 | QString command; |
299 | if ( ! PhoneAccess::readFromPhone( fileName )) { | 300 | if ( ! PhoneAccess::readFromPhone( fileName )) { |
300 | return false; | 301 | return false; |
301 | } | 302 | } |
302 | VCalFormat vfload; | 303 | VCalFormat vfload; |
303 | vfload.setLocalTime ( true ); | 304 | vfload.setLocalTime ( true ); |
304 | qDebug("loading file ..."); | 305 | qDebug("loading file ..."); |
305 | 306 | ||
306 | if ( ! vfload.load( calendar, fileName ) ) | 307 | if ( ! vfload.load( calendar, fileName ) ) |
307 | return false; | 308 | return false; |
308 | QPtrList<Event> er = calendar->rawEvents(); | 309 | Q3PtrList<Event> er = calendar->rawEvents(); |
309 | Event* ev = er.first(); | 310 | Event* ev = er.first(); |
310 | qDebug("reading events... "); | 311 | qDebug("reading events... "); |
311 | while ( ev ) { | 312 | while ( ev ) { |
312 | QStringList cat = ev->categories(); | 313 | QStringList cat = ev->categories(); |
313 | if ( cat.contains( "MeetingDEF" )) { | 314 | if ( cat.contains( "MeetingDEF" )) { |
314 | ev->setCategories( QStringList() ); | 315 | ev->setCategories( QStringList() ); |
315 | } else | 316 | } else |
316 | if ( cat.contains( "Birthday" )) { | 317 | if ( cat.contains( "Birthday" )) { |
317 | ev->setFloats( true ); | 318 | ev->setFloats( true ); |
318 | QDate da = ev->dtStart().date(); | 319 | QDate da = ev->dtStart().date(); |
319 | ev->setDtStart( QDateTime( da) ); | 320 | ev->setDtStart( QDateTime( da) ); |
320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); | 321 | ev->setDtEnd( QDateTime( da.addDays(1)) ); |
321 | 322 | ||
322 | } | 323 | } |
323 | uint cSum; | 324 | uint cSum; |
324 | cSum = PhoneFormat::getCsumEvent( ev ); | 325 | cSum = PhoneFormat::getCsumEvent( ev ); |
325 | int id = ev->pilotId(); | 326 | int id = ev->pilotId(); |
326 | Event *event; | 327 | Event *event; |
327 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 328 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
328 | if ( event ) { | 329 | if ( event ) { |
329 | event = (Event*)event->clone(); | 330 | event = (Event*)event->clone(); |
330 | copyEvent( event, ev ); | 331 | copyEvent( event, ev ); |
331 | calendar->deleteEvent( ev ); | 332 | calendar->deleteEvent( ev ); |
332 | calendar->addEvent( event); | 333 | calendar->addEvent( event); |
333 | } | 334 | } |
334 | else | 335 | else |
335 | event = ev; | 336 | event = ev; |
336 | event->setCsum( mProfileName, QString::number( cSum )); | 337 | event->setCsum( mProfileName, QString::number( cSum )); |
337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 338 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
338 | event->setID( mProfileName,QString::number( id ) ); | 339 | event->setID( mProfileName,QString::number( id ) ); |
339 | ev = er.next(); | 340 | ev = er.next(); |
340 | } | 341 | } |
341 | { | 342 | { |
342 | qDebug("reading todos... "); | 343 | qDebug("reading todos... "); |
343 | QPtrList<Todo> tr = calendar->rawTodos(); | 344 | Q3PtrList<Todo> tr = calendar->rawTodos(); |
344 | Todo* ev = tr.first(); | 345 | Todo* ev = tr.first(); |
345 | while ( ev ) { | 346 | while ( ev ) { |
346 | 347 | ||
347 | QStringList cat = ev->categories(); | 348 | QStringList cat = ev->categories(); |
348 | if ( cat.contains( "MeetingDEF" )) { | 349 | if ( cat.contains( "MeetingDEF" )) { |
349 | ev->setCategories( QStringList() ); | 350 | ev->setCategories( QStringList() ); |
350 | } | 351 | } |
351 | int id = ev->pilotId(); | 352 | int id = ev->pilotId(); |
352 | uint cSum; | 353 | uint cSum; |
353 | cSum = PhoneFormat::getCsumTodo( ev ); | 354 | cSum = PhoneFormat::getCsumTodo( ev ); |
354 | Todo *event; | 355 | Todo *event; |
355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 356 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
356 | if ( event ) { | 357 | if ( event ) { |
357 | //qDebug("copy todo %s ", event->summary().latin1()); | 358 | //qDebug("copy todo %s ", event->summary().latin1()); |
358 | 359 | ||
359 | event = (Todo*)event->clone(); | 360 | event = (Todo*)event->clone(); |
360 | copyTodo( event, ev ); | 361 | copyTodo( event, ev ); |
361 | calendar->deleteTodo( ev ); | 362 | calendar->deleteTodo( ev ); |
362 | calendar->addTodo( event); | 363 | calendar->addTodo( event); |
363 | } | 364 | } |
364 | else | 365 | else |
365 | event = ev; | 366 | event = ev; |
366 | event->setCsum( mProfileName, QString::number( cSum )); | 367 | event->setCsum( mProfileName, QString::number( cSum )); |
367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 368 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
@@ -444,164 +445,164 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) | |||
444 | nCat = catFrom[iii]; | 445 | nCat = catFrom[iii]; |
445 | if ( !nCat.isEmpty() ) | 446 | if ( !nCat.isEmpty() ) |
446 | if ( !cat.contains( nCat )) { | 447 | if ( !cat.contains( nCat )) { |
447 | cat << nCat; | 448 | cat << nCat; |
448 | } | 449 | } |
449 | } | 450 | } |
450 | to->setCategories( cat ); | 451 | to->setCategories( cat ); |
451 | if ( from->isCompleted() ) { | 452 | if ( from->isCompleted() ) { |
452 | to->setCompleted( true ); | 453 | to->setCompleted( true ); |
453 | if( from->completed().isValid() ) | 454 | if( from->completed().isValid() ) |
454 | to->setCompleted( from->completed() ); | 455 | to->setCompleted( from->completed() ); |
455 | } else { | 456 | } else { |
456 | // set percentcomplete only, if to->isCompleted() | 457 | // set percentcomplete only, if to->isCompleted() |
457 | if ( to->isCompleted() ) | 458 | if ( to->isCompleted() ) |
458 | to->setPercentComplete(from->percentComplete()); | 459 | to->setPercentComplete(from->percentComplete()); |
459 | } | 460 | } |
460 | if( to->priority() == 2 && from->priority() == 1 ) | 461 | if( to->priority() == 2 && from->priority() == 1 ) |
461 | ; //skip | 462 | ; //skip |
462 | else if (to->priority() == 4 && from->priority() == 5 ) | 463 | else if (to->priority() == 4 && from->priority() == 5 ) |
463 | ; | 464 | ; |
464 | else | 465 | else |
465 | to->setPriority(from->priority()); | 466 | to->setPriority(from->priority()); |
466 | 467 | ||
467 | } | 468 | } |
468 | #include <qcstring.h> | 469 | #include <q3cstring.h> |
469 | 470 | ||
470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) | 471 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) |
471 | { | 472 | { |
472 | inc->setID( mProfileName, id ); | 473 | inc->setID( mProfileName, id ); |
473 | inc->setCsum( mProfileName, csum); | 474 | inc->setCsum( mProfileName, csum); |
474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 475 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
475 | 476 | ||
476 | } | 477 | } |
477 | 478 | ||
478 | bool PhoneFormat::writeToPhone( Calendar * calendar) | 479 | bool PhoneFormat::writeToPhone( Calendar * calendar) |
479 | { | 480 | { |
480 | #ifdef DESKTOP_VERSION | 481 | #ifdef DESKTOP_VERSION |
481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); | 482 | QString fileName = locateLocal("tmp", "phonefile.vcs"); |
482 | #else | 483 | #else |
483 | QString fileName = "/tmp/phonefile.vcs"; | 484 | QString fileName = "/tmp/phonefile.vcs"; |
484 | #endif | 485 | #endif |
485 | 486 | ||
486 | VCalFormat vfsave; | 487 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 488 | vfsave.setLocalTime ( true ); |
488 | QString id = calendar->timeZoneId(); | 489 | QString id = calendar->timeZoneId(); |
489 | calendar->setLocalTime(); | 490 | calendar->setLocalTime(); |
490 | if ( ! vfsave.save( calendar, fileName ) ) | 491 | if ( ! vfsave.save( calendar, fileName ) ) |
491 | return false; | 492 | return false; |
492 | calendar->setTimeZoneId( id ); | 493 | calendar->setTimeZoneId( id ); |
493 | return PhoneAccess::writeToPhone( fileName ); | 494 | return PhoneAccess::writeToPhone( fileName ); |
494 | } | 495 | } |
495 | bool PhoneFormat::save( Calendar *calendar) | 496 | bool PhoneFormat::save( Calendar *calendar) |
496 | { | 497 | { |
497 | 498 | ||
498 | 499 | ||
499 | // 1 remove events which should be deleted | 500 | // 1 remove events which should be deleted |
500 | QPtrList<Event> er = calendar->rawEvents(); | 501 | Q3PtrList<Event> er = calendar->rawEvents(); |
501 | Event* ev = er.first(); | 502 | Event* ev = er.first(); |
502 | while ( ev ) { | 503 | while ( ev ) { |
503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 504 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
504 | calendar->deleteEvent( ev ); | 505 | calendar->deleteEvent( ev ); |
505 | } else { | 506 | } else { |
506 | 507 | ||
507 | } | 508 | } |
508 | ev = er.next(); | 509 | ev = er.next(); |
509 | } | 510 | } |
510 | // 2 remove todos which should be deleted | 511 | // 2 remove todos which should be deleted |
511 | QPtrList<Todo> tl = calendar->rawTodos(); | 512 | Q3PtrList<Todo> tl = calendar->rawTodos(); |
512 | Todo* to = tl.first(); | 513 | Todo* to = tl.first(); |
513 | while ( to ) { | 514 | while ( to ) { |
514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 515 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
515 | calendar->deleteTodo( to ); | 516 | calendar->deleteTodo( to ); |
516 | } else { | 517 | } else { |
517 | if ( to->isCompleted()) { | 518 | if ( to->isCompleted()) { |
518 | calendar->deleteTodo( to ); | 519 | calendar->deleteTodo( to ); |
519 | } | 520 | } |
520 | } | 521 | } |
521 | to = tl.next(); | 522 | to = tl.next(); |
522 | } | 523 | } |
523 | // 3 save file | 524 | // 3 save file |
524 | if ( !writeToPhone( calendar ) ) | 525 | if ( !writeToPhone( calendar ) ) |
525 | return false; | 526 | return false; |
526 | QLabel status ( i18n(" Opening device ..."), 0 ); | 527 | QLabel status ( i18n(" Opening device ..."), 0 ); |
527 | int w = status.sizeHint().width()+20 ; | 528 | int w = status.sizeHint().width()+20 ; |
528 | if ( w < 200 ) w = 230; | 529 | if ( w < 200 ) w = 230; |
529 | int h = status.sizeHint().height()+20 ; | 530 | int h = status.sizeHint().height()+20 ; |
530 | int dw = QApplication::desktop()->width(); | 531 | int dw = QApplication::desktop()->width(); |
531 | int dh = QApplication::desktop()->height(); | 532 | int dh = QApplication::desktop()->height(); |
532 | status.setCaption(i18n("Writing to phone...") ); | 533 | status.setCaption(i18n("Writing to phone...") ); |
533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 534 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
534 | QString message; | 535 | QString message; |
535 | status.show(); | 536 | status.show(); |
536 | status.raise(); | 537 | status.raise(); |
537 | qApp->processEvents(); | 538 | qApp->processEvents(); |
538 | // 5 reread data | 539 | // 5 reread data |
539 | message = i18n(" Rereading all data ... "); | 540 | message = i18n(" Rereading all data ... "); |
540 | status.setText ( message ); | 541 | status.setText ( message ); |
541 | qApp->processEvents(); | 542 | qApp->processEvents(); |
542 | CalendarLocal* calendarTemp = new CalendarLocal(); | 543 | CalendarLocal* calendarTemp = new CalendarLocal(); |
543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 544 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
544 | if ( ! load( calendarTemp,calendar) ){ | 545 | if ( ! load( calendarTemp,calendar) ){ |
545 | qDebug("error reloading calendar "); | 546 | qDebug("error reloading calendar "); |
546 | delete calendarTemp; | 547 | delete calendarTemp; |
547 | return false; | 548 | return false; |
548 | } | 549 | } |
549 | // 6 compare data | 550 | // 6 compare data |
550 | 551 | ||
551 | //algo 6 compare event | 552 | //algo 6 compare event |
552 | er = calendar->rawEvents(); | 553 | er = calendar->rawEvents(); |
553 | ev = er.first(); | 554 | ev = er.first(); |
554 | message = i18n(" Comparing event # "); | 555 | message = i18n(" Comparing event # "); |
555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 556 | Q3PtrList<Event> er1 = calendarTemp->rawEvents(); |
556 | Event* ev1; | 557 | Event* ev1; |
557 | int procCount = 0; | 558 | int procCount = 0; |
558 | while ( ev ) { | 559 | while ( ev ) { |
559 | //qDebug("event new ID %s",ev->summary().latin1()); | 560 | //qDebug("event new ID %s",ev->summary().latin1()); |
560 | status.setText ( message + QString::number ( ++procCount ) ); | 561 | status.setText ( message + QString::number ( ++procCount ) ); |
561 | qApp->processEvents(); | 562 | qApp->processEvents(); |
562 | ev1 = er1.first(); | 563 | ev1 = er1.first(); |
563 | while ( ev1 ) { | 564 | while ( ev1 ) { |
564 | if ( ev->contains( ev1 ) ) { | 565 | if ( ev->contains( ev1 ) ) { |
565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); | 566 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); |
566 | er1.remove( ev1 ); | 567 | er1.remove( ev1 ); |
567 | break; | 568 | break; |
568 | } | 569 | } |
569 | ev1 = er1.next(); | 570 | ev1 = er1.next(); |
570 | } | 571 | } |
571 | if ( ! ev1 ) { | 572 | if ( ! ev1 ) { |
572 | // ev->removeID(mProfileName); | 573 | // ev->removeID(mProfileName); |
573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 574 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
574 | } | 575 | } |
575 | 576 | ||
576 | 577 | ||
577 | ev = er.next(); | 578 | ev = er.next(); |
578 | } | 579 | } |
579 | //algo 6 compare todo | 580 | //algo 6 compare todo |
580 | tl = calendar->rawTodos(); | 581 | tl = calendar->rawTodos(); |
581 | to = tl.first(); | 582 | to = tl.first(); |
582 | procCount = 0; | 583 | procCount = 0; |
583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 584 | Q3PtrList<Todo> tl1 = calendarTemp->rawTodos(); |
584 | Todo* to1 ; | 585 | Todo* to1 ; |
585 | message = i18n(" Comparing todo # "); | 586 | message = i18n(" Comparing todo # "); |
586 | while ( to ) { | 587 | while ( to ) { |
587 | status.setText ( message + QString::number ( ++procCount ) ); | 588 | status.setText ( message + QString::number ( ++procCount ) ); |
588 | qApp->processEvents(); | 589 | qApp->processEvents(); |
589 | Todo* to1 = tl1.first(); | 590 | Todo* to1 = tl1.first(); |
590 | while ( to1 ) { | 591 | while ( to1 ) { |
591 | if ( to->contains( to1 ) ) { | 592 | if ( to->contains( to1 ) ) { |
592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); | 593 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); |
593 | tl1.remove( to1 ); | 594 | tl1.remove( to1 ); |
594 | break; | 595 | break; |
595 | } | 596 | } |
596 | to1 = tl1.next(); | 597 | to1 = tl1.next(); |
597 | } | 598 | } |
598 | if ( ! to1 ) { | 599 | if ( ! to1 ) { |
599 | //to->removeID(mProfileName); | 600 | //to->removeID(mProfileName); |
600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 601 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
601 | } | 602 | } |
602 | 603 | ||
603 | to = tl.next(); | 604 | to = tl.next(); |
604 | } | 605 | } |
605 | delete calendarTemp; | 606 | delete calendarTemp; |
606 | return true; | 607 | return true; |
607 | 608 | ||