-rw-r--r-- | bin/kdepim/MultiSyncHowTo.txt | 435 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 6 |
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 @@ | |||
1 | Multi Sync HowTo | ||
1 | 2 | ||
2 | HAS TO BE WRITTEN | 3 | With KDE-Pim/Pi you can sync several devices |
4 | "in one go". That means you choose on one device | ||
5 | (where everything is confgured in the right way) | ||
6 | "Multiple Sync" and all devices will be synced. | ||
7 | All devices must be reachable via network. | ||
3 | 8 | ||
4 | Sync HowTo Zaurus <-> KDE | 9 | In this HowTo we will give an explicit example what to set up |
10 | and how configure. | ||
5 | 11 | ||
12 | We assume, that we have four devices which should be synced: | ||
13 | A Sharp Zaurus PDA with KDE-Pim/Pi installed.. | ||
14 | A Windows laptop with KDE-Pim/Pi installed. | ||
15 | A Linux Desktop with KDE installed. | ||
16 | A Linux Laptop with KDE installed. | ||
6 | 17 | ||
7 | This is a | 18 | NOTE: Your KDE version must be 3.3.0 or higher for sncing with. |
8 | Sync HowTo Zaurus <-> K-Desktop Environment(KDE) | 19 | Please read KDE Sync HowTo how to update your SuSE 9.1 to KDE 3.3.x |
9 | using the KDE-Pim/Pi applications | 20 | (KDE Sync HowTo is available in the help menu of KO/Pi and KA/Pi). |
10 | KAddressbook/Pi (KA/Pi) and KOrganizer/Pi (KO/Pi) | ||
11 | on the Zaurus (Z). | ||
12 | 21 | ||
13 | You can now easily sync your Z with the | 22 | The Zaurus is connected to the Linux Desktop via USB cable. |
14 | PIM data of the KDE. | ||
15 | (addressbook and calendar data). | ||
16 | You need to install the desktop versions | ||
17 | of KA/Pi+KO/Pi on the desktop. | ||
18 | You need KDE version 3.3.0 or higher on your desktop. | ||
19 | You need KA/Pi+KO/Pi version 1.9.11 or higher on the desktop | ||
20 | and on the Z. | ||
21 | 23 | ||
22 | NOTE: Almost the same procedure will make it possible to | 24 | All calendar addressbook data should be synced with the other devices. |
23 | sync KA/Pi+KO/Pi running on Windows with KDE via network. | 25 | That means in particular, that the calendar/address data of KDE on |
26 | the Linux laptop and desktop is synced with the other devices. | ||
24 | 27 | ||
25 | The setup+sync procedure is: | 28 | First we have to install the needed programs, |
29 | then we have to configure the programs. | ||
26 | 30 | ||
27 | 0) How the syncing works | 31 | ***************************************** |
28 | 1) Installing KA/Pi+KO/Pi on the Z | 32 | (1) Installing the programs: |
29 | 2) Installing desktop version of KA/Pi+KO/Pi on the desktop | 33 | ***************************************** |
30 | 3) Connection your Z to the desktop via network | ||
31 | (network connection can be set up via USB cable or (W)Lan | ||
32 | 4) Configuring KA/Pi+KO/Pi on Z for Sync | ||
33 | 5) Enable remote sync in KA/Pi+KO/Pi on the desktop | ||
34 | 6) Sync | ||
35 | 34 | ||
36 | ***************************************************** | 35 | Download the files from |
37 | 0) How the syncing works | ||
38 | ***************************************************** | ||
39 | |||
40 | After setting up everything, the following actions will | ||
41 | be performed when syncing: | ||
42 | User enables "remote pi-sync" on desktop. | ||
43 | User chooses "sync with configured desktop profile" on the Z. | ||
44 | Z sends sync request via network to configured IP/port/password. | ||
45 | KO/Pi on desktop detects sync request and syncs with KDE (configurable!). | ||
46 | A window pops up, that KO/Pi on desktop is in "remote syncing mode". | ||
47 | If a conflict occurs when syncing KO/PI<->KDE on the desktop, | ||
48 | automatically the newest entry is choosen. | ||
49 | (To avoid the need of user interaction) | ||
50 | KO/Pi on desktop sends synced file to Zaurus. | ||
51 | KO/Pi on desktop is in "waiting mode" to get synced file back. | ||
52 | Zaurus is syncing it's own calendar with the received file. | ||
53 | Here can be some user interaction needed, i.e. | ||
54 | if the sync profile is configured as | ||
55 | "ask for every entry on conflict" and a conflict occurs. | ||
56 | Zaurus sends back synced file to desktop. | ||
57 | Syncing on Zaurus is complete now. | ||
58 | KO/Pi on desktop gets back synced file. | ||
59 | KO/Pi on desktop removes all entries in its own calendar and | ||
60 | reloads the synced file. | ||
61 | KO/Pi on desktop syncs with KDE. | ||
62 | After syncing with KDE is finished, KO/Pi closes | ||
63 | the "remote syncing mode" window and displays | ||
64 | a "syncing complete" message in the headline. | ||
65 | |||
66 | The actual syncing KO/Pi on desktop <-> KDE is | ||
67 | performed by a small command line tool "kdecaldump", | ||
68 | which writes/reads the complete KDE calendar resources to | ||
69 | a file/from a file. | ||
70 | KO/Pi tags changed entries such that an unchanged entry | ||
71 | is not changed in KDE by kdecaldump. That is important for | ||
72 | calendar entries in KDE, stored in a "disconnected IMAP" calendar resource. | ||
73 | |||
74 | |||
75 | Same way is KA/Pi working. | ||
76 | |||
77 | |||
78 | ***************************************************** | ||
79 | 1) Installing KA/Pi+KO/Pi on the Z | ||
80 | ***************************************************** | ||
81 | |||
82 | Download latest version of KA/Pi+KO/Pi from | ||
83 | http://sourceforge.net/projects/kdepimpi/ | 36 | http://sourceforge.net/projects/kdepimpi/ |
84 | Project KDE/Pim. | 37 | project name KDE/Pim. |
85 | Direct link is: | 38 | Download the latest release. |
86 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 | 39 | You will find in every file a ReadMe, |
87 | Click on the version number to read the release notes/change log. | 40 | where you can read how to install. |
88 | Choose there the right precompiled package for your Z: | 41 | (a) Installing KDE-Pim/Pi on the Windows laptop: |
89 | For Sharp ROM | 42 | Download file kdepim_X.X.X_for_Windows.exe.zip |
90 | -File: kdepim_1.x.xx_for_SharpROM.ipk.zip | 43 | (b) Installing KDE-Pim/Pi on the Linux laptop and desktop: |
91 | For Open Zaurus ROM: | 44 | Download file KDE-Pim-Pi-1.9.10-SuSE9.1.i586.rpm.zip |
92 | -File: kdepim_1.x.xx_for_OZ-gcc3xx.ipk.zip | 45 | (c) Installing KDE-Pim/Pi on the Sharp Zaurus PDA: |
93 | If unsure, choose: | 46 | Depending on your Rom: |
94 | -File: kdepim_1.x.xx_for_SharpROM.ipk.zip | 47 | Download file kdepim_X.X.X_for_SharpROM.ipk.zip |
95 | 48 | or file kdepim_X.X.X_for_OZ-gcc3xx.ipk.zip for OpenZaurus users. | |
96 | Unzip the file and install the packages as usual on your Z. | 49 | If unsure, download kdepim_X.X.X_for_SharpROM.ipk.zip |
97 | In order to intstall KA/Pi+KO/Pi on your Z, | 50 | |
98 | you need to install the following files: | 51 | We assume that we have now on every device KDE-Pim/Pi installed. |
99 | kmicrokdelibs_1.x.xx_arm.ipk | 52 | To learn more about syncing, please read now the |
100 | kaddressbook_1.x.xx_arm.ipk | 53 | Sync HowTo |
101 | korganizer_1.x.xx_arm.ipk | 54 | KDE Sync HowTo |
102 | 55 | available in the help menu of KO/Pi and KA/Pi. | |
103 | ***************************************************** | 56 | |
104 | 2) Installing desktop version of KA/Pi+KO/Pi on the desktop | 57 | |
105 | ***************************************************** | 58 | ***************************************** |
59 | (2) Configuring KDE-Pim/Pi for Multiple sync: | ||
60 | ***************************************** | ||
61 | |||
62 | In mutiple sync, we have one aktive sync device and many | ||
63 | other passive sync devices. | ||
64 | |||
65 | We use the Linux desktop as the active sync device. | ||
66 | But there is no limitation. In general, you can choose | ||
67 | any device as active sync device. | ||
68 | The Zaurus is connected to the Linux Desktop via USB cable. | ||
69 | Please read the KDE Sync HowTo to know how to set up this connection. | ||
70 | |||
71 | We assume, that the devices have the following IP numbers: | ||
72 | Windows laptop: 192.168.0.40 | ||
73 | Linux laptop: 192.168.0.88 | ||
74 | Zaurus: 192.168.129.201 | ||
75 | Linux desktop: 192.168.0.99 | ||
76 | |||
77 | ***************************************** | ||
78 | (2a) Configuring the passive sync devices: | ||
79 | ***************************************** | ||
80 | |||
81 | (i) Windows laptop: 192.168.0.40: Name: XP | ||
82 | Start KO/Pi | ||
83 | Choose menu: Synchronize - Enable PiSync | ||
84 | Leave port as the default 9197. | ||
85 | Choose password xyz. | ||
86 | Click OK. | ||
87 | |||
88 | (ii) Linux laptop: 192.168.0.88: Name: BUG | ||
89 | Start KO/Pi | ||
90 | Choose menu: Synchronize - Enable PiSync | ||
91 | Leave port as the default 9197. | ||
92 | Check the box "Automatically sync with KDE-Desktop when receiving sync request". | ||
93 | Choose password xyz. | ||
94 | Click OK. | ||
95 | |||
96 | (iii) Zaurus: 192.168.129.201: Name: Z760 | ||
97 | Start KO/Pi | ||
98 | Choose menu: Synchronize - Enable PiSync | ||
99 | Leave port as the default 9197. | ||
100 | Choose password xyz. | ||
101 | Click OK. | ||
102 | |||
103 | The configuration of the passive sync devices is done. | ||
104 | |||
105 | ***************************************** | ||
106 | (2b) Configuring the aktive sync device: | ||
107 | ***************************************** | ||
108 | |||
109 | Linux desktop: 192.168.0.99: Name: K7 | ||
110 | Start KO/Pi | ||
111 | Choose menu: Synchronize - Configure... | ||
112 | |||
113 | Set "Local device name" to "K7" | ||
114 | |||
115 | Choose profile: KDE_Desktop | ||
116 | Check "Include in multiple calendar sync". | ||
117 | |||
118 | Create new profile. | ||
119 | Set name from "noName" to "XP". | ||
120 | Check "Include in multiple calendar sync". | ||
121 | Set "Profile kind" to "Pi-sync". | ||
122 | Set Calendar: Password for remote access to "xyz" | ||
123 | Set Calendar: Remote IP address to "192.168.0.40" | ||
124 | Do not change: Calendar: Remote port number | ||
125 | |||
126 | Create new profile. | ||
127 | Set name from "noName" to "BUG". | ||
128 | Check "Include in multiple calendar sync". | ||
129 | Set "Profile kind" to "Pi-sync". | ||
130 | Set Calendar: Password for remote access to "xyz" | ||
131 | Set Calendar: Remote IP address to "192.168.0.88" | ||
132 | Do not change: Calendar: Remote port number | ||
133 | |||
134 | |||
135 | Create new profile. | ||
136 | Set name from "noName" to "Z760". | ||
137 | Check "Include in multiple calendar sync". | ||
138 | Set "Profile kind" to "Pi-sync". | ||
139 | Set Calendar: Password for remote access to "xyz" | ||
140 | Set Calendar: Remote IP address to "192.168.129.201" | ||
141 | Do not change: Calendar: Remote port number | ||
142 | |||
143 | Click on OK in the sync config dialog to save settings. | ||
106 | 144 | ||
107 | Precompiled packages are available for SuSE 9.1. | ||
108 | Choose on the above download location: | ||
109 | File: KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm | ||
110 | Download file and install it on console with | ||
111 | su | ||
112 | rpm -ihv KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm | ||
113 | (NOTE:update with rpm -Uhv KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm) | ||
114 | NOTE for users of SuSE 9.1: | ||
115 | You need KDE version 3.3.0 or higher on your desktop. | ||
116 | Plese make an online update in SuSE (YAST), then update | ||
117 | your KDE to version 3.3.0 or higher. | ||
118 | You can find links to updated precompiled versions of KDE | ||
119 | for SuSE 9.1 on the SusE web site, | ||
120 | a direct link is for example: | ||
121 | ftp://ftp.gwdg.de/pub/linux/suse/ftp.suse.com/suse/i386/supplementary/KDE/update_for_9.1 | ||
122 | HOWTO UPDATE KDE: | ||
123 | Download there the packages in "base". | ||
124 | And the needed package for your language in "internationalization". | ||
125 | Put all downloaded files in one "installation" directory. | ||
126 | Open console and go to the downloaded "installation" directory. | ||
127 | Do there a | ||
128 | su | ||
129 | and then perform a test for the update: | ||
130 | rpm -Uhv --test *.rpm | ||
131 | |||
132 | If no dependencies are shown, you can do the actual update with | ||
133 | rpm -Uhv *.rpm | ||
134 | |||
135 | If there are missing dependencies, you can resolve them by | ||
136 | - download the needed updated KDE package from the | ||
137 | "applications" or from the "development" folder on the server. | ||
138 | - adding a needed rpm package from the SuSE install DVD | ||
139 | - remove the package that has dependencies from your "installation" directory. | ||
140 | |||
141 | Do the | ||
142 | rpm -Uhv --test *.rpm | ||
143 | until you get no dependencies and no errors, then do a | ||
144 | rpm -Uhv *.rpm | ||
145 | Run | ||
146 | SuSEconfig | ||
147 | after installing with rpm is finished. | ||
148 | Restart KDE. | ||
149 | 145 | ||
150 | ***************************************************** | 146 | ***************************************************** |
151 | 3) Connection your Z to the desktop via network | 147 | 3) Test Setup |
152 | (network connection can be set up via USB cable or (W)Lan | ||
153 | ***************************************************** | 148 | ***************************************************** |
154 | 149 | ||
155 | a) Connection via network cable/(W)Lan cards | 150 | Choose menu: Synchronize - XP |
156 | Connect your desktop to the network. | 151 | Now the Windows laptop should be syncronized. |
157 | Set up networking on the Z. | ||
158 | Make sure, you can ping the desktop from Z. | ||
159 | b) Connection via USB cable:(is working for Z 7x0 and Z5500) | ||
160 | (i) Open console on desktop and type | ||
161 | su | ||
162 | tail -f /var/log/messages | ||
163 | (ii) Connect your Z with the USB cable to your desktop | ||
164 | You should get as output in the above console | ||
165 | something like this: | ||
166 | ("BUG" is the name of the desktop computer!) | ||
167 | Oct 26 12:49:37 BUG kernel: usb 2-2: new full speed USB device using address 2 | ||
168 | Oct 26 12:49:37 BUG kernel: usb 2-2: Product: SL-C860 | ||
169 | Oct 26 12:49:37 BUG kernel: usb 2-2: Manufacturer: Sharp | ||
170 | Oct 26 12:49:37 BUG /etc/hotplug/usb.agent[22659]: need a device for this command | ||
171 | Oct 26 12:49:43 BUG kernel: usb0: register usbnet at usb-0000:00:1d.0-2, Sharp Zaurus, PXA-2xx based | ||
172 | Oct 26 12:49:43 BUG kernel: usbcore: registered new driver usbnet | ||
173 | You see in the 5. line ("BUG kernel: usb0: register"), that usb device usb0 is used. | ||
174 | (iii) Create a network startup entry in /etc/sysconfig/network | ||
175 | Depending of the number X of the used usb device, create a file | ||
176 | /etc/sysconfig/network/ifcfg-usbX | ||
177 | (in our case /etc/sysconfig/network/ifcfg-usb0 ) | ||
178 | with the following content: | ||
179 | # usbX config for Zaurus | ||
180 | IPADDR='192.168.129.200' | ||
181 | NETMASK='255.255.255.0' | ||
182 | NETWORK='192.168.129.0' | ||
183 | BROADCAST='192.168.129.255' | ||
184 | STARTMODE='hotplug' | ||
185 | (iv) Disconnect the Z and connect the Z again to the desktop. | ||
186 | Now you should be able to ping the Z from the desktop, try in console on desktop: | ||
187 | ping 192.168.129.201 | ||
188 | Now you should be able to ping the desktop from the Z, try in console on Z: | ||
189 | ping 192.168.129.200 | ||
190 | |||
191 | Now you will get a network connection automatically, | ||
192 | if you connect your Z to the desktop via the USB cable. | ||
193 | |||
194 | |||
195 | In the following, we assume, that | ||
196 | the desktop has the IP address: 192.168.129.200 | ||
197 | and that | ||
198 | the Z has the IP address: 192.168.129.201 | ||
199 | |||
200 | ***************************************************** | ||
201 | 4) Configuring KA/Pi+KO/Pi on Z for Sync | ||
202 | ***************************************************** | ||
203 | 152 | ||
204 | Start KO/Pi on the Z. | 153 | Choose menu: Synchronize - Z760 |
205 | Choose Menu: Synchronize - Configure | 154 | Now the Zaurus should be syncronized. |
206 | Fill in name for "Local device name:", e.g. "Z760" | ||
207 | Click on "New profile" | ||
208 | Set name of "Profile:", e.g. "BUG". | ||
209 | (that is the above name of the desktop computer) | ||
210 | Choose "Profile kind": Pi-Sync. | ||
211 | Set "Password for remote access", e.g. "xyz" for | ||
212 | Calendar and Addressbook. | ||
213 | Set Remote IP address to 192.168.129.200 for | ||
214 | Calendar and Addressbook. | ||
215 | (Note: That is the IP address of the desktop!). | ||
216 | The "Remote port number" is 9197/9198 for | ||
217 | Calendar and Addressbook. | ||
218 | You do not have to change the | ||
219 | "Remote port number" or any other settings. | ||
220 | Click "OK" button to save your settings. | ||
221 | |||
222 | Now you have configured KA/Pi+KO/Pi sync on the Z, | ||
223 | no need to configure anything in KA/Pi. | ||
224 | 155 | ||
156 | Choose menu: Synchronize - BUG | ||
157 | Now the Linux laptop (and KDE there) should be syncronized. | ||
225 | 158 | ||
226 | ***************************************************** | 159 | Choose menu: Synchronize - KDE_Desktop |
227 | 5) Enable remote sync in KA/Pi+KO/Pi on the desktop | 160 | Now KDE on the Linux desptop (your device you are syncing from) |
228 | ***************************************************** | 161 | should be syncronized with KO/Pi. |
229 | 162 | ||
230 | Start KO/Pi on the desktop. | ||
231 | Do a "test" sync with KDE, choose menu: | ||
232 | Synchronize - KDE_Desktop | ||
233 | After syncing, you should have the same data in KDE | ||
234 | and in KO/Pi. | ||
235 | NOTE: | ||
236 | The KO/Pi version 1.9.10 had the bug, that on the first | ||
237 | sync with KDE, all data in KDE was deleted. | ||
238 | DO NOT USE VERSION 1.9.10! | ||
239 | |||
240 | The bevaviour on the first sync is | ||
241 | (in versions >= 1.9.11) | ||
242 | that no data is deleted, the data in KO/Pi and in | ||
243 | KDE is merged into one calendar. | ||
244 | |||
245 | When the first sync was ok, please choose menu: | ||
246 | Synchronize - Enable Pi-sync | ||
247 | Fill in the values for port ("9197" in our examle) | ||
248 | and for the password ( "xyz" in our example) | ||
249 | that you did configure on the Z for that computer. | ||
250 | Enable "Automatically start at application start" | ||
251 | and "Automatically sync with KDE-Desktop when receiving sync request" | ||
252 | by checking the two boxes. | ||
253 | Close KO/Pi. | ||
254 | |||
255 | Configure / test KA/Pi on the desktop in the same way. | ||
256 | Fill in the right value for the port (9198 in our examle) | ||
257 | in KA/Pi! | ||
258 | 163 | ||
259 | ***************************************************** | 164 | ***************************************************** |
260 | 6) Sync | 165 | 4) Sync all devices |
261 | ***************************************************** | 166 | ***************************************************** |
262 | 167 | ||
263 | After configuring everything as above, you have to do | 168 | Choose menu: Synchronize - Multiple Sync |
264 | the following, if you want to sync your Zaurus with KDE: | ||
265 | (It syncs will all resources in KDE, that are not "readonly"). | ||
266 | 169 | ||
267 | Start KO/Pi on the desktop. | 170 | Watch the devices interchanging the calendar data ... |
268 | If Kontact or KOrganizer is running, save the calendar! | ||
269 | Connect the Z with the USB cable to your desktop. | ||
270 | (Or to the local network). | ||
271 | Choose on the Z the menu: | ||
272 | Syncronize - <your name for the desktop sync profile> | ||
273 | ( that was "BUG" in our example ). | ||
274 | That's all. | ||
275 | 171 | ||
276 | Do the same with KA/Pi. | 172 | Wait until you get the message in the KO/Pi header: |
277 | 173 | ||
278 | NOTE: | 174 | 4 profiles synced. Multiple sync complete! |
279 | If an appointment/addressee is created on the Z, it is added to the | ||
280 | standard resource in KDE. | ||
281 | |||
282 | If you have todos with subtodos in your calendar, you will get on | ||
283 | every sync (after you restartet KOrganizer or Kontact in KDE) | ||
284 | the message "xx items changed on local", where | ||
285 | xx is greater or equal to the number of todos. | ||
286 | That behaviour is caused by a bug in KDE. | ||
287 | (In KDE, everytime a subtodo is loaded, | ||
288 | it's "last modified" settings are set to the current time - ouch!) | ||
289 | I hope I can fix this bug in KDE soon. | ||
290 | 175 | ||
176 | NOTE: | ||
177 | If you want to test syncing, you may get wrong results, | ||
178 | if the clocks of the synced devices have too much difference. | ||
179 | |||
180 | Example: Your clocks have a difference of 2 minutes. | ||
181 | You sync. | ||
182 | You edit an appointment on two devices. | ||
183 | You sync again. | ||
184 | You should get a conflict - but you do not get it. | ||
185 | The reason is: On one device the "last modified" | ||
186 | datetime entry of the editet appointment is before the | ||
187 | last sync event datetime on the local device. | ||
188 | Such that the rule is: | ||
189 | If you have a clock difference of X seconds, you may get | ||
190 | wrong results, if you edit the same event within that | ||
191 | X seconds on two devices. | ||
192 | Same is valid for creating a new event, of course. | ||
193 | If creation datetime is before the last sync, it is assumed that there was | ||
194 | an existing event on the local device and the newly created remote | ||
195 | event is deleted. | ||
291 | 196 | ||
292 | 197 | ||
198 | ***************************************************** | ||
199 | 5) Sync KA/Pi | ||
200 | ***************************************************** | ||
293 | 201 | ||
202 | Setup KA/Pi in the same way like KO/Pi. | ||
294 | 203 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 59bf615..59f3b40 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -840,228 +840,228 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local ********************** | 1019 | if ( take == 1 ) {// take local ********************** |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else {// take remote ********************** | 1033 | } else {// take remote ********************** |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict ********** add or delete remote | 1049 | } else { // no conflict ********** add or delete remote |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1065 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1066 | ++addedEvent; | 1066 | ++addedEvent; |
1067 | } | 1067 | } |