author | zautrix <zautrix> | 2004-08-01 21:34:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 21:34:31 (UTC) |
commit | ed3af1a632f953179ef3cad76ab5d99809f47d60 (patch) (unidiff) | |
tree | be4fdfcf808d6876b4bee0698ddc17c8d20313d4 /libkcal | |
parent | 062113379f93ed645d2f246183c89eb8b6814834 (diff) | |
download | kdepimpi-ed3af1a632f953179ef3cad76ab5d99809f47d60.zip kdepimpi-ed3af1a632f953179ef3cad76ab5d99809f47d60.tar.gz kdepimpi-ed3af1a632f953179ef3cad76ab5d99809f47d60.tar.bz2 |
More sync work
-rw-r--r-- | libkcal/icalformatimpl.cpp | 16 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 81 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 8 |
3 files changed, 92 insertions, 13 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index df05ab3..c23978d 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -267,13 +267,10 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | |||
267 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); | 267 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); |
268 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); | 268 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); |
269 | } | 269 | } |
270 | if (incidence->zaurusId() >= 0) { | 270 | if ( !incidence->IDStr().isEmpty()) { |
271 | incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); | 271 | incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); |
272 | } | 272 | } |
273 | 273 | ||
274 | if (incidence->zaurusUid() > 0) { | ||
275 | incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); | ||
276 | } | ||
277 | 274 | ||
278 | writeIncidenceBase(parent,incidence); | 275 | writeIncidenceBase(parent,incidence); |
279 | if (incidence->cancelled()) { | 276 | if (incidence->cancelled()) { |
@@ -1280,14 +1277,11 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | |||
1280 | if (!kp.isNull()) { | 1277 | if (!kp.isNull()) { |
1281 | incidence->setSyncStatus(kp.toInt()); | 1278 | incidence->setSyncStatus(kp.toInt()); |
1282 | } | 1279 | } |
1283 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); | ||
1284 | if (!kp.isNull()) { | ||
1285 | incidence->setZaurusId(kp.toInt()); | ||
1286 | } | ||
1287 | 1280 | ||
1288 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); | 1281 | |
1282 | kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); | ||
1289 | if (!kp.isNull()) { | 1283 | if (!kp.isNull()) { |
1290 | incidence->setZaurusUid(kp.toInt()); | 1284 | incidence->setIDStr(kp); |
1291 | } | 1285 | } |
1292 | 1286 | ||
1293 | // Cancel backwards compatibility mode for subsequent changes by the application | 1287 | // Cancel backwards compatibility mode for subsequent changes by the application |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 707d666..d7c4595 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -40,6 +40,7 @@ IncidenceBase::IncidenceBase() : | |||
40 | mPilotId = 0; | 40 | mPilotId = 0; |
41 | mZaurusId = -1; | 41 | mZaurusId = -1; |
42 | mZaurusUid = 0; | 42 | mZaurusUid = 0; |
43 | mExternalId = ":"; | ||
43 | mTempSyncStat = 0; | 44 | mTempSyncStat = 0; |
44 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
45 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
@@ -65,7 +66,7 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) : | |||
65 | mZaurusUid = i.mZaurusUid; | 66 | mZaurusUid = i.mZaurusUid; |
66 | mTempSyncStat = i.mTempSyncStat; | 67 | mTempSyncStat = i.mTempSyncStat; |
67 | mSyncStatus = i.mSyncStatus; | 68 | mSyncStatus = i.mSyncStatus; |
68 | 69 | mExternalId = i.mExternalId; | |
69 | // The copied object is a new one, so it isn't observed by the observer | 70 | // The copied object is a new one, so it isn't observed by the observer |
70 | // of the original object. | 71 | // of the original object. |
71 | mObservers.clear(); | 72 | mObservers.clear(); |
@@ -80,7 +81,7 @@ IncidenceBase::~IncidenceBase() | |||
80 | 81 | ||
81 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 82 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
82 | { | 83 | { |
83 | 84 | // do not compare mSyncStatus and mExternalId | |
84 | if( i1.attendees().count() != i2.attendees().count() ) { | 85 | if( i1.attendees().count() != i2.attendees().count() ) { |
85 | return false; // no need to check further | 86 | return false; // no need to check further |
86 | } | 87 | } |
@@ -372,6 +373,82 @@ void IncidenceBase::setTempSyncStat( int id ) | |||
372 | mTempSyncStat = id; | 373 | mTempSyncStat = id; |
373 | } | 374 | } |
374 | 375 | ||
376 | void IncidenceBase::setID( const QString & prof , int id ) | ||
377 | { | ||
378 | int num = mExternalId.find( ":"+prof+";" ); | ||
379 | if ( num >= 0 ) { | ||
380 | int len = prof.length()+2; | ||
381 | int end = mExternalId.find( ";", num+len ); | ||
382 | if ( end > 0 ) { | ||
383 | mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end ); | ||
384 | } else | ||
385 | qDebug("Error in IncidenceBase::setID "); | ||
386 | } else { | ||
387 | mExternalId += prof+";"+QString::number( id) +";0:"; | ||
388 | } | ||
389 | } | ||
390 | int IncidenceBase::getID( const QString & prof) | ||
391 | { | ||
392 | int ret = -1; | ||
393 | int num = mExternalId.find(":"+ prof+";" ); | ||
394 | if ( num >= 0 ) { | ||
395 | int len = prof.length()+2; | ||
396 | int end = mExternalId.find( ";", num+len ); | ||
397 | if ( end > 0 ) { | ||
398 | bool ok; | ||
399 | ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok ); | ||
400 | if (!ok) | ||
401 | return -1; | ||
402 | } | ||
403 | } | ||
404 | return ret; | ||
405 | } | ||
406 | |||
407 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | ||
408 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | ||
409 | void IncidenceBase::setCsum( const QString & prof , int id ) | ||
410 | { | ||
411 | int num = mExternalId.find( ":"+prof+";"); | ||
412 | if ( num >= 0 ) { | ||
413 | int len = prof.length()+2; | ||
414 | num = mExternalId.find( ";", num+len ); | ||
415 | int end = mExternalId.find( ":", num+1 ); | ||
416 | if ( end > 0 ) { | ||
417 | mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end ); | ||
418 | } else | ||
419 | qDebug("Error in IncidenceBase::setCsum "); | ||
420 | } else { | ||
421 | mExternalId += prof+";-1;"+QString::number( id) +":"; | ||
422 | } | ||
423 | } | ||
424 | int IncidenceBase::getCsum( const QString & prof) | ||
425 | { | ||
426 | int ret = -1; | ||
427 | int num = mExternalId.find( ":"+prof+";" ); | ||
428 | if ( num >= 0 ) { | ||
429 | int len = prof.length()+2; | ||
430 | num = mExternalId.find( ";", num+len ); | ||
431 | int end = mExternalId.find( ":", num+1 ); | ||
432 | if ( end > 0 ) { | ||
433 | bool ok; | ||
434 | ret = mExternalId.mid ( num ,end-num).toInt( &ok ); | ||
435 | if (!ok) | ||
436 | return -1; | ||
437 | } | ||
438 | } | ||
439 | return ret; | ||
440 | } | ||
441 | |||
442 | void IncidenceBase::setIDStr( const QString & s ) | ||
443 | { | ||
444 | if (mReadOnly) return; | ||
445 | mExternalId = s; | ||
446 | } | ||
447 | |||
448 | QString IncidenceBase::IDStr() const | ||
449 | { | ||
450 | return mExternalId ; | ||
451 | } | ||
375 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 452 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
376 | { | 453 | { |
377 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 454 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index ce6e254..2f85df6 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -132,6 +132,13 @@ class IncidenceBase : public CustomProperties | |||
132 | int zaurusUid() const; | 132 | int zaurusUid() const; |
133 | void setTempSyncStat(int id); | 133 | void setTempSyncStat(int id); |
134 | int tempSyncStat() const; | 134 | int tempSyncStat() const; |
135 | void setIDStr( const QString & ); | ||
136 | QString IDStr() const; | ||
137 | void setID( const QString &, int ); | ||
138 | int getID( const QString & ); | ||
139 | void setCsum( const QString &, int ); | ||
140 | int getCsum( const QString & ); | ||
141 | |||
135 | 142 | ||
136 | void registerObserver( Observer * ); | 143 | void registerObserver( Observer * ); |
137 | void unRegisterObserver( Observer * ); | 144 | void unRegisterObserver( Observer * ); |
@@ -153,6 +160,7 @@ class IncidenceBase : public CustomProperties | |||
153 | 160 | ||
154 | int mDuration; | 161 | int mDuration; |
155 | bool mHasDuration; | 162 | bool mHasDuration; |
163 | QString mExternalId; | ||
156 | int mZaurusId; | 164 | int mZaurusId; |
157 | int mZaurusUid; | 165 | int mZaurusUid; |
158 | int mTempSyncStat; | 166 | int mTempSyncStat; |