summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -246,55 +246,52 @@ icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
// start time
if (journal->dtStart().isValid()) {
icaltimetype start;
if (journal->doesFloat()) {
// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
start = writeICalDate(journal->dtStart().date());
} else {
// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
start = writeICalDateTime(journal->dtStart());
}
icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
}
return vjournal;
}
void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
{
// pilot sync stuff
// TODO: move this application-specific code to kpilot
if (incidence->pilotId()) {
incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
}
- if (incidence->zaurusId() >= 0) {
- incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId()));
+ if ( !incidence->IDStr().isEmpty()) {
+ incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
}
- if (incidence->zaurusUid() > 0) {
- incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid()));
- }
writeIncidenceBase(parent,incidence);
if (incidence->cancelled()) {
icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
}
// creation date
icalcomponent_add_property(parent,icalproperty_new_created(
writeICalDateTime(incidence->created())));
// unique id
icalcomponent_add_property(parent,icalproperty_new_uid(
incidence->uid().utf8()));
// revision
icalcomponent_add_property(parent,icalproperty_new_sequence(
incidence->revision()));
// last modification date
icalcomponent_add_property(parent,icalproperty_new_lastmodified(
writeICalDateTime(incidence->lastModified())));
// description
if (!incidence->description().isEmpty()) {
@@ -1259,56 +1256,53 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
incidence->addAttachment(readAttachment(p));
break;
default:
// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
// << endl;
break;
}
p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
}
if ( readrec ) {
readRecurrenceRule(rectype,incidence);
}
// kpilot stuff
// TODO: move this application-specific code to kpilot
QString kp = incidence->nonKDECustomProperty("X-PILOTID");
if (!kp.isNull()) {
incidence->setPilotId(kp.toInt());
}
kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
if (!kp.isNull()) {
incidence->setSyncStatus(kp.toInt());
}
- kp = incidence->nonKDECustomProperty("X-ZAURUSID");
- if (!kp.isNull()) {
- incidence->setZaurusId(kp.toInt());
- }
- kp = incidence->nonKDECustomProperty("X-ZAURUSUID");
+
+ kp = incidence->nonKDECustomProperty("X-KOPIEXTID");
if (!kp.isNull()) {
- incidence->setZaurusUid(kp.toInt());
+ incidence->setIDStr(kp);
}
// Cancel backwards compatibility mode for subsequent changes by the application
incidence->recurrence()->setCompatVersion();
// add categories
incidence->setCategories(categories);
// iterate through all alarms
for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
alarm;
alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
readAlarm(alarm,incidence);
}
}
void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
{
icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
while (p) {
icalproperty_kind kind = icalproperty_isa(p);
switch (kind) {
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 707d666..d7c4595 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -19,89 +19,90 @@
*/
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include "calformat.h"
#include "incidencebase.h"
using namespace KCal;
IncidenceBase::IncidenceBase() :
mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
mPilotId(0), mSyncStatus(SYNCMOD)
{
setUid(CalFormat::createUniqueId());
mOrganizer = "";
mFloats = false;
mDuration = 0;
mHasDuration = false;
mPilotId = 0;
mZaurusId = -1;
mZaurusUid = 0;
+ mExternalId = ":";
mTempSyncStat = 0;
mSyncStatus = 0;
mAttendees.setAutoDelete( true );
}
IncidenceBase::IncidenceBase(const IncidenceBase &i) :
CustomProperties( i )
{
mReadOnly = i.mReadOnly;
mDtStart = i.mDtStart;
mDuration = i.mDuration;
mHasDuration = i.mHasDuration;
mOrganizer = i.mOrganizer;
mUid = i.mUid;
QPtrList<Attendee> attendees = i.attendees();
for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
mAttendees.append( new Attendee( *a ) );
}
mFloats = i.mFloats;
mLastModified = i.mLastModified;
mPilotId = i.mPilotId;
mZaurusId = i.mZaurusId;
mZaurusUid = i.mZaurusUid;
mTempSyncStat = i.mTempSyncStat;
mSyncStatus = i.mSyncStatus;
-
+ mExternalId = i.mExternalId;
// The copied object is a new one, so it isn't observed by the observer
// of the original object.
mObservers.clear();
mAttendees.setAutoDelete( true );
}
IncidenceBase::~IncidenceBase()
{
}
bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
{
-
+ // do not compare mSyncStatus and mExternalId
if( i1.attendees().count() != i2.attendees().count() ) {
return false; // no need to check further
}
if ( i1.attendees().count() > 0 ) {
Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
while ( a1 ) {
if ( !( (*a1) == (*a2)) )
{
//qDebug("Attendee not equal ");
return false;
}
a1 = i1.attendees().next();
a2 = i2.attendees().next();
}
}
//if ( i1.dtStart() != i2.dtStart() )
// return false;
#if 0
qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
qDebug("1 %d ",i1.duration() == i2.duration() );
qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
qDebug("6 %d ",i1.organizer() == i2.organizer() );
@@ -351,43 +352,119 @@ int IncidenceBase::zaurusId() const
{
return mZaurusId;
}
int IncidenceBase::zaurusUid() const
{
return mZaurusUid;
}
void IncidenceBase::setZaurusUid( int id )
{
if (mReadOnly) return;
mZaurusUid = id;
}
int IncidenceBase::tempSyncStat() const
{
return mTempSyncStat;
}
void IncidenceBase::setTempSyncStat( int id )
{
if (mReadOnly) return;
mTempSyncStat = id;
}
+void IncidenceBase::setID( const QString & prof , int id )
+{
+ int num = mExternalId.find( ":"+prof+";" );
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ int end = mExternalId.find( ";", num+len );
+ if ( end > 0 ) {
+ mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end );
+ } else
+ qDebug("Error in IncidenceBase::setID ");
+ } else {
+ mExternalId += prof+";"+QString::number( id) +";0:";
+ }
+}
+int IncidenceBase::getID( const QString & prof)
+{
+ int ret = -1;
+ int num = mExternalId.find(":"+ prof+";" );
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ int end = mExternalId.find( ";", num+len );
+ if ( end > 0 ) {
+ bool ok;
+ ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok );
+ if (!ok)
+ return -1;
+ }
+ }
+ return ret;
+}
+
+// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0:
+// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
+void IncidenceBase::setCsum( const QString & prof , int id )
+{
+ int num = mExternalId.find( ":"+prof+";");
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ num = mExternalId.find( ";", num+len );
+ int end = mExternalId.find( ":", num+1 );
+ if ( end > 0 ) {
+ mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end );
+ } else
+ qDebug("Error in IncidenceBase::setCsum ");
+ } else {
+ mExternalId += prof+";-1;"+QString::number( id) +":";
+ }
+}
+int IncidenceBase::getCsum( const QString & prof)
+{
+ int ret = -1;
+ int num = mExternalId.find( ":"+prof+";" );
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ num = mExternalId.find( ";", num+len );
+ int end = mExternalId.find( ":", num+1 );
+ if ( end > 0 ) {
+ bool ok;
+ ret = mExternalId.mid ( num ,end-num).toInt( &ok );
+ if (!ok)
+ return -1;
+ }
+ }
+ return ret;
+}
+
+void IncidenceBase::setIDStr( const QString & s )
+{
+ if (mReadOnly) return;
+ mExternalId = s;
+}
+
+QString IncidenceBase::IDStr() const
+{
+ return mExternalId ;
+}
void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
{
if( !mObservers.contains(observer) ) mObservers.append( observer );
}
void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
{
mObservers.remove( observer );
}
void IncidenceBase::updated()
{
QPtrListIterator<Observer> it(mObservers);
while( it.current() ) {
Observer *o = it.current();
++it;
o->incidenceUpdated( this );
}
}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index ce6e254..2f85df6 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -111,60 +111,68 @@ class IncidenceBase : public CustomProperties
int attendeeCount() const { return mAttendees.count(); };
/** Return the Attendee with this email */
Attendee* attendeeByMail(const QString &);
/** Return first Attendee with one of this emails */
Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
/** pilot syncronization states */
enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
/** Set synchronisation satus. */
void setSyncStatus(int stat);
/** Return synchronisation status. */
int syncStatus() const;
/** Set Pilot Id. */
void setPilotId(int id);
/** Return Pilot Id. */
int pilotId() const;
void setZaurusId(int id);
int zaurusId() const;
void setZaurusUid(int id);
int zaurusUid() const;
void setTempSyncStat(int id);
int tempSyncStat() const;
+ void setIDStr( const QString & );
+ QString IDStr() const;
+ void setID( const QString &, int );
+ int getID( const QString & );
+ void setCsum( const QString &, int );
+ int getCsum( const QString & );
+
void registerObserver( Observer * );
void unRegisterObserver( Observer * );
void updated();
protected:
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
private:
// base components
QDateTime mDtStart;
QString mOrganizer;
QString mUid;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
bool mFloats;
int mDuration;
bool mHasDuration;
+ QString mExternalId;
int mZaurusId;
int mZaurusUid;
int mTempSyncStat;
// PILOT SYNCHRONIZATION STUFF
int mPilotId; // unique id for pilot sync
int mSyncStatus; // status (for sync)
QPtrList<Observer> mObservers;
};
bool operator==( const IncidenceBase&, const IncidenceBase& );
}
#endif