summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/MultiSyncHowTo.txt435
-rw-r--r--korganizer/calendarview.cpp6
2 files changed, 175 insertions, 266 deletions
diff --git a/bin/kdepim/MultiSyncHowTo.txt b/bin/kdepim/MultiSyncHowTo.txt
index 25e5be8..3591eb9 100644
--- a/bin/kdepim/MultiSyncHowTo.txt
+++ b/bin/kdepim/MultiSyncHowTo.txt
@@ -1,294 +1,203 @@
+Multi Sync HowTo
-HAS TO BE WRITTEN
+With KDE-Pim/Pi you can sync several devices
+"in one go". That means you choose on one device
+(where everything is confgured in the right way)
+"Multiple Sync" and all devices will be synced.
+All devices must be reachable via network.
-Sync HowTo Zaurus <-> KDE
+In this HowTo we will give an explicit example what to set up
+and how configure.
+We assume, that we have four devices which should be synced:
+A Sharp Zaurus PDA with KDE-Pim/Pi installed..
+A Windows laptop with KDE-Pim/Pi installed.
+A Linux Desktop with KDE installed.
+A Linux Laptop with KDE installed.
-This is a
-Sync HowTo Zaurus <-> K-Desktop Environment(KDE)
-using the KDE-Pim/Pi applications
-KAddressbook/Pi (KA/Pi) and KOrganizer/Pi (KO/Pi)
-on the Zaurus (Z).
+NOTE: Your KDE version must be 3.3.0 or higher for sncing with.
+ Please read KDE Sync HowTo how to update your SuSE 9.1 to KDE 3.3.x
+ (KDE Sync HowTo is available in the help menu of KO/Pi and KA/Pi).
-You can now easily sync your Z with the
-PIM data of the KDE.
-(addressbook and calendar data).
-You need to install the desktop versions
-of KA/Pi+KO/Pi on the desktop.
-You need KDE version 3.3.0 or higher on your desktop.
-You need KA/Pi+KO/Pi version 1.9.11 or higher on the desktop
-and on the Z.
+The Zaurus is connected to the Linux Desktop via USB cable.
-NOTE: Almost the same procedure will make it possible to
-sync KA/Pi+KO/Pi running on Windows with KDE via network.
+All calendar addressbook data should be synced with the other devices.
+That means in particular, that the calendar/address data of KDE on
+the Linux laptop and desktop is synced with the other devices.
-The setup+sync procedure is:
+First we have to install the needed programs,
+then we have to configure the programs.
-0) How the syncing works
-1) Installing KA/Pi+KO/Pi on the Z
-2) Installing desktop version of KA/Pi+KO/Pi on the desktop
-3) Connection your Z to the desktop via network
- (network connection can be set up via USB cable or (W)Lan
-4) Configuring KA/Pi+KO/Pi on Z for Sync
-5) Enable remote sync in KA/Pi+KO/Pi on the desktop
-6) Sync
+*****************************************
+(1) Installing the programs:
+*****************************************
-*****************************************************
-0) How the syncing works
-*****************************************************
-
-After setting up everything, the following actions will
-be performed when syncing:
-User enables "remote pi-sync" on desktop.
-User chooses "sync with configured desktop profile" on the Z.
-Z sends sync request via network to configured IP/port/password.
-KO/Pi on desktop detects sync request and syncs with KDE (configurable!).
-A window pops up, that KO/Pi on desktop is in "remote syncing mode".
-If a conflict occurs when syncing KO/PI<->KDE on the desktop,
-automatically the newest entry is choosen.
-(To avoid the need of user interaction)
-KO/Pi on desktop sends synced file to Zaurus.
-KO/Pi on desktop is in "waiting mode" to get synced file back.
-Zaurus is syncing it's own calendar with the received file.
-Here can be some user interaction needed, i.e.
-if the sync profile is configured as
-"ask for every entry on conflict" and a conflict occurs.
-Zaurus sends back synced file to desktop.
-Syncing on Zaurus is complete now.
-KO/Pi on desktop gets back synced file.
-KO/Pi on desktop removes all entries in its own calendar and
-reloads the synced file.
-KO/Pi on desktop syncs with KDE.
-After syncing with KDE is finished, KO/Pi closes
-the "remote syncing mode" window and displays
-a "syncing complete" message in the headline.
-
-The actual syncing KO/Pi on desktop <-> KDE is
-performed by a small command line tool "kdecaldump",
-which writes/reads the complete KDE calendar resources to
-a file/from a file.
-KO/Pi tags changed entries such that an unchanged entry
-is not changed in KDE by kdecaldump. That is important for
-calendar entries in KDE, stored in a "disconnected IMAP" calendar resource.
-
-
-Same way is KA/Pi working.
-
-
-*****************************************************
-1) Installing KA/Pi+KO/Pi on the Z
-*****************************************************
-
-Download latest version of KA/Pi+KO/Pi from
+Download the files from
http://sourceforge.net/projects/kdepimpi/
-Project KDE/Pim.
-Direct link is:
-http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604
-Click on the version number to read the release notes/change log.
-Choose there the right precompiled package for your Z:
-For Sharp ROM
--File: kdepim_1.x.xx_for_SharpROM.ipk.zip
-For Open Zaurus ROM:
--File: kdepim_1.x.xx_for_OZ-gcc3xx.ipk.zip
-If unsure, choose:
--File: kdepim_1.x.xx_for_SharpROM.ipk.zip
-
-Unzip the file and install the packages as usual on your Z.
-In order to intstall KA/Pi+KO/Pi on your Z,
-you need to install the following files:
-kmicrokdelibs_1.x.xx_arm.ipk
-kaddressbook_1.x.xx_arm.ipk
-korganizer_1.x.xx_arm.ipk
-
-*****************************************************
-2) Installing desktop version of KA/Pi+KO/Pi on the desktop
-*****************************************************
+project name KDE/Pim.
+Download the latest release.
+You will find in every file a ReadMe,
+where you can read how to install.
+(a) Installing KDE-Pim/Pi on the Windows laptop:
+ Download file kdepim_X.X.X_for_Windows.exe.zip
+(b) Installing KDE-Pim/Pi on the Linux laptop and desktop:
+ Download file KDE-Pim-Pi-1.9.10-SuSE9.1.i586.rpm.zip
+(c) Installing KDE-Pim/Pi on the Sharp Zaurus PDA:
+ Depending on your Rom:
+ Download file kdepim_X.X.X_for_SharpROM.ipk.zip
+ or file kdepim_X.X.X_for_OZ-gcc3xx.ipk.zip for OpenZaurus users.
+ If unsure, download kdepim_X.X.X_for_SharpROM.ipk.zip
+
+We assume that we have now on every device KDE-Pim/Pi installed.
+To learn more about syncing, please read now the
+Sync HowTo
+KDE Sync HowTo
+available in the help menu of KO/Pi and KA/Pi.
+
+
+*****************************************
+(2) Configuring KDE-Pim/Pi for Multiple sync:
+*****************************************
+
+In mutiple sync, we have one aktive sync device and many
+other passive sync devices.
+
+We use the Linux desktop as the active sync device.
+But there is no limitation. In general, you can choose
+any device as active sync device.
+The Zaurus is connected to the Linux Desktop via USB cable.
+Please read the KDE Sync HowTo to know how to set up this connection.
+
+We assume, that the devices have the following IP numbers:
+Windows laptop: 192.168.0.40
+Linux laptop: 192.168.0.88
+Zaurus: 192.168.129.201
+Linux desktop: 192.168.0.99
+
+*****************************************
+(2a) Configuring the passive sync devices:
+*****************************************
+
+(i) Windows laptop: 192.168.0.40: Name: XP
+Start KO/Pi
+Choose menu: Synchronize - Enable PiSync
+Leave port as the default 9197.
+Choose password xyz.
+Click OK.
+
+(ii) Linux laptop: 192.168.0.88: Name: BUG
+Start KO/Pi
+Choose menu: Synchronize - Enable PiSync
+Leave port as the default 9197.
+Check the box "Automatically sync with KDE-Desktop when receiving sync request".
+Choose password xyz.
+Click OK.
+
+(iii) Zaurus: 192.168.129.201: Name: Z760
+Start KO/Pi
+Choose menu: Synchronize - Enable PiSync
+Leave port as the default 9197.
+Choose password xyz.
+Click OK.
+
+The configuration of the passive sync devices is done.
+
+*****************************************
+(2b) Configuring the aktive sync device:
+*****************************************
+
+Linux desktop: 192.168.0.99: Name: K7
+Start KO/Pi
+Choose menu: Synchronize - Configure...
+
+Set "Local device name" to "K7"
+
+Choose profile: KDE_Desktop
+Check "Include in multiple calendar sync".
+
+Create new profile.
+Set name from "noName" to "XP".
+Check "Include in multiple calendar sync".
+Set "Profile kind" to "Pi-sync".
+Set Calendar: Password for remote access to "xyz"
+Set Calendar: Remote IP address to "192.168.0.40"
+Do not change: Calendar: Remote port number
+
+Create new profile.
+Set name from "noName" to "BUG".
+Check "Include in multiple calendar sync".
+Set "Profile kind" to "Pi-sync".
+Set Calendar: Password for remote access to "xyz"
+Set Calendar: Remote IP address to "192.168.0.88"
+Do not change: Calendar: Remote port number
+
+
+Create new profile.
+Set name from "noName" to "Z760".
+Check "Include in multiple calendar sync".
+Set "Profile kind" to "Pi-sync".
+Set Calendar: Password for remote access to "xyz"
+Set Calendar: Remote IP address to "192.168.129.201"
+Do not change: Calendar: Remote port number
+
+Click on OK in the sync config dialog to save settings.
-Precompiled packages are available for SuSE 9.1.
-Choose on the above download location:
-File: KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm
-Download file and install it on console with
-su
-rpm -ihv KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm
-(NOTE:update with rpm -Uhv KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm)
-NOTE for users of SuSE 9.1:
-You need KDE version 3.3.0 or higher on your desktop.
-Plese make an online update in SuSE (YAST), then update
-your KDE to version 3.3.0 or higher.
-You can find links to updated precompiled versions of KDE
-for SuSE 9.1 on the SusE web site,
-a direct link is for example:
-ftp://ftp.gwdg.de/pub/linux/suse/ftp.suse.com/suse/i386/supplementary/KDE/update_for_9.1
-HOWTO UPDATE KDE:
-Download there the packages in "base".
-And the needed package for your language in "internationalization".
-Put all downloaded files in one "installation" directory.
-Open console and go to the downloaded "installation" directory.
-Do there a
-su
-and then perform a test for the update:
-rpm -Uhv --test *.rpm
-
-If no dependencies are shown, you can do the actual update with
-rpm -Uhv *.rpm
-
-If there are missing dependencies, you can resolve them by
-- download the needed updated KDE package from the
- "applications" or from the "development" folder on the server.
-- adding a needed rpm package from the SuSE install DVD
-- remove the package that has dependencies from your "installation" directory.
-
-Do the
-rpm -Uhv --test *.rpm
-until you get no dependencies and no errors, then do a
-rpm -Uhv *.rpm
-Run
-SuSEconfig
-after installing with rpm is finished.
-Restart KDE.
*****************************************************
-3) Connection your Z to the desktop via network
- (network connection can be set up via USB cable or (W)Lan
+3) Test Setup
*****************************************************
-a) Connection via network cable/(W)Lan cards
- Connect your desktop to the network.
- Set up networking on the Z.
- Make sure, you can ping the desktop from Z.
-b) Connection via USB cable:(is working for Z 7x0 and Z5500)
- (i) Open console on desktop and type
- su
- tail -f /var/log/messages
- (ii) Connect your Z with the USB cable to your desktop
- You should get as output in the above console
- something like this:
- ("BUG" is the name of the desktop computer!)
- Oct 26 12:49:37 BUG kernel: usb 2-2: new full speed USB device using address 2
- Oct 26 12:49:37 BUG kernel: usb 2-2: Product: SL-C860
- Oct 26 12:49:37 BUG kernel: usb 2-2: Manufacturer: Sharp
- Oct 26 12:49:37 BUG /etc/hotplug/usb.agent[22659]: need a device for this command
- Oct 26 12:49:43 BUG kernel: usb0: register usbnet at usb-0000:00:1d.0-2, Sharp Zaurus, PXA-2xx based
- Oct 26 12:49:43 BUG kernel: usbcore: registered new driver usbnet
- You see in the 5. line ("BUG kernel: usb0: register"), that usb device usb0 is used.
- (iii) Create a network startup entry in /etc/sysconfig/network
- Depending of the number X of the used usb device, create a file
- /etc/sysconfig/network/ifcfg-usbX
- (in our case /etc/sysconfig/network/ifcfg-usb0 )
- with the following content:
- # usbX config for Zaurus
- IPADDR='192.168.129.200'
- NETMASK='255.255.255.0'
- NETWORK='192.168.129.0'
- BROADCAST='192.168.129.255'
- STARTMODE='hotplug'
- (iv) Disconnect the Z and connect the Z again to the desktop.
- Now you should be able to ping the Z from the desktop, try in console on desktop:
- ping 192.168.129.201
- Now you should be able to ping the desktop from the Z, try in console on Z:
- ping 192.168.129.200
-
- Now you will get a network connection automatically,
- if you connect your Z to the desktop via the USB cable.
-
-
-In the following, we assume, that
-the desktop has the IP address: 192.168.129.200
-and that
-the Z has the IP address: 192.168.129.201
+Choose menu: Synchronize - XP
+Now the Windows laptop should be syncronized.
-*****************************************************
-4) Configuring KA/Pi+KO/Pi on Z for Sync
-*****************************************************
-
-Start KO/Pi on the Z.
-Choose Menu: Synchronize - Configure
-Fill in name for "Local device name:", e.g. "Z760"
-Click on "New profile"
-Set name of "Profile:", e.g. "BUG".
-(that is the above name of the desktop computer)
-Choose "Profile kind": Pi-Sync.
-Set "Password for remote access", e.g. "xyz" for
-Calendar and Addressbook.
-Set Remote IP address to 192.168.129.200 for
-Calendar and Addressbook.
-(Note: That is the IP address of the desktop!).
-The "Remote port number" is 9197/9198 for
-Calendar and Addressbook.
-You do not have to change the
-"Remote port number" or any other settings.
-Click "OK" button to save your settings.
-
-Now you have configured KA/Pi+KO/Pi sync on the Z,
-no need to configure anything in KA/Pi.
+Choose menu: Synchronize - Z760
+Now the Zaurus should be syncronized.
+Choose menu: Synchronize - BUG
+Now the Linux laptop (and KDE there) should be syncronized.
-*****************************************************
-5) Enable remote sync in KA/Pi+KO/Pi on the desktop
-*****************************************************
+Choose menu: Synchronize - KDE_Desktop
+Now KDE on the Linux desptop (your device you are syncing from)
+should be syncronized with KO/Pi.
-Start KO/Pi on the desktop.
-Do a "test" sync with KDE, choose menu:
-Synchronize - KDE_Desktop
-After syncing, you should have the same data in KDE
-and in KO/Pi.
-NOTE:
-The KO/Pi version 1.9.10 had the bug, that on the first
-sync with KDE, all data in KDE was deleted.
-DO NOT USE VERSION 1.9.10!
-
-The bevaviour on the first sync is
-(in versions >= 1.9.11)
-that no data is deleted, the data in KO/Pi and in
-KDE is merged into one calendar.
-
-When the first sync was ok, please choose menu:
-Synchronize - Enable Pi-sync
-Fill in the values for port ("9197" in our examle)
-and for the password ( "xyz" in our example)
-that you did configure on the Z for that computer.
-Enable "Automatically start at application start"
-and "Automatically sync with KDE-Desktop when receiving sync request"
-by checking the two boxes.
-Close KO/Pi.
-
-Configure / test KA/Pi on the desktop in the same way.
-Fill in the right value for the port (9198 in our examle)
-in KA/Pi!
*****************************************************
-6) Sync
+4) Sync all devices
*****************************************************
-After configuring everything as above, you have to do
-the following, if you want to sync your Zaurus with KDE:
-(It syncs will all resources in KDE, that are not "readonly").
+Choose menu: Synchronize - Multiple Sync
-Start KO/Pi on the desktop.
-If Kontact or KOrganizer is running, save the calendar!
-Connect the Z with the USB cable to your desktop.
-(Or to the local network).
-Choose on the Z the menu:
-Syncronize - <your name for the desktop sync profile>
-( that was "BUG" in our example ).
-That's all.
+Watch the devices interchanging the calendar data ...
-Do the same with KA/Pi.
+Wait until you get the message in the KO/Pi header:
-NOTE:
-If an appointment/addressee is created on the Z, it is added to the
-standard resource in KDE.
-
-If you have todos with subtodos in your calendar, you will get on
-every sync (after you restartet KOrganizer or Kontact in KDE)
-the message "xx items changed on local", where
-xx is greater or equal to the number of todos.
-That behaviour is caused by a bug in KDE.
-(In KDE, everytime a subtodo is loaded,
-it's "last modified" settings are set to the current time - ouch!)
-I hope I can fix this bug in KDE soon.
+4 profiles synced. Multiple sync complete!
+NOTE:
+If you want to test syncing, you may get wrong results,
+if the clocks of the synced devices have too much difference.
+
+Example: Your clocks have a difference of 2 minutes.
+You sync.
+You edit an appointment on two devices.
+You sync again.
+You should get a conflict - but you do not get it.
+The reason is: On one device the "last modified"
+datetime entry of the editet appointment is before the
+last sync event datetime on the local device.
+Such that the rule is:
+If you have a clock difference of X seconds, you may get
+wrong results, if you edit the same event within that
+X seconds on two devices.
+Same is valid for creating a new event, of course.
+If creation datetime is before the last sync, it is assumed that there was
+an existing event on the local device and the newly created remote
+event is deleted.
+*****************************************************
+5) Sync KA/Pi
+*****************************************************
+Setup KA/Pi in the same way like KO/Pi.
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 59bf615..59f3b40 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -744,420 +744,420 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
if ( remCh )
remoteMod =( lastSync.addDays( 1 ) );
}
}
full = true;
if ( mode < SYNC_PREF_ASK )
mode = SYNC_PREF_ASK;
} else {
if ( localMod == remoteMod )
// 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", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
//qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.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("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
if ( full && mode < SYNC_PREF_NEWEST )
mode = SYNC_PREF_ASK;
switch( mode ) {
case SYNC_PREF_LOCAL:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 1;
break;
case SYNC_PREF_REMOTE:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 2;
break;
case SYNC_PREF_NEWEST:
if ( localMod > remoteMod )
return 1;
else
return 2;
break;
case SYNC_PREF_ASK:
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
localIsNew = localMod >= remoteMod;
if ( localIsNew )
getEventViewerDialog()->setColorMode( 1 );
else
getEventViewerDialog()->setColorMode( 2 );
getEventViewerDialog()->setIncidence(local);
if ( localIsNew )
getEventViewerDialog()->setColorMode( 2 );
else
getEventViewerDialog()->setColorMode( 1 );
getEventViewerDialog()->addIncidence(remote);
getEventViewerDialog()->setColorMode( 0 );
//qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
getEventViewerDialog()->showMe();
result = getEventViewerDialog()->executeS( localIsNew );
return result;
break;
case SYNC_PREF_FORCE_LOCAL:
return 1;
break;
case SYNC_PREF_FORCE_REMOTE:
return 2;
break;
default:
// SYNC_PREF_TAKE_BOTH not implemented
break;
}
return 0;
}
Event* CalendarView::getLastSyncEvent()
{
Event* lse;
//qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
if (!lse) {
lse = new Event();
lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
QString sum = "";
if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
sum = "E: ";
lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
lse->setDtStart( mLastCalendarSync );
lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
lse->setCategories( i18n("SyncEvent") );
lse->setReadOnly( true );
mCalendar->addEvent( lse );
}
return lse;
}
// we check, if the to delete event has a id for a profile
// if yes, we set this id in the profile to delete
void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
{
if ( lastSync.count() == 0 ) {
//qDebug(" lastSync.count() == 0");
return;
}
if ( toDelete->type() == "Journal" )
return;
Event* eve = lastSync.first();
while ( eve ) {
QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
if ( !id.isEmpty() ) {
QString des = eve->description();
QString pref = "e";
if ( toDelete->type() == "Todo" )
pref = "t";
des += pref+ id + ",";
eve->setReadOnly( false );
eve->setDescription( des );
//qDebug("setdes %s ", des.latin1());
eve->setReadOnly( true );
}
eve = lastSync.next();
}
}
void CalendarView::checkExternalId( Incidence * inc )
{
QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
checkExternSyncEvent( lastSync, inc );
}
bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
{
bool syncOK = true;
int addedEvent = 0;
int addedEventR = 0;
int deletedEventR = 0;
int deletedEventL = 0;
int changedLocal = 0;
int changedRemote = 0;
//QPtrList<Event> el = local->rawEvents();
Event* eventR;
QString uid;
int take;
Event* eventL;
Event* eventRSync;
Event* eventLSync;
QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastCalendarSync = QDateTime::currentDateTime();
if ( mSyncManager->syncWithDesktop() ) {
remote->resetPilotStat(1);
if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
} else {
- qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime ");
+ qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
}
}
- QDateTime modifiedCalendar = mLastCalendarSync;;
+ QDateTime modifiedCalendar = mLastCalendarSync;
eventLSync = getLastSyncEvent();
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
eventRSync = (Event*) eventR->clone();
remote->deleteEvent(eventR );
} else {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
eventRSync = (Event*)eventLSync->clone();
} else {
fullDateRange = true;
eventRSync = new Event();
eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
eventRSync->setDtStart( mLastCalendarSync );
eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
eventRSync->setCategories( i18n("SyncEvent") );
}
}
if ( eventLSync->dtStart() == mLastCalendarSync )
fullDateRange = true;
if ( ! fullDateRange ) {
if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
// qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
//qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
fullDateRange = true;
}
}
if ( mSyncManager->syncWithDesktop() ) {
- fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync );
+ fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
}
if ( fullDateRange )
mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastCalendarSync = eventLSync->dtStart();
// for resyncing if own file has changed
if ( mCurrentSyncDevice == "deleteaftersync" ) {
mLastCalendarSync = loadedFileVersion;
//qDebug("setting mLastCalendarSync ");
}
//qDebug("*************************** ");
qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
QPtrList<Incidence> er = remote->rawIncidences();
Incidence* inR = er.first();
Incidence* inL;
QProgressBar bar( er.count(),0 );
bar.setCaption (i18n("Syncing - close to abort!") );
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar.sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar.show();
int modulo = (er.count()/10)+1;
int incCounter = 0;
while ( inR ) {
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inR->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
QString idS;
qApp->processEvents();
if ( !skipIncidence ) {
inL = local->incidence( uid );
if ( inL ) { // maybe conflict - same uid in both calendars
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 **********************
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
else
idS = inR->IDStr();
remote->deleteIncidence( inR );
inR = inL->clone();
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
inR->setIDStr( idS );
remote->addIncidence( inR );
if ( mSyncManager->syncWithDesktop() )
inR->setPilotId( 2 );
++changedRemote;
} else {// take remote **********************
idS = inL->IDStr();
int pid = inL->pilotId();
local->deleteIncidence( inL );
inL = inR->clone();
if ( mSyncManager->syncWithDesktop() )
inL->setPilotId( pid );
inL->setIDStr( idS );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
}
local->addIncidence( inL );
++changedLocal;
}
}
} else { // no conflict ********** add or delete remote
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 );
inL = inR->clone();
inL->setIDStr( ":" );
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
local->addIncidence( inL );
++addedEvent;
}
} else {
if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
local->addIncidence( inL );
++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;
while ( inL ) {
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 ) { // no conflict ********** add or delete local
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
//qDebug("remote added Incidence %s ", inL->summary().latin1());
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
remote->addIncidence( inR );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
remote->addIncidence( inR );
}
}
}
}
}
inL = el.next();
}
int delFut = 0;
int remRem = 0;
if ( mSyncManager->mWriteBackInFuture ) {
er = remote->rawIncidences();
remRem = er.count();
inR = er.first();
QDateTime dt;
QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
while ( inR ) {
if ( inR->type() == "Todo" ) {
Todo * t = (Todo*)inR;
if ( t->hasDueDate() )
dt = t->dtDue();
else
dt = cur.addSecs( 62 );
}
else if (inR->type() == "Event" ) {