summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-01 11:37:35 (UTC)
committer zautrix <zautrix>2004-08-01 11:37:35 (UTC)
commite954cc1e29b129982e4d07c4f490d7e881597374 (patch) (side-by-side diff)
tree29e7bdcf20952b813637083596102f7e7b080567
parent8a394f316feb828954d69480553f85c9c0f4b353 (diff)
downloadkdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.zip
kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.gz
kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.bz2
Made sync code more readable by using defines
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile30
-rw-r--r--korganizer/calendarview.cpp47
-rw-r--r--libkcal/sharpformat.cpp15
-rw-r--r--libkcal/syncdefines.h22
-rw-r--r--libkdepim/ksyncprofile.h10
5 files changed, 62 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index 826e70e..19c57e5 100644
--- a/Makefile
+++ b/Makefile
@@ -23,25 +23,19 @@ SUBDIRS_MICROKDE = \
kabc/plugins/dir \
korganizer \
kalarmd \
kaddressbook
SUBDIRS_QTOPIA_PLUGIN = \
- kabc/converter/qtopia \
- kabc/plugins/qtopia \
- kaddressbook/xxport/qtopia
+ kabc/plugins/qtopia
SUBDIRS_OPIE_PLUGIN = \
- kabc/converter/opie \
- kabc/plugins/opie \
- kaddressbook/xxport/opie
+ kabc/plugins/opie
SUBDIRS_SHARP_PLUGIN = \
- kabc/converter/sharpdtm \
- kabc/plugins/sharpdtm \
- kaddressbook/xxport/sharpdtm
+ kabc/plugins/sharpdtm
SUBDIRS_LDAP_PLUGIN = \
kabc/plugins/ldap
SUBDIRS_MICROMAIL = \
kmicromail/libetpan \
@@ -145,16 +139,16 @@ variable_test: variable_info
ifdef BUILD_NO_MICROMAIL
@echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL)
endif
ifdef BUILD_NO_SHARP_PLUGIN
@echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN)
else
- ifndef SHARPDTMSDK
+ ifndef SHARPDTMSDK
@echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK)
$(error SHARPDTMSDK is not defined)
- endif
+ endif
endif
@echo --------------------------------------
objects:
for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done
@@ -193,15 +187,12 @@ tmake: objects \
libkdepim/Makefile$(PLATFORM) \
korganizer/Makefile$(PLATFORM) \
kalarmd/Makefile$(PLATFORM) \
libical/src/libical/Makefile$(PLATFORM) \
libical/src/libicalss/Makefile$(PLATFORM) \
kabc/Makefile$(PLATFORM) \
- kabc/converter/opie/Makefile$(PLATFORM) \
- kabc/converter/qtopia/Makefile$(PLATFORM) \
- kabc/converter/sharpdtm/Makefile$(PLATFORM) \
kabc/formats/binary/Makefile$(PLATFORM) \
kabc/plugins/file/Makefile$(PLATFORM) \
kabc/plugins/dir/Makefile$(PLATFORM) \
kabc/plugins/ldap/Makefile$(PLATFORM) \
kabc/plugins/opie/Makefile$(PLATFORM) \
kabc/plugins/qtopia/Makefile$(PLATFORM) \
@@ -210,13 +201,12 @@ tmake: objects \
kaddressbook/xxport/qtopia/Makefile$(PLATFORM) \
kaddressbook/xxport/sharpdtm/Makefile$(PLATFORM) \
kaddressbook/Makefile$(PLATFORM) \
kmicromail/Makefile$(PLATFORM) \
kmicromail/libetpan/Makefile$(PLATFORM) \
kmicromail/libmailwrapper/Makefile$(PLATFORM)
-
qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro
cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" qtcompat.pro -o Makefile$(PLATFORM)
@@ -242,22 +232,12 @@ libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro
libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro
cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalssE.pro -o Makefile$(PLATFORM)
kabc/Makefile$(PLATFORM): kabc/kabcE.pro
cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcE.pro -o Makefile$(PLATFORM)
-kabc/converter/opie/Makefile$(PLATFORM): kabc/converter/opie/opieE.pro
- cd kabc/converter/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM)
-
-kabc/converter/qtopia/Makefile$(PLATFORM): kabc/converter/qtopia/qtopiaE.pro
- cd kabc/converter/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM)
-
-kabc/converter/sharpdtm/Makefile$(PLATFORM): kabc/converter/sharpdtm/sharpdtmE.pro
- cd kabc/converter/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM)
-
-
kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro
cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcformat_binaryE.pro -o Makefile$(PLATFORM)
kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro
cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" fileE.pro -o Makefile$(PLATFORM)
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 58b3d70..fd68dc4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -126,15 +126,13 @@
#endif
using namespace KOrg;
using namespace KCal;
extern int globalFlagBlockAgenda;
extern int globalFlagBlockStartup;
-#define SYNC_MODE_NORMAL 0
-#define SYNC_MODE_SHARP 1
-#define SYNC_MODE_QTOPIA 2
+
class KOBeamPrefs : public QDialog
{
public:
KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
@@ -724,16 +722,16 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
// int zaurusStat() const;
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
QDateTime lastSync = mLastCalendarSync;
- if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
bool remCh, locCh;
remCh = ( remote->zaurusUid() != local->zaurusUid() );
- locCh = ( local->zaurusStat() != local->revision() );
+ 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 ) {
@@ -747,14 +745,14 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
if ( remCh )
remote->setLastModified( lastSync.addDays( 1 ) );
}
}
full = true;
- if ( mode < 3 )
- mode = 3;
+ if ( mode < SYNC_PREF_ASK )
+ mode = SYNC_PREF_ASK;
} else {
if ( local->lastModified() == remote->lastModified() )
if ( local->revision() == remote->revision() )
return 0;
}
@@ -771,48 +769,48 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
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_SHARP ) {
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
local->setZaurusUid( remote->zaurusUid() );
}
- if ( mode < 4 )
+ 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;
- if ( full && mode < 2 )
- mode = 3;
+ if ( full && mode < SYNC_PREF_NEWEST )
+ mode = SYNC_PREF_ASK;
switch( mode ) {
- case 0:
+ case SYNC_PREF_LOCAL:
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
return 2;
return 1;
break;
- case 1:
+ case SYNC_PREF_REMOTE:
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
return 2;
return 2;
break;
- case 2:
+ case SYNC_PREF_NEWEST:
if ( local->lastModified() > remote->lastModified() )
return 1;
else
return 2;
break;
- case 3:
+ case SYNC_PREF_ASK:
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
return 2;
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
@@ -832,20 +830,21 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
getEventViewerDialog()->showMe();
result = getEventViewerDialog()->executeS( localIsNew );
return result;
break;
- case 4:
+ case SYNC_PREF_FORCE_LOCAL:
return 1;
break;
- case 5:
+ case SYNC_PREF_FORCE_REMOTE:
return 2;
break;
default:
+ // SYNC_PREF_TAKE_BOTH not implemented
break;
}
return 0;
}
Event* CalendarView::getLastSyncEvent()
{
@@ -993,19 +992,19 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
local->deleteIncidence( inL );
local->addIncidence( inR->clone() );
++changedLocal;
}
}
} else { // no conflict
- if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = eventLSync->description();
QString pref = "e";
if ( inR->type() == "Todo" )
pref = "t";
if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
- inR->setZaurusStat( -3 );
+ inR->setZaurusStat( SYNC_TEMPSTATE_DELETE );
//remote->deleteIncidence( inR );
++deletedEventR;
} else {
inR->setLastModified( modifiedCalendar );
local->addIncidence( inR->clone() );
++addedEvent;
@@ -1042,18 +1041,18 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
bar.setProgress( incCounter );
++incCounter;
uid = inL->uid();
bool skipIncidence = false;
if ( uid.left(21) == QString("last-syncEvent-device") )
skipIncidence = true;
- if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" )
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
skipIncidence = true;
if ( !skipIncidence ) {
inR = remote->incidence( uid );
if ( ! inR ) {
- if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( inL->zaurusId() >= 0 && mode != 4 ) {
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
inL->setZaurusId( -1 );
@@ -1138,13 +1137,13 @@ bool CalendarView::syncCalendar(QString filename, int mode)
updateView();
return syncOK;
}
void CalendarView::syncSharp()
{
#ifndef DESKTOP_VERSION
- mGlobalSyncMode = SYNC_MODE_SHARP;
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
//mCurrentSyncDevice = "sharp-DTM";
if ( KOPrefs::instance()->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
@@ -1157,23 +1156,25 @@ void CalendarView::syncSharp()
qApp->processEvents();
if ( syncOK ) {
if ( KOPrefs::instance()->mWriteBackFile )
{
QPtrList<Incidence> iL = mCalendar->rawIncidences();
Incidence* inc = iL.first();
+ /* obsolete
while ( inc ) {
inc->setZaurusStat( inc->revision () );
inc = iL.next();
}
+ */
// pending: clean last sync event description
sharpFormat.save(calendar);
iL = calendar->rawIncidences();
inc = iL.first();
Incidence* loc;
while ( inc ) {
- if ( inc->zaurusStat() == -4 ) {
+ if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) {
loc = mCalendar->incidence(inc->uid() );
if ( loc ) {
loc->setZaurusId( inc->zaurusId() );
loc->setZaurusUid( inc->zaurusUid() );
}
}
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index f83f72e..973f19d 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -39,12 +39,13 @@
#include "calendar.h"
#include "alarm.h"
#include "recurrence.h"
#include "calendarlocal.h"
#include "sharpformat.h"
+#include "syncdefines.h"
using namespace KCal;
//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
@@ -88,13 +89,13 @@ class SharpParser : public QObject
if ( event )
event = (Event*)event->clone();
else
event = new Event;
event->setZaurusId( attList[0].toInt() );
event->setZaurusUid( cSum );
- event->setZaurusStat( -2 );
+ event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
event->setSummary( attList[2] );
event->setLocation( attList[3] );
event->setDescription( attList[4] );
if ( attList[7] == "1" ) {
event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
@@ -199,13 +200,13 @@ class SharpParser : public QObject
//1,,,,,1,4,Loch zumachen,""
//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
todo->setZaurusId( attList[0].toInt() );
todo->setZaurusUid( cSum );
- todo->setZaurusStat( -2 );
+ todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
todo->setSummary( attList[7] );
todo->setDescription( attList[8]);
int priority = attList[6].toInt();
if ( priority == 0 ) priority = 3;
@@ -464,13 +465,13 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
bool ok;
int newnum = templist[0].toInt( &ok );
if ( ok && newnum > 0) {
retval = newnum;
inc->setZaurusId( newnum );
inc->setZaurusUid( getCsum( templist ) );
- inc->setZaurusStat( -4 );
+ inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID );
}
}
}
//qDebug("getNumFromRecord returning : %d ", retval);
return retval;
}
@@ -503,17 +504,17 @@ bool SharpFormat::save( Calendar *calendar)
bool deleteEnt = false;
bool changeEnt = false;
QString message = i18n("Processing event # ");
int procCount = 0;
while ( ev ) {
//qDebug("i %d ", ++i);
- if ( ev->zaurusStat() != -2 ) {
+ if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
QString eString = getEventString( ev );
- if ( ev->zaurusStat() == -3 ) { // delete
+ if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete
// deleting empty strings does not work.
// we write first and x and then delete the record with the x
eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
changeString += eString + "\n";
deleteString += eString + "\n";
deleteEnt = true;
@@ -589,17 +590,17 @@ bool SharpFormat::save( Calendar *calendar)
QPtrList<Todo> tl = calendar->rawTodos();
Todo* to = tl.first();
i = 0;
message = i18n("Processing todo # ");
procCount = 0;
while ( to ) {
- if ( to->zaurusStat() != -2 ) {
+ if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
QString eString = getTodoString( to );
- if ( to->zaurusStat() == -3 ) { // delete
+ if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete
// deleting empty strings does not work.
// we write first and x and then delete the record with the x
eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
changeString += eString + "\n";
deleteString += eString + "\n";
deleteEnt = true;
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
new file mode 100644
index 0000000..57642ec
--- a/dev/null
+++ b/libkcal/syncdefines.h
@@ -0,0 +1,22 @@
+
+#ifndef _KSYNC_DEFINES_H_
+#define _KSYNC_DEFINES_H_
+
+#define SYNC_PREF_LOCAL 0
+#define SYNC_PREF_REMOTE 1
+#define SYNC_PREF_NEWEST 2
+#define SYNC_PREF_ASK 3
+#define SYNC_PREF_FORCE_LOCAL 4
+#define SYNC_PREF_FORCE_REMOTE 5
+#define SYNC_PREF_TAKE_BOTH 6
+
+#define SYNC_MODE_NORMAL 0
+#define SYNC_MODE_EXTERNAL 1
+
+#define SYNC_TEMPSTATE_INITIAL 0
+#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
+#define SYNC_TEMPSTATE_DELETE -3
+#define SYNC_TEMPSTATE_NEW_ID -4
+
+
+#endif
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
index 238ffad..3f7f1ac 100644
--- a/libkdepim/ksyncprofile.h
+++ b/libkdepim/ksyncprofile.h
@@ -24,19 +24,15 @@
#include <qcolor.h>
#include <qfont.h>
#include <qstringlist.h>
#include <qobject.h>
#include <qstring.h>
-#define SYNC_PREF_LOCAL 0
-#define SYNC_PREF_REMOTE 1
-#define SYNC_PREF_NEWEST 2
-#define SYNC_PREF_ASK 3
-#define SYNC_PREF_FORCE_LOCAL 4
-#define SYNC_PREF_FORCE_REMOTE 5
-#define SYNC_PREF_TAKE_BOTH 6
+#include <libkcal/syncdefines.h>
+
+
class KConfig;
/**
@short Class for storing a preferences setting
@author Cornelius Schumacher