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 | |
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 | |||
@@ -238,71 +238,68 @@ icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | |||
238 | } | 238 | } |
239 | 239 | ||
240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) |
241 | { | 241 | { |
242 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); | 242 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); |
243 | 243 | ||
244 | writeIncidence(vjournal,journal); | 244 | writeIncidence(vjournal,journal); |
245 | 245 | ||
246 | // start time | 246 | // start time |
247 | if (journal->dtStart().isValid()) { | 247 | if (journal->dtStart().isValid()) { |
248 | icaltimetype start; | 248 | icaltimetype start; |
249 | if (journal->doesFloat()) { | 249 | if (journal->doesFloat()) { |
250 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 250 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
251 | start = writeICalDate(journal->dtStart().date()); | 251 | start = writeICalDate(journal->dtStart().date()); |
252 | } else { | 252 | } else { |
253 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 253 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
254 | start = writeICalDateTime(journal->dtStart()); | 254 | start = writeICalDateTime(journal->dtStart()); |
255 | } | 255 | } |
256 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); | 256 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); |
257 | } | 257 | } |
258 | 258 | ||
259 | return vjournal; | 259 | return vjournal; |
260 | } | 260 | } |
261 | 261 | ||
262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | 262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) |
263 | { | 263 | { |
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 | ||
283 | // creation date | 280 | // creation date |
284 | icalcomponent_add_property(parent,icalproperty_new_created( | 281 | icalcomponent_add_property(parent,icalproperty_new_created( |
285 | writeICalDateTime(incidence->created()))); | 282 | writeICalDateTime(incidence->created()))); |
286 | 283 | ||
287 | // unique id | 284 | // unique id |
288 | icalcomponent_add_property(parent,icalproperty_new_uid( | 285 | icalcomponent_add_property(parent,icalproperty_new_uid( |
289 | incidence->uid().utf8())); | 286 | incidence->uid().utf8())); |
290 | 287 | ||
291 | // revision | 288 | // revision |
292 | icalcomponent_add_property(parent,icalproperty_new_sequence( | 289 | icalcomponent_add_property(parent,icalproperty_new_sequence( |
293 | incidence->revision())); | 290 | incidence->revision())); |
294 | 291 | ||
295 | // last modification date | 292 | // last modification date |
296 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( | 293 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( |
297 | writeICalDateTime(incidence->lastModified()))); | 294 | writeICalDateTime(incidence->lastModified()))); |
298 | 295 | ||
299 | // description | 296 | // description |
300 | if (!incidence->description().isEmpty()) { | 297 | if (!incidence->description().isEmpty()) { |
301 | icalcomponent_add_property(parent,icalproperty_new_description( | 298 | icalcomponent_add_property(parent,icalproperty_new_description( |
302 | incidence->description().utf8())); | 299 | incidence->description().utf8())); |
303 | } | 300 | } |
304 | 301 | ||
305 | // summary | 302 | // summary |
306 | if (!incidence->summary().isEmpty()) { | 303 | if (!incidence->summary().isEmpty()) { |
307 | icalcomponent_add_property(parent,icalproperty_new_summary( | 304 | icalcomponent_add_property(parent,icalproperty_new_summary( |
308 | incidence->summary().utf8())); | 305 | incidence->summary().utf8())); |
@@ -1251,72 +1248,69 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | |||
1251 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1248 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1252 | } else { | 1249 | } else { |
1253 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1250 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1254 | } | 1251 | } |
1255 | } | 1252 | } |
1256 | break; | 1253 | break; |
1257 | 1254 | ||
1258 | case ICAL_ATTACH_PROPERTY: // attachments | 1255 | case ICAL_ATTACH_PROPERTY: // attachments |
1259 | incidence->addAttachment(readAttachment(p)); | 1256 | incidence->addAttachment(readAttachment(p)); |
1260 | break; | 1257 | break; |
1261 | 1258 | ||
1262 | default: | 1259 | default: |
1263 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1260 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1264 | // << endl; | 1261 | // << endl; |
1265 | break; | 1262 | break; |
1266 | } | 1263 | } |
1267 | 1264 | ||
1268 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1265 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1269 | } | 1266 | } |
1270 | if ( readrec ) { | 1267 | if ( readrec ) { |
1271 | readRecurrenceRule(rectype,incidence); | 1268 | readRecurrenceRule(rectype,incidence); |
1272 | } | 1269 | } |
1273 | // kpilot stuff | 1270 | // kpilot stuff |
1274 | // TODO: move this application-specific code to kpilot | 1271 | // TODO: move this application-specific code to kpilot |
1275 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1272 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1276 | if (!kp.isNull()) { | 1273 | if (!kp.isNull()) { |
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 |
1297 | incidence->setCategories(categories); | 1291 | incidence->setCategories(categories); |
1298 | 1292 | ||
1299 | // iterate through all alarms | 1293 | // iterate through all alarms |
1300 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); | 1294 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); |
1301 | alarm; | 1295 | alarm; |
1302 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { | 1296 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { |
1303 | readAlarm(alarm,incidence); | 1297 | readAlarm(alarm,incidence); |
1304 | } | 1298 | } |
1305 | } | 1299 | } |
1306 | 1300 | ||
1307 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 1301 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
1308 | { | 1302 | { |
1309 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1303 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1310 | 1304 | ||
1311 | while (p) { | 1305 | while (p) { |
1312 | icalproperty_kind kind = icalproperty_isa(p); | 1306 | icalproperty_kind kind = icalproperty_isa(p); |
1313 | switch (kind) { | 1307 | switch (kind) { |
1314 | 1308 | ||
1315 | case ICAL_UID_PROPERTY: // unique id | 1309 | case ICAL_UID_PROPERTY: // unique id |
1316 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); | 1310 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); |
1317 | break; | 1311 | break; |
1318 | 1312 | ||
1319 | case ICAL_ORGANIZER_PROPERTY: // organizer | 1313 | case ICAL_ORGANIZER_PROPERTY: // organizer |
1320 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); | 1314 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); |
1321 | break; | 1315 | break; |
1322 | 1316 | ||
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 707d666..d7c4595 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -11,105 +11,106 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidencebase.h" | 27 | #include "incidencebase.h" |
28 | 28 | ||
29 | using namespace KCal; | 29 | using namespace KCal; |
30 | 30 | ||
31 | IncidenceBase::IncidenceBase() : | 31 | IncidenceBase::IncidenceBase() : |
32 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 32 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
33 | mPilotId(0), mSyncStatus(SYNCMOD) | 33 | mPilotId(0), mSyncStatus(SYNCMOD) |
34 | { | 34 | { |
35 | setUid(CalFormat::createUniqueId()); | 35 | setUid(CalFormat::createUniqueId()); |
36 | mOrganizer = ""; | 36 | mOrganizer = ""; |
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 | ||
48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
49 | CustomProperties( i ) | 50 | CustomProperties( i ) |
50 | { | 51 | { |
51 | mReadOnly = i.mReadOnly; | 52 | mReadOnly = i.mReadOnly; |
52 | mDtStart = i.mDtStart; | 53 | mDtStart = i.mDtStart; |
53 | mDuration = i.mDuration; | 54 | mDuration = i.mDuration; |
54 | mHasDuration = i.mHasDuration; | 55 | mHasDuration = i.mHasDuration; |
55 | mOrganizer = i.mOrganizer; | 56 | mOrganizer = i.mOrganizer; |
56 | mUid = i.mUid; | 57 | mUid = i.mUid; |
57 | QPtrList<Attendee> attendees = i.attendees(); | 58 | QPtrList<Attendee> attendees = i.attendees(); |
58 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
59 | mAttendees.append( new Attendee( *a ) ); | 60 | mAttendees.append( new Attendee( *a ) ); |
60 | } | 61 | } |
61 | mFloats = i.mFloats; | 62 | mFloats = i.mFloats; |
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 | } |
75 | 76 | ||
76 | IncidenceBase::~IncidenceBase() | 77 | IncidenceBase::~IncidenceBase() |
77 | { | 78 | { |
78 | } | 79 | } |
79 | 80 | ||
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 | } |
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 ) { |
90 | if ( !( (*a1) == (*a2)) ) | 91 | if ( !( (*a1) == (*a2)) ) |
91 | { | 92 | { |
92 | //qDebug("Attendee not equal "); | 93 | //qDebug("Attendee not equal "); |
93 | return false; | 94 | return false; |
94 | } | 95 | } |
95 | a1 = i1.attendees().next(); | 96 | a1 = i1.attendees().next(); |
96 | a2 = i2.attendees().next(); | 97 | a2 = i2.attendees().next(); |
97 | } | 98 | } |
98 | } | 99 | } |
99 | //if ( i1.dtStart() != i2.dtStart() ) | 100 | //if ( i1.dtStart() != i2.dtStart() ) |
100 | // return false; | 101 | // return false; |
101 | #if 0 | 102 | #if 0 |
102 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 103 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
103 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 104 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
104 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 105 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
105 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 106 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
106 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 107 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
107 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 108 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
108 | 109 | ||
109 | #endif | 110 | #endif |
110 | return ( i1.organizer() == i2.organizer() && | 111 | return ( i1.organizer() == i2.organizer() && |
111 | // i1.uid() == i2.uid() && | 112 | // i1.uid() == i2.uid() && |
112 | // Don't compare lastModified, otherwise the operator is not | 113 | // Don't compare lastModified, otherwise the operator is not |
113 | // of much use. We are not comparing for identity, after all. | 114 | // of much use. We are not comparing for identity, after all. |
114 | i1.doesFloat() == i2.doesFloat() && | 115 | i1.doesFloat() == i2.doesFloat() && |
115 | i1.duration() == i2.duration() && | 116 | i1.duration() == i2.duration() && |
@@ -343,51 +344,127 @@ int IncidenceBase::pilotId() const | |||
343 | } | 344 | } |
344 | void IncidenceBase::setZaurusId( int id ) | 345 | void IncidenceBase::setZaurusId( int id ) |
345 | { | 346 | { |
346 | if (mReadOnly) return; | 347 | if (mReadOnly) return; |
347 | mZaurusId = id; | 348 | mZaurusId = id; |
348 | } | 349 | } |
349 | 350 | ||
350 | int IncidenceBase::zaurusId() const | 351 | int IncidenceBase::zaurusId() const |
351 | { | 352 | { |
352 | return mZaurusId; | 353 | return mZaurusId; |
353 | } | 354 | } |
354 | 355 | ||
355 | int IncidenceBase::zaurusUid() const | 356 | int IncidenceBase::zaurusUid() const |
356 | { | 357 | { |
357 | return mZaurusUid; | 358 | return mZaurusUid; |
358 | } | 359 | } |
359 | void IncidenceBase::setZaurusUid( int id ) | 360 | void IncidenceBase::setZaurusUid( int id ) |
360 | { | 361 | { |
361 | if (mReadOnly) return; | 362 | if (mReadOnly) return; |
362 | mZaurusUid = id; | 363 | mZaurusUid = id; |
363 | } | 364 | } |
364 | 365 | ||
365 | int IncidenceBase::tempSyncStat() const | 366 | int IncidenceBase::tempSyncStat() const |
366 | { | 367 | { |
367 | return mTempSyncStat; | 368 | return mTempSyncStat; |
368 | } | 369 | } |
369 | void IncidenceBase::setTempSyncStat( int id ) | 370 | void IncidenceBase::setTempSyncStat( int id ) |
370 | { | 371 | { |
371 | if (mReadOnly) return; | 372 | if (mReadOnly) return; |
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 ); |
378 | } | 455 | } |
379 | 456 | ||
380 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 457 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
381 | { | 458 | { |
382 | mObservers.remove( observer ); | 459 | mObservers.remove( observer ); |
383 | } | 460 | } |
384 | 461 | ||
385 | void IncidenceBase::updated() | 462 | void IncidenceBase::updated() |
386 | { | 463 | { |
387 | QPtrListIterator<Observer> it(mObservers); | 464 | QPtrListIterator<Observer> it(mObservers); |
388 | while( it.current() ) { | 465 | while( it.current() ) { |
389 | Observer *o = it.current(); | 466 | Observer *o = it.current(); |
390 | ++it; | 467 | ++it; |
391 | o->incidenceUpdated( this ); | 468 | o->incidenceUpdated( this ); |
392 | } | 469 | } |
393 | } | 470 | } |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index ce6e254..2f85df6 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -103,68 +103,76 @@ class IncidenceBase : public CustomProperties | |||
103 | void addAttendee(Attendee *a, bool doupdate=true ); | 103 | void addAttendee(Attendee *a, bool doupdate=true ); |
104 | // void removeAttendee(Attendee *a); | 104 | // void removeAttendee(Attendee *a); |
105 | // void removeAttendee(const char *n); | 105 | // void removeAttendee(const char *n); |
106 | /** Remove all Attendees. */ | 106 | /** Remove all Attendees. */ |
107 | void clearAttendees(); | 107 | void clearAttendees(); |
108 | /** Return list of attendees. */ | 108 | /** Return list of attendees. */ |
109 | QPtrList<Attendee> attendees() const { return mAttendees; }; | 109 | QPtrList<Attendee> attendees() const { return mAttendees; }; |
110 | /** Return number of attendees. */ | 110 | /** Return number of attendees. */ |
111 | int attendeeCount() const { return mAttendees.count(); }; | 111 | int attendeeCount() const { return mAttendees.count(); }; |
112 | /** Return the Attendee with this email */ | 112 | /** Return the Attendee with this email */ |
113 | Attendee* attendeeByMail(const QString &); | 113 | Attendee* attendeeByMail(const QString &); |
114 | /** Return first Attendee with one of this emails */ | 114 | /** Return first Attendee with one of this emails */ |
115 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); | 115 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); |
116 | 116 | ||
117 | /** pilot syncronization states */ | 117 | /** pilot syncronization states */ |
118 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; | 118 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; |
119 | /** Set synchronisation satus. */ | 119 | /** Set synchronisation satus. */ |
120 | void setSyncStatus(int stat); | 120 | void setSyncStatus(int stat); |
121 | /** Return synchronisation status. */ | 121 | /** Return synchronisation status. */ |
122 | int syncStatus() const; | 122 | int syncStatus() const; |
123 | 123 | ||
124 | /** Set Pilot Id. */ | 124 | /** Set Pilot Id. */ |
125 | void setPilotId(int id); | 125 | void setPilotId(int id); |
126 | /** Return Pilot Id. */ | 126 | /** Return Pilot Id. */ |
127 | int pilotId() const; | 127 | int pilotId() const; |
128 | 128 | ||
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: |
141 | bool mReadOnly; | 148 | bool mReadOnly; |
142 | QDateTime getEvenTime( QDateTime ); | 149 | QDateTime getEvenTime( QDateTime ); |
143 | 150 | ||
144 | private: | 151 | private: |
145 | // base components | 152 | // base components |
146 | QDateTime mDtStart; | 153 | QDateTime mDtStart; |
147 | QString mOrganizer; | 154 | QString mOrganizer; |
148 | QString mUid; | 155 | QString mUid; |
149 | QDateTime mLastModified; | 156 | QDateTime mLastModified; |
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 |
162 | int mSyncStatus; // status (for sync) | 170 | int mSyncStatus; // status (for sync) |
163 | 171 | ||
164 | QPtrList<Observer> mObservers; | 172 | QPtrList<Observer> mObservers; |
165 | }; | 173 | }; |
166 | 174 | ||
167 | bool operator==( const IncidenceBase&, const IncidenceBase& ); | 175 | bool operator==( const IncidenceBase&, const IncidenceBase& ); |
168 | } | 176 | } |
169 | 177 | ||
170 | #endif | 178 | #endif |