author | zautrix <zautrix> | 2004-10-05 11:37:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:37:46 (UTC) |
commit | 4c877944b4e7bb7f74b4c8db07a99fd8133e8b86 (patch) (unidiff) | |
tree | bd3ecaaa9618eb6774ccc05fa79d546296fe54ba | |
parent | f002814959b88dc7786bbb4299ab6252a6fa8e0d (diff) | |
download | kdepimpi-4c877944b4e7bb7f74b4c8db07a99fd8133e8b86.zip kdepimpi-4c877944b4e7bb7f74b4c8db07a99fd8133e8b86.tar.gz kdepimpi-4c877944b4e7bb7f74b4c8db07a99fd8133e8b86.tar.bz2 |
added missing ;
-rw-r--r-- | libkcal/phoneformat.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 16c5880..29c1ae6 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -191,542 +191,542 @@ int PhoneFormat::initDevice(GSM_StateMachine *s) | |||
191 | cfg->Connection = strdup(mConnection.latin1()); | 191 | cfg->Connection = strdup(mConnection.latin1()); |
192 | cfg->DefaultConnection = false; | 192 | cfg->DefaultConnection = false; |
193 | qDebug("Connection set %s ", cfg->Connection ); | 193 | qDebug("Connection set %s ", cfg->Connection ); |
194 | 194 | ||
195 | } | 195 | } |
196 | if ( ! mDevice.isEmpty() ) { | 196 | if ( ! mDevice.isEmpty() ) { |
197 | cfg->Device = strdup(mDevice.latin1()); | 197 | cfg->Device = strdup(mDevice.latin1()); |
198 | cfg->DefaultDevice = false; | 198 | cfg->DefaultDevice = false; |
199 | qDebug("Device set %s ", cfg->Device); | 199 | qDebug("Device set %s ", cfg->Device); |
200 | 200 | ||
201 | } | 201 | } |
202 | if ( ! mModel.isEmpty() ) { | 202 | if ( ! mModel.isEmpty() ) { |
203 | strcpy(cfg->Model,mModel.latin1() ); | 203 | strcpy(cfg->Model,mModel.latin1() ); |
204 | cfg->DefaultModel = false; | 204 | cfg->DefaultModel = false; |
205 | qDebug("Model set %s ",cfg->Model ); | 205 | qDebug("Model set %s ",cfg->Model ); |
206 | } | 206 | } |
207 | int error=GSM_InitConnection(s,3); | 207 | int error=GSM_InitConnection(s,3); |
208 | return error; | 208 | return error; |
209 | } | 209 | } |
210 | #endif | 210 | #endif |
211 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 211 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
212 | { | 212 | { |
213 | QStringList attList; | 213 | QStringList attList; |
214 | if ( todo->hasDueDate() ) | 214 | if ( todo->hasDueDate() ) |
215 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 215 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
216 | attList << todo->summary(); | 216 | attList << todo->summary(); |
217 | QString completedString = "no"; | 217 | QString completedString = "no"; |
218 | if ( todo->isCompleted() ) | 218 | if ( todo->isCompleted() ) |
219 | completedString = "yes"; | 219 | completedString = "yes"; |
220 | attList << completedString; | 220 | attList << completedString; |
221 | int prio = todo->priority(); | 221 | int prio = todo->priority(); |
222 | if( prio == 2 ) prio = 1; | 222 | if( prio == 2 ) prio = 1; |
223 | if (prio == 4 ) prio = 5 ; | 223 | if (prio == 4 ) prio = 5 ; |
224 | attList << QString::number( prio ); | 224 | attList << QString::number( prio ); |
225 | QString alarmString = "na"; | 225 | QString alarmString = "na"; |
226 | Alarm *alarm; | 226 | Alarm *alarm; |
227 | if ( todo->alarms().count() > 0 ) { | 227 | if ( todo->alarms().count() > 0 ) { |
228 | alarm = todo->alarms().first(); | 228 | alarm = todo->alarms().first(); |
229 | if ( alarm->enabled() ) { | 229 | if ( alarm->enabled() ) { |
230 | alarmString = QString::number(alarm->offset() ); | 230 | alarmString = QString::number(alarm->offset() ); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | attList << alarmString; | 233 | attList << alarmString; |
234 | attList << todo->categoriesStr(); | 234 | attList << todo->categoriesStr(); |
235 | attList << todo->secrecyStr(); | 235 | attList << todo->secrecyStr(); |
236 | return PhoneFormat::getCsum(attList ); | 236 | return PhoneFormat::getCsum(attList ); |
237 | 237 | ||
238 | } | 238 | } |
239 | ulong PhoneFormat::getCsumEvent( Event* event ) | 239 | ulong PhoneFormat::getCsumEvent( Event* event ) |
240 | { | 240 | { |
241 | QStringList attList; | 241 | QStringList attList; |
242 | attList << PhoneParser::dtToString ( event->dtStart() ); | 242 | attList << PhoneParser::dtToString ( event->dtStart() ); |
243 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 243 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
244 | attList << event->summary(); | 244 | attList << event->summary(); |
245 | attList << event->location(); | 245 | attList << event->location(); |
246 | QString alarmString = "na"; | 246 | QString alarmString = "na"; |
247 | Alarm *alarm; | 247 | Alarm *alarm; |
248 | if ( event->alarms().count() > 0 ) { | 248 | if ( event->alarms().count() > 0 ) { |
249 | alarm = event->alarms().first(); | 249 | alarm = event->alarms().first(); |
250 | if ( alarm->enabled() ) { | 250 | if ( alarm->enabled() ) { |
251 | alarmString = QString::number( alarm->offset() ); | 251 | alarmString = QString::number( alarm->offset() ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | attList << alarmString; | 254 | attList << alarmString; |
255 | Recurrence* rec = event->recurrence(); | 255 | Recurrence* rec = event->recurrence(); |
256 | QStringList list; | 256 | QStringList list; |
257 | bool writeEndDate = false; | 257 | bool writeEndDate = false; |
258 | switch ( rec->doesRecur() ) | 258 | switch ( rec->doesRecur() ) |
259 | { | 259 | { |
260 | case Recurrence::rDaily: // 0 | 260 | case Recurrence::rDaily: // 0 |
261 | list.append( "0" ); | 261 | list.append( "0" ); |
262 | list.append( QString::number( rec->frequency() ));//12 | 262 | list.append( QString::number( rec->frequency() ));//12 |
263 | list.append( "0" ); | 263 | list.append( "0" ); |
264 | list.append( "0" ); | 264 | list.append( "0" ); |
265 | writeEndDate = true; | 265 | writeEndDate = true; |
266 | break; | 266 | break; |
267 | case Recurrence::rWeekly:// 1 | 267 | case Recurrence::rWeekly:// 1 |
268 | list.append( "1" ); | 268 | list.append( "1" ); |
269 | list.append( QString::number( rec->frequency()) );//12 | 269 | list.append( QString::number( rec->frequency()) );//12 |
270 | list.append( "0" ); | 270 | list.append( "0" ); |
271 | { | 271 | { |
272 | int days = 0; | 272 | int days = 0; |
273 | QBitArray weekDays = rec->days(); | 273 | QBitArray weekDays = rec->days(); |
274 | int i; | 274 | int i; |
275 | for( i = 1; i <= 7; ++i ) { | 275 | for( i = 1; i <= 7; ++i ) { |
276 | if ( weekDays[i-1] ) { | 276 | if ( weekDays[i-1] ) { |
277 | days += 1 << (i-1); | 277 | days += 1 << (i-1); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | list.append( QString::number( days ) ); | 280 | list.append( QString::number( days ) ); |
281 | } | 281 | } |
282 | //pending weekdays | 282 | //pending weekdays |
283 | writeEndDate = true; | 283 | writeEndDate = true; |
284 | 284 | ||
285 | break; | 285 | break; |
286 | case Recurrence::rMonthlyPos:// 2 | 286 | case Recurrence::rMonthlyPos:// 2 |
287 | list.append( "2" ); | 287 | list.append( "2" ); |
288 | list.append( QString::number( rec->frequency()) );//12 | 288 | list.append( QString::number( rec->frequency()) );//12 |
289 | 289 | ||
290 | writeEndDate = true; | 290 | writeEndDate = true; |
291 | { | 291 | { |
292 | int count = 1; | 292 | int count = 1; |
293 | QPtrList<Recurrence::rMonthPos> rmp; | 293 | QPtrList<Recurrence::rMonthPos> rmp; |
294 | rmp = rec->monthPositions(); | 294 | rmp = rec->monthPositions(); |
295 | if ( rmp.first()->negative ) | 295 | if ( rmp.first()->negative ) |
296 | count = 5 - rmp.first()->rPos - 1; | 296 | count = 5 - rmp.first()->rPos - 1; |
297 | else | 297 | else |
298 | count = rmp.first()->rPos - 1; | 298 | count = rmp.first()->rPos - 1; |
299 | list.append( QString::number( count ) ); | 299 | list.append( QString::number( count ) ); |
300 | 300 | ||
301 | } | 301 | } |
302 | 302 | ||
303 | list.append( "0" ); | 303 | list.append( "0" ); |
304 | break; | 304 | break; |
305 | case Recurrence::rMonthlyDay:// 3 | 305 | case Recurrence::rMonthlyDay:// 3 |
306 | list.append( "3" ); | 306 | list.append( "3" ); |
307 | list.append( QString::number( rec->frequency()) );//12 | 307 | list.append( QString::number( rec->frequency()) );//12 |
308 | list.append( "0" ); | 308 | list.append( "0" ); |
309 | list.append( "0" ); | 309 | list.append( "0" ); |
310 | writeEndDate = true; | 310 | writeEndDate = true; |
311 | break; | 311 | break; |
312 | case Recurrence::rYearlyMonth://4 | 312 | case Recurrence::rYearlyMonth://4 |
313 | list.append( "4" ); | 313 | list.append( "4" ); |
314 | list.append( QString::number( rec->frequency()) );//12 | 314 | list.append( QString::number( rec->frequency()) );//12 |
315 | list.append( "0" ); | 315 | list.append( "0" ); |
316 | list.append( "0" ); | 316 | list.append( "0" ); |
317 | writeEndDate = true; | 317 | writeEndDate = true; |
318 | break; | 318 | break; |
319 | 319 | ||
320 | default: | 320 | default: |
321 | list.append( "255" ); | 321 | list.append( "255" ); |
322 | list.append( QString() ); | 322 | list.append( QString() ); |
323 | list.append( "0" ); | 323 | list.append( "0" ); |
324 | list.append( QString() ); | 324 | list.append( QString() ); |
325 | list.append( "0" ); | 325 | list.append( "0" ); |
326 | list.append( "20991231T000000" ); | 326 | list.append( "20991231T000000" ); |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | if ( writeEndDate ) { | 329 | if ( writeEndDate ) { |
330 | 330 | ||
331 | if ( rec->endDate().isValid() ) { // 15 + 16 | 331 | if ( rec->endDate().isValid() ) { // 15 + 16 |
332 | list.append( "1" ); | 332 | list.append( "1" ); |
333 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 333 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
334 | } else { | 334 | } else { |
335 | list.append( "0" ); | 335 | list.append( "0" ); |
336 | list.append( "20991231T000000" ); | 336 | list.append( "20991231T000000" ); |
337 | } | 337 | } |
338 | 338 | ||
339 | } | 339 | } |
340 | attList << list.join(""); | 340 | attList << list.join(""); |
341 | attList << event->categoriesStr(); | 341 | attList << event->categoriesStr(); |
342 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 342 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
343 | 343 | ||
344 | attList << event->secrecyStr(); | 344 | attList << event->secrecyStr(); |
345 | return PhoneFormat::getCsum(attList ); | 345 | return PhoneFormat::getCsum(attList ); |
346 | } | 346 | } |
347 | ulong PhoneFormat::getCsum( const QStringList & attList) | 347 | ulong PhoneFormat::getCsum( const QStringList & attList) |
348 | { | 348 | { |
349 | int max = attList.count(); | 349 | int max = attList.count(); |
350 | ulong cSum = 0; | 350 | ulong cSum = 0; |
351 | int j,k,i; | 351 | int j,k,i; |
352 | int add; | 352 | int add; |
353 | for ( i = 0; i < max ; ++i ) { | 353 | for ( i = 0; i < max ; ++i ) { |
354 | QString s = attList[i]; | 354 | QString s = attList[i]; |
355 | if ( ! s.isEmpty() ){ | 355 | if ( ! s.isEmpty() ){ |
356 | j = s.length(); | 356 | j = s.length(); |
357 | for ( k = 0; k < j; ++k ) { | 357 | for ( k = 0; k < j; ++k ) { |
358 | int mul = k +1; | 358 | int mul = k +1; |
359 | add = s[k].unicode (); | 359 | add = s[k].unicode (); |
360 | if ( k < 16 ) | 360 | if ( k < 16 ) |
361 | mul = mul * mul; | 361 | mul = mul * mul; |
362 | int ii = i+1; | 362 | int ii = i+1; |
363 | add = add * mul *ii*ii*ii; | 363 | add = add * mul *ii*ii*ii; |
364 | cSum += add; | 364 | cSum += add; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | } | 368 | } |
369 | //QString dump = attList.join(","); | 369 | //QString dump = attList.join(","); |
370 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 370 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
371 | 371 | ||
372 | return cSum; | 372 | return cSum; |
373 | 373 | ||
374 | } | 374 | } |
375 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 375 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
376 | #include <stdlib.h> | 376 | #include <stdlib.h> |
377 | #define DEBUGMODE false | 377 | #define DEBUGMODE false |
378 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 378 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
379 | { | 379 | { |
380 | 380 | ||
381 | QString fileName; | 381 | QString fileName; |
382 | #ifdef _WIN32_ | 382 | #ifdef _WIN32_ |
383 | fileName = locateLocal("tmp", "tempfile.vcs") | 383 | fileName = locateLocal("tmp", "tempfile.vcs"); |
384 | #else | 384 | #else |
385 | fileName = "/tmp/kdepimtemp.vcs"; | 385 | fileName = "/tmp/kdepimtemp.vcs"; |
386 | #endif | 386 | #endif |
387 | #ifdef DESKTOP_VERSION | 387 | #ifdef DESKTOP_VERSION |
388 | QString command ="./kammu --backup " + fileName + " -yes" ; | 388 | QString command ="./kammu --backup " + fileName + " -yes" ; |
389 | #else | 389 | #else |
390 | QString command ="kammu --backup " + fileName + " -yes" ; | 390 | QString command ="kammu --backup " + fileName + " -yes" ; |
391 | #endif | 391 | #endif |
392 | int ret = system ( command.latin1() ); | 392 | int ret = system ( command.latin1() ); |
393 | if ( ret != 0 ) { | 393 | if ( ret != 0 ) { |
394 | qDebug("Error::command returned %d", ret); | 394 | qDebug("Error::command returned %d", ret); |
395 | return false; | 395 | return false; |
396 | } | 396 | } |
397 | VCalFormat vfload; | 397 | VCalFormat vfload; |
398 | vfload.setLocalTime ( true ); | 398 | vfload.setLocalTime ( true ); |
399 | qDebug("loading file ..."); | 399 | qDebug("loading file ..."); |
400 | 400 | ||
401 | if ( ! vfload.load( calendar, fileName ) ) | 401 | if ( ! vfload.load( calendar, fileName ) ) |
402 | return false; | 402 | return false; |
403 | QPtrList<Event> er = calendar->rawEvents(); | 403 | QPtrList<Event> er = calendar->rawEvents(); |
404 | Event* ev = er.first(); | 404 | Event* ev = er.first(); |
405 | qDebug("reading events... "); | 405 | qDebug("reading events... "); |
406 | while ( ev ) { | 406 | while ( ev ) { |
407 | QStringList cat = ev->categories(); | 407 | QStringList cat = ev->categories(); |
408 | if ( cat.contains( "MeetingDEF" )) { | 408 | if ( cat.contains( "MeetingDEF" )) { |
409 | ev->setCategories( QStringList() ); | 409 | ev->setCategories( QStringList() ); |
410 | } | 410 | } |
411 | int id = ev->pilotId(); | 411 | int id = ev->pilotId(); |
412 | Event *event; | 412 | Event *event; |
413 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 413 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
414 | if ( event ) { | 414 | if ( event ) { |
415 | event = (Event*)event->clone(); | 415 | event = (Event*)event->clone(); |
416 | copyEvent( event, ev ); | 416 | copyEvent( event, ev ); |
417 | calendar->deleteEvent( ev ); | 417 | calendar->deleteEvent( ev ); |
418 | calendar->addEvent( event); | 418 | calendar->addEvent( event); |
419 | } | 419 | } |
420 | else | 420 | else |
421 | event = ev; | 421 | event = ev; |
422 | uint cSum; | 422 | uint cSum; |
423 | cSum = PhoneFormat::getCsumEvent( event ); | 423 | cSum = PhoneFormat::getCsumEvent( event ); |
424 | event->setCsum( mProfileName, QString::number( cSum )); | 424 | event->setCsum( mProfileName, QString::number( cSum )); |
425 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 425 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
426 | event->setID( mProfileName,QString::number( id ) ); | 426 | event->setID( mProfileName,QString::number( id ) ); |
427 | ev = er.next(); | 427 | ev = er.next(); |
428 | } | 428 | } |
429 | { | 429 | { |
430 | qDebug("reading todos... "); | 430 | qDebug("reading todos... "); |
431 | QPtrList<Todo> tr = calendar->rawTodos(); | 431 | QPtrList<Todo> tr = calendar->rawTodos(); |
432 | Todo* ev = tr.first(); | 432 | Todo* ev = tr.first(); |
433 | while ( ev ) { | 433 | while ( ev ) { |
434 | 434 | ||
435 | QStringList cat = ev->categories(); | 435 | QStringList cat = ev->categories(); |
436 | if ( cat.contains( "MeetingDEF" )) { | 436 | if ( cat.contains( "MeetingDEF" )) { |
437 | ev->setCategories( QStringList() ); | 437 | ev->setCategories( QStringList() ); |
438 | } | 438 | } |
439 | int id = ev->pilotId(); | 439 | int id = ev->pilotId(); |
440 | Todo *event; | 440 | Todo *event; |
441 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 441 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
442 | if ( event ) { | 442 | if ( event ) { |
443 | //qDebug("copy todo %s ", event->summary().latin1()); | 443 | //qDebug("copy todo %s ", event->summary().latin1()); |
444 | 444 | ||
445 | event = (Todo*)event->clone(); | 445 | event = (Todo*)event->clone(); |
446 | copyTodo( event, ev ); | 446 | copyTodo( event, ev ); |
447 | calendar->deleteTodo( ev ); | 447 | calendar->deleteTodo( ev ); |
448 | calendar->addTodo( event); | 448 | calendar->addTodo( event); |
449 | } | 449 | } |
450 | else | 450 | else |
451 | event = ev; | 451 | event = ev; |
452 | uint cSum; | 452 | uint cSum; |
453 | cSum = PhoneFormat::getCsumTodo( event ); | 453 | cSum = PhoneFormat::getCsumTodo( event ); |
454 | event->setCsum( mProfileName, QString::number( cSum )); | 454 | event->setCsum( mProfileName, QString::number( cSum )); |
455 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 455 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
456 | event->setID( mProfileName,QString::number( id ) ); | 456 | event->setID( mProfileName,QString::number( id ) ); |
457 | ev = tr.next(); | 457 | ev = tr.next(); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | return true; | 460 | return true; |
461 | } | 461 | } |
462 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 462 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
463 | { | 463 | { |
464 | if ( from->dtStart().isValid() ) | 464 | if ( from->dtStart().isValid() ) |
465 | to->setDtStart( from->dtStart() ); | 465 | to->setDtStart( from->dtStart() ); |
466 | if ( from->dtEnd().isValid() ) | 466 | if ( from->dtEnd().isValid() ) |
467 | to->setDtEnd( from->dtEnd() ); | 467 | to->setDtEnd( from->dtEnd() ); |
468 | if ( !from->location().isEmpty() ) | 468 | if ( !from->location().isEmpty() ) |
469 | to->setLocation( from->location() ); | 469 | to->setLocation( from->location() ); |
470 | if ( !from->description().isEmpty() ) | 470 | if ( !from->description().isEmpty() ) |
471 | to->setDescription( from->description() ); | 471 | to->setDescription( from->description() ); |
472 | if ( !from->summary().isEmpty() ) | 472 | if ( !from->summary().isEmpty() ) |
473 | to->setSummary( from->summary() ); | 473 | to->setSummary( from->summary() ); |
474 | 474 | ||
475 | if ( from->alarms().count() ) { | 475 | if ( from->alarms().count() ) { |
476 | to->clearAlarms(); | 476 | to->clearAlarms(); |
477 | Alarm *a = from->alarms().first(); | 477 | Alarm *a = from->alarms().first(); |
478 | Alarm *b = to->newAlarm( ); | 478 | Alarm *b = to->newAlarm( ); |
479 | b->setEnabled( a->enabled() ); | 479 | b->setEnabled( a->enabled() ); |
480 | if ( a->hasStartOffset() ) { | 480 | if ( a->hasStartOffset() ) { |
481 | b->setStartOffset( a->startOffset() ); | 481 | b->setStartOffset( a->startOffset() ); |
482 | } | 482 | } |
483 | if ( a->hasTime() ) | 483 | if ( a->hasTime() ) |
484 | b->setTime( a->time() ); | 484 | b->setTime( a->time() ); |
485 | 485 | ||
486 | } | 486 | } |
487 | QStringList cat = to->categories(); | 487 | QStringList cat = to->categories(); |
488 | QStringList catFrom = from->categories(); | 488 | QStringList catFrom = from->categories(); |
489 | QString nCat; | 489 | QString nCat; |
490 | int iii; | 490 | int iii; |
491 | for ( iii = 0; iii < catFrom.count();++iii ) { | 491 | for ( iii = 0; iii < catFrom.count();++iii ) { |
492 | nCat = catFrom[iii]; | 492 | nCat = catFrom[iii]; |
493 | if ( !nCat.isEmpty() ) | 493 | if ( !nCat.isEmpty() ) |
494 | if ( !cat.contains( nCat )) { | 494 | if ( !cat.contains( nCat )) { |
495 | cat << nCat; | 495 | cat << nCat; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | to->setCategories( cat ); | 498 | to->setCategories( cat ); |
499 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 499 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
500 | to->setRecurrence( r ) ; | 500 | to->setRecurrence( r ) ; |
501 | 501 | ||
502 | 502 | ||
503 | } | 503 | } |
504 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 504 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
505 | { | 505 | { |
506 | if ( from->dtStart().isValid() ) | 506 | if ( from->dtStart().isValid() ) |
507 | to->setDtStart( from->dtStart() ); | 507 | to->setDtStart( from->dtStart() ); |
508 | if ( from->dtDue().isValid() ) | 508 | if ( from->dtDue().isValid() ) |
509 | to->setDtDue( from->dtDue() ); | 509 | to->setDtDue( from->dtDue() ); |
510 | if ( !from->location().isEmpty() ) | 510 | if ( !from->location().isEmpty() ) |
511 | to->setLocation( from->location() ); | 511 | to->setLocation( from->location() ); |
512 | if ( !from->description().isEmpty() ) | 512 | if ( !from->description().isEmpty() ) |
513 | to->setDescription( from->description() ); | 513 | to->setDescription( from->description() ); |
514 | if ( !from->summary().isEmpty() ) | 514 | if ( !from->summary().isEmpty() ) |
515 | to->setSummary( from->summary() ); | 515 | to->setSummary( from->summary() ); |
516 | 516 | ||
517 | if ( from->alarms().count() ) { | 517 | if ( from->alarms().count() ) { |
518 | to->clearAlarms(); | 518 | to->clearAlarms(); |
519 | Alarm *a = from->alarms().first(); | 519 | Alarm *a = from->alarms().first(); |
520 | Alarm *b = to->newAlarm( ); | 520 | Alarm *b = to->newAlarm( ); |
521 | b->setEnabled( a->enabled() ); | 521 | b->setEnabled( a->enabled() ); |
522 | if ( a->hasStartOffset() ) | 522 | if ( a->hasStartOffset() ) |
523 | b->setStartOffset( a->startOffset() ); | 523 | b->setStartOffset( a->startOffset() ); |
524 | if ( a->hasTime() ) | 524 | if ( a->hasTime() ) |
525 | b->setTime( a->time() ); | 525 | b->setTime( a->time() ); |
526 | } | 526 | } |
527 | 527 | ||
528 | QStringList cat = to->categories(); | 528 | QStringList cat = to->categories(); |
529 | QStringList catFrom = from->categories(); | 529 | QStringList catFrom = from->categories(); |
530 | QString nCat; | 530 | QString nCat; |
531 | int iii; | 531 | int iii; |
532 | for ( iii = 0; iii < catFrom.count();++iii ) { | 532 | for ( iii = 0; iii < catFrom.count();++iii ) { |
533 | nCat = catFrom[iii]; | 533 | nCat = catFrom[iii]; |
534 | if ( !nCat.isEmpty() ) | 534 | if ( !nCat.isEmpty() ) |
535 | if ( !cat.contains( nCat )) { | 535 | if ( !cat.contains( nCat )) { |
536 | cat << nCat; | 536 | cat << nCat; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | to->setCategories( cat ); | 539 | to->setCategories( cat ); |
540 | if ( from->isCompleted() ) { | 540 | if ( from->isCompleted() ) { |
541 | to->setCompleted( true ); | 541 | to->setCompleted( true ); |
542 | if( from->completed().isValid() ) | 542 | if( from->completed().isValid() ) |
543 | to->setCompleted( from->completed() ); | 543 | to->setCompleted( from->completed() ); |
544 | } else { | 544 | } else { |
545 | // set percentcomplete only, if to->isCompleted() | 545 | // set percentcomplete only, if to->isCompleted() |
546 | if ( to->isCompleted() ) | 546 | if ( to->isCompleted() ) |
547 | to->setPercentComplete(from->percentComplete()); | 547 | to->setPercentComplete(from->percentComplete()); |
548 | } | 548 | } |
549 | if( to->priority() == 2 && from->priority() == 1 ) | 549 | if( to->priority() == 2 && from->priority() == 1 ) |
550 | ; //skip | 550 | ; //skip |
551 | else if (to->priority() == 4 && from->priority() == 5 ) | 551 | else if (to->priority() == 4 && from->priority() == 5 ) |
552 | ; | 552 | ; |
553 | else | 553 | else |
554 | to->setPriority(from->priority()); | 554 | to->setPriority(from->priority()); |
555 | 555 | ||
556 | } | 556 | } |
557 | #include <qcstring.h> | 557 | #include <qcstring.h> |
558 | 558 | ||
559 | void PhoneFormat::afterSave( Incidence* inc) | 559 | void PhoneFormat::afterSave( Incidence* inc) |
560 | { | 560 | { |
561 | uint csum; | 561 | uint csum; |
562 | inc->removeID( mProfileName ); | 562 | inc->removeID( mProfileName ); |
563 | if ( inc->type() == "Event") | 563 | if ( inc->type() == "Event") |
564 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 564 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
565 | else | 565 | else |
566 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 566 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
567 | inc->setCsum( mProfileName, QString::number( csum )); | 567 | inc->setCsum( mProfileName, QString::number( csum )); |
568 | 568 | ||
569 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 569 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
570 | 570 | ||
571 | } | 571 | } |
572 | bool PhoneFormat::save( Calendar *calendar) | 572 | bool PhoneFormat::save( Calendar *calendar) |
573 | { | 573 | { |
574 | QLabel status ( i18n(" Opening device ..."), 0 ); | 574 | QLabel status ( i18n(" Opening device ..."), 0 ); |
575 | int w = status.sizeHint().width()+20 ; | 575 | int w = status.sizeHint().width()+20 ; |
576 | if ( w < 200 ) w = 230; | 576 | if ( w < 200 ) w = 230; |
577 | int h = status.sizeHint().height()+20 ; | 577 | int h = status.sizeHint().height()+20 ; |
578 | int dw = QApplication::desktop()->width(); | 578 | int dw = QApplication::desktop()->width(); |
579 | int dh = QApplication::desktop()->height(); | 579 | int dh = QApplication::desktop()->height(); |
580 | status.setCaption(i18n("Writing to phone...") ); | 580 | status.setCaption(i18n("Writing to phone...") ); |
581 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 581 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
582 | status.show(); | 582 | status.show(); |
583 | status.raise(); | 583 | status.raise(); |
584 | qApp->processEvents(); | 584 | qApp->processEvents(); |
585 | QString message; | 585 | QString message; |
586 | #ifdef _WIN32_ | 586 | #ifdef _WIN32_ |
587 | QString fileName = locateLocal("tmp", "tempfile.vcs") | 587 | QString fileName = locateLocal("tmp", "tempfile.vcs"); |
588 | #else | 588 | #else |
589 | QString fileName = "/tmp/kdepimtemp.vcs"; | 589 | QString fileName = "/tmp/kdepimtemp.vcs"; |
590 | #endif | 590 | #endif |
591 | 591 | ||
592 | // 1 remove events which should be deleted | 592 | // 1 remove events which should be deleted |
593 | QPtrList<Event> er = calendar->rawEvents(); | 593 | QPtrList<Event> er = calendar->rawEvents(); |
594 | Event* ev = er.first(); | 594 | Event* ev = er.first(); |
595 | while ( ev ) { | 595 | while ( ev ) { |
596 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 596 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
597 | calendar->deleteEvent( ev ); | 597 | calendar->deleteEvent( ev ); |
598 | } else { | 598 | } else { |
599 | 599 | ||
600 | } | 600 | } |
601 | ev = er.next(); | 601 | ev = er.next(); |
602 | } | 602 | } |
603 | // 2 remove todos which should be deleted | 603 | // 2 remove todos which should be deleted |
604 | QPtrList<Todo> tl = calendar->rawTodos(); | 604 | QPtrList<Todo> tl = calendar->rawTodos(); |
605 | Todo* to = tl.first(); | 605 | Todo* to = tl.first(); |
606 | while ( to ) { | 606 | while ( to ) { |
607 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 607 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
608 | calendar->deleteTodo( to ); | 608 | calendar->deleteTodo( to ); |
609 | } else { | 609 | } else { |
610 | if ( to->isCompleted()) { | 610 | if ( to->isCompleted()) { |
611 | calendar->deleteTodo( to ); | 611 | calendar->deleteTodo( to ); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | to = tl.next(); | 614 | to = tl.next(); |
615 | } | 615 | } |
616 | // 3 save file | 616 | // 3 save file |
617 | VCalFormat vfsave; | 617 | VCalFormat vfsave; |
618 | vfsave.setLocalTime ( true ); | 618 | vfsave.setLocalTime ( true ); |
619 | if ( ! vfsave.save( calendar, fileName ) ) | 619 | if ( ! vfsave.save( calendar, fileName ) ) |
620 | return false; | 620 | return false; |
621 | // 4 call kammu | 621 | // 4 call kammu |
622 | #ifdef DESKTOP_VERSION | 622 | #ifdef DESKTOP_VERSION |
623 | QString command ="./kammu --restore " + fileName ; | 623 | QString command ="./kammu --restore " + fileName ; |
624 | #else | 624 | #else |
625 | QString command ="kammu --restore " + fileName ; | 625 | QString command ="kammu --restore " + fileName ; |
626 | #endif | 626 | #endif |
627 | int ret; | 627 | int ret; |
628 | while ( (ret = system ( command.latin1())) != 0 ) { | 628 | while ( (ret = system ( command.latin1())) != 0 ) { |
629 | qDebug("Error S::command returned %d. asking users", ret); | 629 | qDebug("Error S::command returned %d. asking users", ret); |
630 | int retval = KMessageBox::warningContinueCancel(0, | 630 | int retval = KMessageBox::warningContinueCancel(0, |
631 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); | 631 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); |
632 | if ( retval != KMessageBox::Continue ) | 632 | if ( retval != KMessageBox::Continue ) |
633 | return false; | 633 | return false; |
634 | } | 634 | } |
635 | 635 | ||
636 | // 5 reread data | 636 | // 5 reread data |
637 | message = i18n(" Rereading all data ... "); | 637 | message = i18n(" Rereading all data ... "); |
638 | status.setText ( message ); | 638 | status.setText ( message ); |
639 | qApp->processEvents(); | 639 | qApp->processEvents(); |
640 | CalendarLocal* calendarTemp = new CalendarLocal(); | 640 | CalendarLocal* calendarTemp = new CalendarLocal(); |
641 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 641 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
642 | if ( ! load( calendarTemp,calendar) ){ | 642 | if ( ! load( calendarTemp,calendar) ){ |
643 | qDebug("error reloading calendar "); | 643 | qDebug("error reloading calendar "); |
644 | delete calendarTemp; | 644 | delete calendarTemp; |
645 | return false; | 645 | return false; |
646 | } | 646 | } |
647 | // 6 compare data | 647 | // 6 compare data |
648 | 648 | ||
649 | //algo 6 compare event | 649 | //algo 6 compare event |
650 | er = calendar->rawEvents(); | 650 | er = calendar->rawEvents(); |
651 | ev = er.first(); | 651 | ev = er.first(); |
652 | message = i18n(" Comparing event # "); | 652 | message = i18n(" Comparing event # "); |
653 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 653 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
654 | Event* ev1; | 654 | Event* ev1; |
655 | int procCount = 0; | 655 | int procCount = 0; |
656 | while ( ev ) { | 656 | while ( ev ) { |
657 | //qDebug("event new ID %s",ev->summary().latin1()); | 657 | //qDebug("event new ID %s",ev->summary().latin1()); |
658 | status.setText ( message + QString::number ( ++procCount ) ); | 658 | status.setText ( message + QString::number ( ++procCount ) ); |
659 | qApp->processEvents(); | 659 | qApp->processEvents(); |
660 | uint csum; | 660 | uint csum; |
661 | csum = PhoneFormat::getCsumEvent( ev ); | 661 | csum = PhoneFormat::getCsumEvent( ev ); |
662 | QString cSum = QString::number( csum ); | 662 | QString cSum = QString::number( csum ); |
663 | //ev->setCsum( mProfileName, cSum ); | 663 | //ev->setCsum( mProfileName, cSum ); |
664 | //qDebug("Event cSum %s ", cSum.latin1()); | 664 | //qDebug("Event cSum %s ", cSum.latin1()); |
665 | ev1 = er1.first(); | 665 | ev1 = er1.first(); |
666 | while ( ev1 ) { | 666 | while ( ev1 ) { |
667 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 667 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
668 | er1.remove( ev1 ); | 668 | er1.remove( ev1 ); |
669 | afterSave( ev ); | 669 | afterSave( ev ); |
670 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 670 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
671 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | 671 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); |
672 | 672 | ||
673 | break; | 673 | break; |
674 | } | 674 | } |
675 | ev1 = er1.next(); | 675 | ev1 = er1.next(); |
676 | } | 676 | } |
677 | if ( ! ev1 ) { | 677 | if ( ! ev1 ) { |
678 | // ev->removeID(mProfileName); | 678 | // ev->removeID(mProfileName); |
679 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 679 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
680 | } | 680 | } |
681 | 681 | ||
682 | 682 | ||
683 | ev = er.next(); | 683 | ev = er.next(); |
684 | } | 684 | } |
685 | //algo 6 compare todo | 685 | //algo 6 compare todo |
686 | tl = calendar->rawTodos(); | 686 | tl = calendar->rawTodos(); |
687 | to = tl.first(); | 687 | to = tl.first(); |
688 | procCount = 0; | 688 | procCount = 0; |
689 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 689 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
690 | Todo* to1 ; | 690 | Todo* to1 ; |
691 | message = i18n(" Comparing todo # "); | 691 | message = i18n(" Comparing todo # "); |
692 | while ( to ) { | 692 | while ( to ) { |
693 | status.setText ( message + QString::number ( ++procCount ) ); | 693 | status.setText ( message + QString::number ( ++procCount ) ); |
694 | qApp->processEvents(); | 694 | qApp->processEvents(); |
695 | uint csum; | 695 | uint csum; |
696 | csum = PhoneFormat::getCsumTodo( to ); | 696 | csum = PhoneFormat::getCsumTodo( to ); |
697 | QString cSum = QString::number( csum ); | 697 | QString cSum = QString::number( csum ); |
698 | //to->setCsum( mProfileName, cSum ); | 698 | //to->setCsum( mProfileName, cSum ); |
699 | //qDebug("Todo cSum %s ", cSum.latin1()); | 699 | //qDebug("Todo cSum %s ", cSum.latin1()); |
700 | Todo* to1 = tl1.first(); | 700 | Todo* to1 = tl1.first(); |
701 | while ( to1 ) { | 701 | while ( to1 ) { |
702 | if ( to1->getCsum( mProfileName ) == cSum ) { | 702 | if ( to1->getCsum( mProfileName ) == cSum ) { |
703 | tl1.remove( to1 ); | 703 | tl1.remove( to1 ); |
704 | afterSave( to ); | 704 | afterSave( to ); |
705 | to->setID(mProfileName, to1->getID(mProfileName) ); | 705 | to->setID(mProfileName, to1->getID(mProfileName) ); |
706 | break; | 706 | break; |
707 | } | 707 | } |
708 | to1 = tl1.next(); | 708 | to1 = tl1.next(); |
709 | } | 709 | } |
710 | if ( ! to1 ) { | 710 | if ( ! to1 ) { |
711 | //to->removeID(mProfileName); | 711 | //to->removeID(mProfileName); |
712 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 712 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
713 | } | 713 | } |
714 | 714 | ||
715 | to = tl.next(); | 715 | to = tl.next(); |
716 | } | 716 | } |
717 | delete calendarTemp; | 717 | delete calendarTemp; |
718 | return true; | 718 | return true; |
719 | 719 | ||
720 | 720 | ||
721 | 721 | ||
722 | } | 722 | } |
723 | 723 | ||
724 | 724 | ||
725 | QString PhoneFormat::toString( Calendar * ) | 725 | QString PhoneFormat::toString( Calendar * ) |
726 | { | 726 | { |
727 | return QString::null; | 727 | return QString::null; |
728 | } | 728 | } |
729 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 729 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
730 | { | 730 | { |
731 | return false; | 731 | return false; |
732 | } | 732 | } |