summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-01 21:34:31 (UTC)
committer zautrix <zautrix>2004-08-01 21:34:31 (UTC)
commited3af1a632f953179ef3cad76ab5d99809f47d60 (patch) (unidiff)
treebe4fdfcf808d6876b4bee0698ddc17c8d20313d4
parent062113379f93ed645d2f246183c89eb8b6814834 (diff)
downloadkdepimpi-ed3af1a632f953179ef3cad76ab5d99809f47d60.zip
kdepimpi-ed3af1a632f953179ef3cad76ab5d99809f47d60.tar.gz
kdepimpi-ed3af1a632f953179ef3cad76ab5d99809f47d60.tar.bz2
More sync work
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp16
-rw-r--r--libkcal/incidencebase.cpp81
-rw-r--r--libkcal/incidencebase.h8
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
@@ -264,19 +264,16 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
264 // pilot sync stuff 264 // pilot sync stuff
265// TODO: move this application-specific code to kpilot 265// TODO: move this application-specific code to kpilot
266 if (incidence->pilotId()) { 266 if (incidence->pilotId()) {
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()) {
280 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 277 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
281 } 278 }
282 279
@@ -1277,20 +1274,17 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1277 incidence->setPilotId(kp.toInt()); 1274 incidence->setPilotId(kp.toInt());
1278 } 1275 }
1279 kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); 1276 kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
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
1294 incidence->recurrence()->setCompatVersion(); 1288 incidence->recurrence()->setCompatVersion();
1295 1289
1296 // add categories 1290 // add categories
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 707d666..d7c4595 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -37,12 +37,13 @@ IncidenceBase::IncidenceBase() :
37 mFloats = false; 37 mFloats = false;
38 mDuration = 0; 38 mDuration = 0;
39 mHasDuration = false; 39 mHasDuration = false;
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 );
46} 47}
47 48
48IncidenceBase::IncidenceBase(const IncidenceBase &i) : 49IncidenceBase::IncidenceBase(const IncidenceBase &i) :
@@ -62,13 +63,13 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
62 mLastModified = i.mLastModified; 63 mLastModified = i.mLastModified;
63 mPilotId = i.mPilotId; 64 mPilotId = i.mPilotId;
64 mZaurusId = i.mZaurusId; 65 mZaurusId = i.mZaurusId;
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();
72 73
73 mAttendees.setAutoDelete( true ); 74 mAttendees.setAutoDelete( true );
74} 75}
@@ -77,13 +78,13 @@ IncidenceBase::~IncidenceBase()
77{ 78{
78} 79}
79 80
80 81
81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 82bool 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 }
87 if ( i1.attendees().count() > 0 ) { 88 if ( i1.attendees().count() > 0 ) {
88 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 89 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
89 while ( a1 ) { 90 while ( a1 ) {
@@ -369,12 +370,88 @@ int IncidenceBase::tempSyncStat() const
369void IncidenceBase::setTempSyncStat( int id ) 370void IncidenceBase::setTempSyncStat( int id )
370{ 371{
371 if (mReadOnly) return; 372 if (mReadOnly) return;
372 mTempSyncStat = id; 373 mTempSyncStat = id;
373} 374}
374 375
376void 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}
390int 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
409void 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}
424int 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
442void IncidenceBase::setIDStr( const QString & s )
443{
444 if (mReadOnly) return;
445 mExternalId = s;
446}
447
448QString IncidenceBase::IDStr() const
449{
450 return mExternalId ;
451}
375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 452void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
376{ 453{
377 if( !mObservers.contains(observer) ) mObservers.append( observer ); 454 if( !mObservers.contains(observer) ) mObservers.append( observer );
378} 455}
379 456
380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 457void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index ce6e254..2f85df6 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -129,12 +129,19 @@ class IncidenceBase : public CustomProperties
129 void setZaurusId(int id); 129 void setZaurusId(int id);
130 int zaurusId() const; 130 int zaurusId() const;
131 void setZaurusUid(int id); 131 void setZaurusUid(int id);
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 * );
138 void updated(); 145 void updated();
139 146
140 protected: 147 protected:
@@ -150,12 +157,13 @@ class IncidenceBase : public CustomProperties
150 QPtrList<Attendee> mAttendees; 157 QPtrList<Attendee> mAttendees;
151 158
152 bool mFloats; 159 bool mFloats;
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;
159 167
160 // PILOT SYNCHRONIZATION STUFF 168 // PILOT SYNCHRONIZATION STUFF
161 int mPilotId; // unique id for pilot sync 169 int mPilotId; // unique id for pilot sync