summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp16
-rw-r--r--libkcal/alarm.cpp36
-rw-r--r--libkcal/recurrence.cpp56
-rw-r--r--libkcal/sharpformat.cpp7
4 files changed, 94 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 258bd43..94cc97d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -717,97 +717,97 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
//void setZaurusId(int id);
// int zaurusId() const;
// void setZaurusUid(int id);
// int zaurusUid() const;
// void setZaurusStat(int id);
// int zaurusStat() const;
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
QDateTime lastSync = mLastCalendarSync;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
bool remCh, locCh;
remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
if ( remCh )
qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
locCh = ( local->lastModified() > mLastCalendarSync );
//qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
if ( !remCh && ! locCh ) {
qDebug("both not changed ");
lastSync = local->lastModified().addDays(1);
} else {
if ( locCh ) {
- qDebug("loc changed %d", local->revision() );
+ qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1());
lastSync = local->lastModified().addDays( -1 );
if ( !remCh )
remote->setLastModified( lastSync.addDays( -1 ) );
} else {
qDebug(" not loc changed ");
lastSync = local->lastModified().addDays( 1 );
if ( remCh )
remote->setLastModified( lastSync.addDays( 1 ) );
}
}
full = true;
if ( mode < SYNC_PREF_ASK )
mode = SYNC_PREF_ASK;
} else {
if ( local->lastModified() == remote->lastModified() )
if ( local->revision() == remote->revision() )
return 0;
}
// qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
//qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
//qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
//full = true; //debug only
if ( full ) {
bool equ = false;
if ( local->type() == "Event" ) {
equ = (*((Event*) local) == *((Event*) remote));
}
else if ( local->type() =="Todo" )
equ = (*((Todo*) local) == (*(Todo*) remote));
else if ( local->type() =="Journal" )
equ = (*((Journal*) local) == *((Journal*) remote));
if ( equ ) {
//qDebug("equal ");
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
}
if ( mode < SYNC_PREF_FORCE_LOCAL )
return 0;
}//else //debug only
//qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
}
int result;
bool localIsNew;
- qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
+ //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
if ( full && mode < SYNC_PREF_NEWEST )
mode = SYNC_PREF_ASK;
switch( mode ) {
case SYNC_PREF_LOCAL:
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
return 2;
return 1;
break;
case SYNC_PREF_REMOTE:
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
return 2;
return 2;
break;
case SYNC_PREF_NEWEST:
if ( local->lastModified() > remote->lastModified() )
return 1;
else
return 2;
@@ -1009,71 +1009,74 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inR->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
qApp->processEvents();
if ( !skipIncidence ) {
inL = local->incidence( uid );
if ( inL ) { // maybe conflict - same uid in both calendars
int maxrev = inL->revision();
if ( maxrev < inR->revision() )
maxrev = inR->revision();
if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
//qDebug("take %d %s ", take, inL->summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
remote->deleteIncidence( inR );
if ( inL->revision() < maxrev )
inL->setRevision( maxrev );
- remote->addIncidence( inL->clone() );
+ inR = inL->clone();
+ inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
+ remote->addIncidence( inR );
++changedRemote;
} else {
if ( inR->revision() < maxrev )
inR->setRevision( maxrev );
local->deleteIncidence( inL );
local->addIncidence( inR->clone() );
++changedLocal;
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = eventLSync->description();
QString pref = "e";
if ( inR->type() == "Todo" )
pref = "t";
if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
//remote->deleteIncidence( inR );
++deletedEventR;
} else {
inR->setLastModified( modifiedCalendar );
- local->addIncidence( inR->clone() );
+ inL = inR->clone();
+ local->addIncidence( inL );
++addedEvent;
}
} else {
if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
local->addIncidence( inR->clone() );
++addedEvent;
} else {
checkExternSyncEvent(eventRSyncSharp, inR);
remote->deleteIncidence( inR );
++deletedEventR;
}
}
}
}
inR = er.next();
}
QPtrList<Incidence> el = local->rawIncidences();
inL = el.first();
modulo = (el.count()/10)+1;
bar.setCaption (i18n("Add / remove events") );
bar.setTotalSteps ( el.count() ) ;
bar.show();
incCounter = 0;
@@ -1082,50 +1085,53 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
qApp->processEvents();
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inL->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
skipIncidence = true;
if ( !skipIncidence ) {
inR = remote->incidence( uid );
if ( ! inR ) {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
+ qDebug("remote added Incidence %s ", inL->summary().latin1());
inL->setLastModified( modifiedCalendar );
- remote->addIncidence( inL->clone() );
+ inR = inL->clone();
+ inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
+ remote->addIncidence( inR );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
remote->addIncidence( inL->clone() );
}
}
}
}
}
inL = el.next();
}
int delFut = 0;
if ( KOPrefs::instance()->mWriteBackInFuture ) {
er = remote->rawIncidences();
inR = er.first();
QDateTime dt;
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 29e6205..1fc7169 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -28,64 +28,98 @@
using namespace KCal;
#include <qwidget.h>
Alarm::Alarm(Incidence *parent)
: mParent(parent),
mType(Audio),
mDescription(""), // to make operator==() not fail
mFile(""), // to make operator==() not fail
mMailSubject(""), // to make operator==() not fail
mAlarmSnoozeTime(5),
mAlarmRepeatCount(0),
mEndOffset(false),
mHasTime(false),
mAlarmEnabled(false)
{
}
Alarm::~Alarm()
{
}
bool Alarm::operator==( const Alarm& rhs ) const
{
+
if ( mType != rhs.mType ||
mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ||
mAlarmRepeatCount != rhs.mAlarmRepeatCount ||
mAlarmEnabled != rhs.mAlarmEnabled ||
mHasTime != rhs.mHasTime)
return false;
+#if 0
+ if ( mType != rhs.mType ) {
+
+ qDebug("aaa1 ");
+ return false;
+ }
+
+ if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) {
+
+ qDebug("aaa2 ");
+ return false;
+ }
+
+
+ if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) {
+
+ qDebug("aaa3 ");
+ return false;
+ }
+
+ if ( mAlarmEnabled != rhs.mAlarmEnabled ) {
+
+ qDebug("aaa4 ");
+ return false;
+ }
+
+ if ( mHasTime != rhs.mHasTime ) {
+
+ qDebug("aaa5 ");
+ return false;
+ }
+#endif
+
+
if (mHasTime) {
if (mAlarmTime != rhs.mAlarmTime)
return false;
} else {
if (mOffset != rhs.mOffset ||
mEndOffset != rhs.mEndOffset)
return false;
}
-
switch (mType) {
case Display:
return mDescription == rhs.mDescription;
case Email:
return mDescription == rhs.mDescription &&
mMailAttachFiles == rhs.mMailAttachFiles &&
mMailAddresses == rhs.mMailAddresses &&
mMailSubject == rhs.mMailSubject;
case Procedure:
return mFile == rhs.mFile &&
mDescription == rhs.mDescription;
case Audio:
return mFile == rhs.mFile;
case Invalid:
break;
}
return false;
}
void Alarm::setType(Alarm::Type type)
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp
index dd74e10..e84f672 100644
--- a/libkcal/recurrence.cpp
+++ b/libkcal/recurrence.cpp
@@ -85,76 +85,108 @@ Recurrence::Recurrence(const Recurrence &r, Incidence *parent)
for (QPtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) {
int *tmp = new int;
*tmp = *yn.current();
rYearNums.append(tmp);
}
rMonthDays.setAutoDelete( true );
rMonthPositions.setAutoDelete( true );
rYearNums.setAutoDelete( true );
}
Recurrence::~Recurrence()
{
}
bool Recurrence::operator==( const Recurrence& r2 ) const
{
// the following line is obvious
if ( recurs == rNone && r2.recurs == rNone )
return true;
// we need the above line, because two non recurring events may
// differ in the other settings, because one (or both)
// may be not initialized properly
+
if ( recurs != r2.recurs
|| rFreq != r2.rFreq
|| rDuration != r2.rDuration
|| !rDuration && rEndDateTime != r2.rEndDateTime
|| mRecurStart != r2.mRecurStart
|| mFloats != r2.mFloats
|| mRecurReadOnly != r2.mRecurReadOnly
|| mRecurExDatesCount != r2.mRecurExDatesCount )
return false;
// no need to compare mCompat* and mParent
// OK to compare the pointers
switch ( recurs )
{
case rWeekly:
return rDays == r2.rDays
&& rWeekStart == r2.rWeekStart;
- case rMonthlyPos:
- return rMonthPositions.count() == r2.rMonthPositions.count();
- case rMonthlyDay:
- return rMonthDays.count() == r2.rMonthDays.count();
- case rYearlyPos:
- return rYearNums.count() == r2.rYearNums.count()
- && rMonthPositions.count() == r2.rMonthPositions.count();
- case rYearlyMonth:
- return rYearNums.count() == r2.rYearNums.count()
- && mFeb29YearlyType == r2.mFeb29YearlyType;
- case rYearlyDay:
- return rYearNums == r2.rYearNums;
+ case rMonthlyPos: {
+ QPtrList<rMonthPos> MonthPositions = rMonthPositions;
+ QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
+ if ( !MonthPositions.count() )
+ return false;
+ if ( !MonthPositions2.count() )
+ return false;
+ return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
+ }
+ case rMonthlyDay: {
+ QPtrList<int> MonthDays = rMonthDays ;
+ QPtrList<int> MonthDays2 = r2.rMonthDays ;
+ if ( !MonthDays.count() )
+ return false;
+ if ( !MonthDays2.count() )
+ return false;
+ return *MonthDays.first() == *MonthDays2.first() ;
+ }
+ case rYearlyPos: {
+
+ QPtrList<int> YearNums = rYearNums;
+ QPtrList<int> YearNums2 = r2.rYearNums;
+ if ( *YearNums.first() != *YearNums2.first() )
+ return false;
+ QPtrList<rMonthPos> MonthPositions = rMonthPositions;
+ QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
+ if ( !MonthPositions.count() )
+ return false;
+ if ( !MonthPositions2.count() )
+ return false;
+ return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
+
+ }
+ case rYearlyMonth: {
+ QPtrList<int> YearNums = rYearNums;
+ QPtrList<int> YearNums2 = r2.rYearNums;
+ return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType);
+ }
+ case rYearlyDay: {
+ QPtrList<int> YearNums = rYearNums;
+ QPtrList<int> YearNums2 = r2.rYearNums;
+ return ( *YearNums.first() == *YearNums2.first() );
+ }
case rNone:
case rMinutely:
case rHourly:
case rDaily:
default:
return true;
}
}
/*
bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2)
{
if ( l1.count() != l2.count() )
return false;
int count = l1.count();
int i;
for ( i = 0; i < count ; ++i ) {
// if ( l1.at(i) != l2.at(i) )
return false;
qDebug("compüare ");
}
return true;
}
*/
QString Recurrence::recurrenceText() const
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index defdb09..89eb72f 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -159,50 +159,51 @@ class SharpParser : public QObject
days.setBit( startDate.dayOfWeek() - 1 );
r->addMonthlyPos( pos, days );
} else if ( rtype == "4" ) {
if ( hasEndDate )
r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
else
r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
r->addYearlyNum( startDate.month() );
}
} else {
event->recurrence()->unsetRecurs();
}
QString categoryList = attList[1] ;
event->setCategories( lookupCategories( categoryList ) );
// strange 0 semms to mean: alarm enabled
if ( attList[8] == "0" ) {
Alarm *alarm;
if ( event->alarms().count() > 0 )
alarm = event->alarms().first();
else {
alarm = new Alarm( event );
event->addAlarm( alarm );
+ alarm->setType( Alarm::Audio );
}
- alarm->setType( Alarm::Audio );
+ //alarm->setType( Alarm::Audio );
alarm->setEnabled( true );
int alarmOffset = attList[9].toInt();
alarm->setStartOffset( alarmOffset * -60 );
} else {
Alarm *alarm;
if ( event->alarms().count() > 0 ) {
alarm = event->alarms().first();
alarm->setType( Alarm::Audio );
alarm->setStartOffset( -60*15 );
alarm->setEnabled( false );
}
}
mCalendar->addEvent( event);
} else if ( qName == "Todo" ) {
Todo *todo;
todo = existingCalendar->todo( "Sharp_DTM", attList[0] );
if (todo )
todo = (Todo*)todo->clone();
else
todo = new Todo;
//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
@@ -347,55 +348,55 @@ SharpFormat::~SharpFormat()
ulong SharpFormat::getCsum( const QStringList & attList)
{
int max = attList.count() -1;
ulong cSum = 0;
int j,k,i;
int add;
for ( i = 1; i < max ; ++i ) {
QString s = attList[i];
if ( ! s.isEmpty() ){
j = s.length();
for ( k = 0; k < j; ++k ) {
int mul = k +1;
add = s[k].unicode ();
if ( k < 16 )
mul = mul * mul;
add = add * mul *i*i*i;
cSum += add;
}
}
}
return cSum;
}
#include <stdlib.h>
-#define DEBUGMODE false
+//#define DEBUGMODE false
+#define DEBUGMODE true
bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
{
bool debug = DEBUGMODE;
- //debug = true;
QString text;
QString codec = "utf8";
QLabel status ( i18n("Reading events ..."), 0 );
int w = status.sizeHint().width()+20 ;
if ( w < 200 ) w = 200;
int h = status.sizeHint().height()+20 ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
status.setCaption(i18n("Reading DTM Data") );
status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
status.show();
status.raise();
qApp->processEvents();
QString fileName;
if ( ! debug ) {
fileName = "/tmp/kopitempout";
QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
system ( command.latin1() );
} else {
fileName = "/tmp/events.txt";
}
QFile file( fileName );