-rw-r--r-- | bin/kdepim/korganizer/howtoSYNC.txt | 19 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 58 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 1 |
3 files changed, 64 insertions, 14 deletions
diff --git a/bin/kdepim/korganizer/howtoSYNC.txt b/bin/kdepim/korganizer/howtoSYNC.txt index d3046de..c4e80f5 100644 --- a/bin/kdepim/korganizer/howtoSYNC.txt +++ b/bin/kdepim/korganizer/howtoSYNC.txt | |||
@@ -1,468 +1,483 @@ | |||
1 | WARNING: | 1 | WARNING: |
2 | YOU MAY GET UNEXSPECTED (I.E. WRONG) SYNCHRONIZATION RESULTS, | 2 | YOU MAY GET UNEXSPECTED (I.E. WRONG) SYNCHRONIZATION RESULTS, |
3 | IF YOU CHANGE AN EVENT ON THE FIRST DEVICE AND SYNC IMMEDIATELY FROM | 3 | IF YOU CHANGE AN EVENT ON THE FIRST DEVICE AND SYNC IMMEDIATELY FROM |
4 | THE OTHER DEVICE WITH THIS DEVICE, IF THE CLOCKS OF THE TWO DEVICES | 4 | THE OTHER DEVICE WITH THIS DEVICE, IF THE CLOCKS OF THE TWO DEVICES |
5 | HAVE TOO MUCH DIFFERENCE. | 5 | HAVE TOO MUCH DIFFERENCE. |
6 | 6 | ||
7 | In other words: Please make shure, that the clocks of the devices | 7 | In other words: Please make shure, that the clocks of the devices |
8 | you want to sync have only a difference of some seconds! | 8 | you want to sync have only a difference of some seconds! |
9 | 9 | ||
10 | 10 | ||
11 | CONTENT: | 11 | CONTENT: |
12 | 12 | ||
13 | 0) How syncing works | 13 | 0) How syncing works |
14 | 1) Qick overview of settings | 14 | 1) Qick overview of settings |
15 | 2) Sync settings in sync dialog | 15 | 2) Sync settings in sync dialog |
16 | 3) Syncing background | 16 | 3) Syncing background |
17 | 4) Sync preferences | 17 | 4) Sync preferences |
18 | 5) Details about sync profile kinds | 18 | 5) Details about sync profile kinds |
19 | 19 | ||
20 | ************************************************************************* | 20 | ************************************************************************* |
21 | 0) How syncing works | 21 | 0) How syncing works |
22 | ************************************************************************* | 22 | ************************************************************************* |
23 | 23 | ||
24 | Note: | 24 | Note: |
25 | The recommended and easiest way to syncronize two devices where | 25 | The recommended and easiest way to syncronize two devices where |
26 | KO/Pi or KA/Pi is installed, is the profile kind "Pi-Sync". | 26 | KO/Pi or KA/Pi is installed, is the profile kind "Pi-Sync". |
27 | Details about that in 5) b). | 27 | Details about that in 5) b). |
28 | 28 | ||
29 | In KDE-Pim/Pi you can synchronize ( sync ) your calendar/addressbook | 29 | In KDE-Pim/Pi you can synchronize ( sync ) your calendar/addressbook |
30 | with another calendar/addressbook , by syncing your | 30 | with another calendar/addressbook , by syncing your |
31 | (local) calendar/addressbook with a (remote) file. | 31 | (local) calendar/addressbook with a (remote) file. |
32 | This remote file may on your local filesystem | 32 | This remote file may on your local filesystem |
33 | or on another (remote) device. | 33 | or on another (remote) device. |
34 | 34 | ||
35 | If you want to sync with another remote device, | 35 | If you want to sync with another remote device, |
36 | you have two create a sync profile. | 36 | you have two create a sync profile. |
37 | You have two choices for choosing the profil kind: | 37 | You have two choices for choosing the profil kind: |
38 | I) You have to choose profile kind "Remote file" and to specify a | 38 | I) You have to choose profile kind "Remote file" and to specify a |
39 | command line download/upload command ( like scp, ftp, ...) to | 39 | command line download/upload command ( like scp, ftp, ...) to |
40 | a) download the remote file to your local machine to a temp file | 40 | a) download the remote file to your local machine to a temp file |
41 | b) sync with this temp file | 41 | b) sync with this temp file |
42 | c) upload the synced file to the remote device | 42 | c) upload the synced file to the remote device |
43 | II) If you want to sync with a device, where KO/Pi( or KA/Pi ) is | 43 | II) If you want to sync with a device, where KO/Pi( or KA/Pi ) is |
44 | installed, you can easily get the remote file via network | 44 | installed, you can easily get the remote file via network |
45 | with the build in file transfer feature: | 45 | with the build in file transfer feature: |
46 | Choose profile kind "Pi-Sync" and | 46 | Choose profile kind "Pi-Sync" and |
47 | a) Start KO/Pi or KA/Pi on remote device and | 47 | a) Start KO/Pi or KA/Pi on remote device and |
48 | enable "Pi-Sync" on remote device with password and port. | 48 | enable "Pi-Sync" on remote device with password and port. |
49 | b) Specify password, port and IP address in your profile. | 49 | b) Specify password, port and IP address in your profile. |
50 | 50 | ||
51 | 51 | ||
52 | You can sync with your mobile phone as well. | 52 | You can sync with your mobile phone as well. |
53 | Everything is explained in more details below. | 53 | Everything is explained in more details below. |
54 | 54 | ||
55 | NOTE: | 55 | NOTE: |
56 | If you do not use profile kind "Pi-Sync", | 56 | If you do not use profile kind "Pi-Sync", |
57 | it is recommended to close | 57 | it is recommended to close |
58 | a running KO/Pi ( or KA/Pi) on the remote device. | 58 | a running KO/Pi ( or KA/Pi) on the remote device. |
59 | (Note: KO/Pi( or KA/Pi) running on Zaurus with | 59 | (Note: KO/Pi( or KA/Pi) running on Zaurus with |
60 | FastLoad enabled will never be closed!) | 60 | FastLoad enabled will never be closed!) |
61 | After syncing with a running KO/Pi on the remote device, | 61 | After syncing with a running KO/Pi on the remote device, |
62 | a "save" on the remote device will tell you that it needs to merge (sync). | 62 | a "save" on the remote device will tell you that it needs to merge (sync). |
63 | After merging (just a syncing with the changed file) | 63 | After merging (just a syncing with the changed file) |
64 | you will get the new data showing in remote KO/Pi. | 64 | you will get the new data showing in remote KO/Pi. |
65 | 65 | ||
66 | ************************************************************************* | 66 | ************************************************************************* |
67 | 1) Qick overview of settings | 67 | 1) Qick overview of settings |
68 | ************************************************************************* | 68 | ************************************************************************* |
69 | 69 | ||
70 | a) Open sync settings dialog (Menu Synchronize - Configure...) | 70 | a) Open sync settings dialog (Menu Synchronize - Configure...) |
71 | b) Give your device a unique name. | 71 | b) Give your device a unique name. |
72 | (unique in the set of all devices you want to sync with). | 72 | (unique in the set of all devices you want to sync with). |
73 | If you have already configured another devive and created | 73 | If you have already configured another devive and created |
74 | there a sync profile to sync with this device, give your device | 74 | there a sync profile to sync with this device, give your device |
75 | the same name as this sync profile! The same name is important, | 75 | the same name as this sync profile! The same name is important, |
76 | because it makes it possible to sync first A->B | 76 | because it makes it possible to sync first A->B |
77 | (A local device, that performs the sync, B remote device) | 77 | (A local device, that performs the sync, B remote device) |
78 | and then B->A. Such that the B->A sync knows about the | 78 | and then B->A. Such that the B->A sync knows about the |
79 | already performed A->B sync. | 79 | already performed A->B sync. |
80 | That means: It is unimportant if you sync A->B or B->A, | 80 | That means: It is unimportant if you sync A->B or B->A, |
81 | the devices A and B will be synced properly. | 81 | the devices A and B will be synced properly. |
82 | c) Create a new sync profile and give it a unique name. | 82 | c) Create a new sync profile and give it a unique name. |
83 | (unique in the set of all sync profiles on this device). | 83 | (unique in the set of all sync profiles on this device). |
84 | If you want to sync with a device, where KO/Pi is already installed | 84 | If you want to sync with a device, where KO/Pi is already installed |
85 | and which has a given unique device name, use this device name as | 85 | and which has a given unique device name, use this device name as |
86 | your profile name ( refer to b) ). | 86 | your profile name ( refer to b) ). |
87 | d) Coose the profile kind of your syncing method: | 87 | d) Coose the profile kind of your syncing method: |
88 | (i) Local file or | 88 | (i) Local file or |
89 | (ii) Pi-Sync or | 89 | (ii) Pi-Sync or |
90 | (iii) Remote file or | 90 | (iii) Remote file or |
91 | (iiii) Mobile Phone. | 91 | (iiii) Mobile Phone. |
92 | Detailed explanation in 5) | 92 | Detailed explanation in 5) |
93 | e) Choose the other profile options. | 93 | e) Choose the other profile options. |
94 | Detailed explanation in 2) | 94 | Detailed explanation in 2) |
95 | f) Close sync dialog with OK. | 95 | f) Close sync dialog with OK. |
96 | g) Sync. | 96 | g) Sync. |
97 | 97 | ||
98 | NOTE: | 98 | NOTE: |
99 | AFTER SYNCING THERE ARE "SYNC EVENTS" CREATED | 99 | AFTER SYNCING THERE ARE "SYNC EVENTS" CREATED |
100 | (OR UPDATED, IF IT ALREADY EXITS) FOR EACH SYNC PROFILE. | 100 | (OR UPDATED, IF IT ALREADY EXITS) FOR EACH SYNC PROFILE. |
101 | YOU MAY NOT DELETE OR CHANGE THESE EVENTS. | 101 | YOU MAY NOT DELETE OR CHANGE THESE EVENTS. |
102 | 102 | ||
103 | ************************************************************************* | 103 | ************************************************************************* |
104 | 2) Sync settings in sync dialog | 104 | 2) Sync settings in sync dialog |
105 | ************************************************************************* | 105 | ************************************************************************* |
106 | 106 | ||
107 | a) Local device name: | 107 | a) Local device name: |
108 | -> 1) b) | 108 | -> 1) b) |
109 | b) Profile: | 109 | b) Profile: |
110 | -> 1) c) | 110 | -> 1) c) |
111 | c) Include in multiple sync: | 111 | c) Include in multiple sync: |
112 | In the Synchronize menu, there is a multiple sync menu entry. | 112 | In the Synchronize menu, there is a multiple sync menu entry. |
113 | If you choose this menu entry, all user defined profiles with this | 113 | If you choose this menu entry, all user defined profiles with this |
114 | 'Include in multiple sync' option enabled will be synced | 114 | 'Include in multiple sync' option enabled will be synced |
115 | one after another. And this twice. This will take some time. | 115 | one after another. And this twice. This will take some time. |
116 | After that sync, on all devices should be the same data. | 116 | After that sync, on all devices should be the same data. |
117 | d) Ask for preferences before sync: | 117 | d) Ask for preferences before sync: |
118 | Check this to be asked for sync settings before each sync. | 118 | Check this to be asked for sync preferences settings before each sync. |
119 | If the profile kind is "Pi-Sync" you will be asked to confirm | ||
120 | the "Pi-Sync" specific settings (Password,IP address, port number) | ||
121 | as well. That makes it possible to use that profile for a | ||
122 | device that is connected via DHCP to the network and gets different | ||
123 | IP addresses when connection to the network. | ||
119 | e) Sync preferences: | 124 | e) Sync preferences: |
120 | Choose here your sync preferences. | 125 | Choose here your sync preferences. |
121 | Details -> 4) | 126 | Details -> 4) |
122 | f) Show summary after sync: | 127 | f) Show summary after sync: |
123 | Check this to get a small summary dialog after sync | 128 | Check this to get a small summary dialog after sync |
124 | about number of added/changed/deleted events on local/remote. | 129 | about number of added/changed/deleted events on local/remote. |
125 | g) Write back synced data: | 130 | g) Write back synced data: |
126 | Uncheck this to update the local calendar only. | 131 | Uncheck this to update the local calendar only. |
127 | I.e. your local calendar is synced with the remote calendar | 132 | I.e. your local calendar is synced with the remote calendar |
128 | but nothing on the remote calendar is changed. | 133 | but nothing on the remote calendar is changed. |
129 | If you uncheck "Write back synced data", the settings | 134 | If you uncheck "Write back synced data", the settings |
130 | under h) and i) are ignored, of course. | 135 | under h) and i) are ignored, of course. |
131 | h) --Write back (on remote) existing entries only: | 136 | h) --Write back (on remote) existing entries only: |
132 | Check this to update the remote data only. | 137 | Check this to update the remote data only. |
133 | I.e. no data from yor local calendar/addressbook is added to the | 138 | I.e. no data from yor local calendar/addressbook is added to the |
134 | remote device. You may use this option to | 139 | remote device. You may use this option to |
135 | sync against some kind of "public calendar/addressbook" without | 140 | sync against some kind of "public calendar/addressbook" without |
136 | writing back your personal data. | 141 | writing back your personal data. |
137 | i) --Write back (calendar) entries in future only: | 142 | i) --Write back (calendar) entries in future only: |
138 | Check this to write back only calendar entries in future. | 143 | Check this to write back only calendar entries in future. |
139 | (Useful when syncing with mobile phones.) | 144 | (Useful when syncing with mobile phones.) |
140 | You can specify the date range in weeks with | 145 | You can specify the date range in weeks with |
141 | ---- Max. weeks in future. | 146 | ---- Max. weeks in future. |
142 | Note: The date range starts always 7 days before the actual date! | 147 | Note: The date range starts always 7 days before the actual date! |
143 | I.e. the calendar events of the last week are written back always. | 148 | I.e. the calendar events of the last week are written back always. |
144 | j) Profile kind: | 149 | j) Profile kind: |
145 | Details -> 5) | 150 | Details -> 5) |
146 | 151 | ||
147 | ************************************************************************* | 152 | ************************************************************************* |
148 | 3) Syncing background | 153 | 3) Syncing background |
149 | ************************************************************************* | 154 | ************************************************************************* |
150 | 155 | ||
151 | The same mentioned for calendars is valid for addressbooks as well. | 156 | The same mentioned for calendars is valid for addressbooks as well. |
152 | 157 | ||
153 | Synchronizing calendars ( i.e. files ) means, | 158 | Synchronizing calendars ( i.e. files ) means, |
154 | to merge two calendars in a useful way. | 159 | to merge two calendars in a useful way. |
155 | If the two calendars are completely different, | 160 | If the two calendars are completely different, |
156 | there is no problem, the resulting calendar contains | 161 | there is no problem, the resulting calendar contains |
157 | all data from the local and from the remote calendar. | 162 | all data from the local and from the remote calendar. |
158 | 163 | ||
159 | Problems will occur, if you have edited items | 164 | Problems will occur, if you have edited items |
160 | from the local calendar on the remote machine. | 165 | from the local calendar on the remote machine. |
161 | Then it could be, that items are in conflict. | 166 | Then it could be, that items are in conflict. |
162 | Two items are "in conflict", if they have the | 167 | Two items are "in conflict", if they have the |
163 | same unique ID (which get an item at time of | 168 | same unique ID (which get an item at time of |
164 | creation and owns it until it is deleted ) | 169 | creation and owns it until it is deleted ) |
165 | and they both are modified after the last | 170 | and they both are modified after the last |
166 | synchronization. | 171 | synchronization. |
167 | 172 | ||
168 | At first sync of two calendars there is no item deleted. | 173 | At first sync of two calendars there is no item deleted. |
169 | If the calendars are synced before and there is an item, | 174 | If the calendars are synced before and there is an item, |
170 | which is not edited after the last sync and is only | 175 | which is not edited after the last sync and is only |
171 | available in one calendar, then this item is deleted | 176 | available in one calendar, then this item is deleted |
172 | in this calendar. | 177 | in this calendar. |
173 | 178 | ||
174 | But when was the last synchronization between two calendars? | 179 | But when was the last synchronization between two calendars? |
175 | 180 | ||
176 | To know that, KO/Pi creates at first syncing | 181 | To know that, KO/Pi creates at first syncing |
177 | of two files an unique event "<profile name> - sync Event" | 182 | of two files an unique event "<profile name> - sync Event" |
178 | on the remote and the local calendar. | 183 | on the remote and the local calendar. |
179 | After syncing, the start time of this event is set | 184 | After syncing, the start time of this event is set |
180 | to the time of syncing. | 185 | to the time of syncing. |
181 | The event is read only and the user may not change it. | 186 | The event is read only and the user may not change it. |
182 | 187 | ||
183 | If two such files are synced, that both have an event | 188 | If two such files are synced, that both have an event |
184 | "<profile name> - sync Event" and the events have | 189 | "<profile name> - sync Event" and the events have |
185 | the same start time, then deleted items on the one calendar | 190 | the same start time, then deleted items on the one calendar |
186 | are deleted on the other as well. | 191 | are deleted on the other as well. |
187 | 192 | ||
188 | 193 | ||
189 | ************************************************************************* | 194 | ************************************************************************* |
190 | 4) Sync preferences | 195 | 4) Sync preferences |
191 | ************************************************************************* | 196 | ************************************************************************* |
192 | 197 | ||
193 | Two items are "in conflict", if they have the same unique ID | 198 | Two items are "in conflict", if they have the same unique ID |
194 | and they both are modified after the last synchronization. | 199 | and they both are modified after the last synchronization. |
195 | (Details -> 3) ). | 200 | (Details -> 3) ). |
196 | 201 | ||
197 | If an item is not modified after the last sync and | 202 | If an item is not modified after the last sync and |
198 | it is not found in the other calendar, it is deleted. | 203 | it is not found in the other calendar, it is deleted. |
199 | 204 | ||
200 | On the first sync, there is no item deleted. | 205 | On the first sync, there is no item deleted. |
201 | 206 | ||
202 | SYNC PREFERENCES: | 207 | SYNC PREFERENCES: |
203 | -Take local entry on conflict: | 208 | -Take local entry on conflict: |
204 | Takes the local entry on conflict. | 209 | Takes the local entry on conflict. |
205 | If it is the first sync, | 210 | If it is the first sync, |
206 | "Ask for every entry" | 211 | "Ask for every entry" |
207 | is chosen automatically, | 212 | is chosen automatically, |
208 | if this is selected. | 213 | if this is selected. |
209 | 214 | ||
210 | -Take remote entry on conflict: | 215 | -Take remote entry on conflict: |
211 | Takes the remote entry on conflict. | 216 | Takes the remote entry on conflict. |
212 | If it is the first sync, | 217 | If it is the first sync, |
213 | "Ask for every entry" | 218 | "Ask for every entry" |
214 | is chosen automatically, | 219 | is chosen automatically, |
215 | if this is selected. | 220 | if this is selected. |
216 | 221 | ||
217 | -Take newest entry on conflict: | 222 | -Take newest entry on conflict: |
218 | This takes the newest entry on conflict. | 223 | This takes the newest entry on conflict. |
219 | May be the most useful syncing mode. | 224 | May be the most useful syncing mode. |
220 | 225 | ||
221 | -Ask for every entry on conflict: | 226 | -Ask for every entry on conflict: |
222 | Pops up an event viewer dialog and | 227 | Pops up an event viewer dialog and |
223 | shows the two conflicting entries there. | 228 | shows the two conflicting entries there. |
224 | The user can chose, which entry he would like to take. | 229 | The user can chose, which entry he would like to take. |
225 | The button for the newest entry | 230 | The button for the newest entry |
226 | is automatically set as default button. | 231 | is automatically set as default button. |
227 | The color for the newest entry is green. | 232 | The color for the newest entry is green. |
228 | 233 | ||
229 | -Force: Take local entry always: | 234 | -Force: Take local entry always: |
230 | Even if the calendars are already synced | 235 | Even if the calendars are already synced |
231 | there is no item deleted on local. | 236 | there is no item deleted on local. |
232 | 237 | ||
233 | -Force: Take remote entry always: | 238 | -Force: Take remote entry always: |
234 | Analogous to | 239 | Analogous to |
235 | "Force: Take local entry always" | 240 | "Force: Take local entry always" |
236 | 241 | ||
237 | ************************************************************************* | 242 | ************************************************************************* |
238 | 5) Details about sync profile kinds | 243 | 5) Details about sync profile kinds |
239 | ************************************************************************* | 244 | ************************************************************************* |
240 | 245 | ||
241 | a) Local file | 246 | a) Local file |
242 | Please specify a local file you want to sync with. | 247 | Please specify a local file you want to sync with. |
243 | 248 | ||
244 | b) Pi-Sync (direct Kx/Pi to Kx/Pi sync) | 249 | b) Pi-Sync (direct Kx/Pi to Kx/Pi sync) |
245 | We mention here only KO/Pi, but the same is valid for KA/Pi. | 250 | We mention here only KO/Pi, but the same is valid for KA/Pi. |
246 | If you want to sync with a device, where KO/Pi is | 251 | If you want to sync with a device, where KO/Pi is |
247 | installed, you can easily get the remote file via network | 252 | installed, you can easily get the remote file via network |
248 | with the build in file transfer feature "Pi-Sync": | 253 | with the build in file transfer feature "Pi-Sync": |
249 | You have first to enable file transfer on the remote device: | 254 | You have first to enable file transfer on the remote device: |
250 | - Start KO/Pi on the remote device. | 255 | - Start KO/Pi on the remote device. |
251 | - Choose Menu Synchronize-Enable Pi-Sync. | 256 | - Choose Menu Synchronize-Enable Pi-Sync. |
252 | - Choose a port number, where KO/Pi should listen for | 257 | - Choose a port number, where KO/Pi should listen for |
253 | file sending requests. Valid port numbers are numbers | 258 | file sending requests. Valid port numbers are numbers |
254 | between 1 and 65565. Do not specify port numbers, that are | 259 | between 1 and 65565. Do not specify port numbers, that are |
255 | used by other applications. A port number between 9000 and 9999 | 260 | used by other applications. A port number between 9000 and 9999 |
256 | is most likely not used by another application. | 261 | is most likely not used by another application. |
257 | The default port number is 9197 for KO/Pi. | 262 | The default port number is 9197 for KO/Pi. |
258 | If you specify a port number, which is already in use, | 263 | If you specify a port number, which is already in use, |
259 | you will get an error message when closing this dialog. | 264 | you will get an error message when closing this dialog. |
260 | - Choose a password. | 265 | - Choose a password. |
261 | - Click OK. | 266 | - Click OK. |
262 | Now KO/Pi will send the calendar data via the network, | 267 | Now KO/Pi will send the calendar data via the network, |
263 | if some other device is sending a "please send calendar" | 268 | if some other device is sending a "please send calendar" |
264 | request on the given port using the given password. | 269 | request on the given port using the given password. |
265 | If you want to be sure, nobody can access your calendar | 270 | If you want to be sure, nobody can access your calendar |
266 | data, simply disable the file transfer feature on the | 271 | data, simply disable the file transfer feature on the |
267 | remote device after the syncing is done by choosing: | 272 | remote device after the syncing is done by choosing: |
268 | Menu Synchronize-Disable Pi-Sync. | 273 | Menu Synchronize-Disable Pi-Sync. |
269 | 274 | ||
275 | Note: If you want to sync with a remote device that gets different | ||
276 | IPaddresses each time connected to the network | ||
277 | (this may be the case, if you use DHCP for connection | ||
278 | of the remote device to the network) simply enable | ||
279 | "Ask for preferences before sync". | ||
280 | Then you will be asked to confirm the | ||
281 | "Pi-Sync" specific settings | ||
282 | (Password,IP address, port number) | ||
283 | and you can easily change the IP address before each sync. | ||
284 | |||
270 | On your local device, create a new profile and choose | 285 | On your local device, create a new profile and choose |
271 | profile kind "Pi-Sync". | 286 | profile kind "Pi-Sync". |
272 | Fill in the needed values: | 287 | Fill in the needed values: |
273 | - Password for remote access: | 288 | - Password for remote access: |
274 | The password you specified on the remote device. | 289 | The password you specified on the remote device. |
275 | - Remote IP address: | 290 | - Remote IP address: |
276 | The IP address of the remote device. | 291 | The IP address of the remote device. |
277 | - Remote port number: | 292 | - Remote port number: |
278 | The port number you specified on the remote device. | 293 | The port number you specified on the remote device. |
279 | 294 | ||
280 | Now you can syncronize your local device easily with your | 295 | Now you can syncronize your local device easily with your |
281 | remote device. This works well for all platforms KO/Pi is | 296 | remote device. This works well for all platforms KO/Pi is |
282 | running on, e.g. syncing a KO/Pi on Zaurus with KO/Pi on Windows | 297 | running on, e.g. syncing a KO/Pi on Zaurus with KO/Pi on Windows |
283 | is now very easy. | 298 | is now very easy. |
284 | 299 | ||
285 | c) Remote file | 300 | c) Remote file |
286 | Syncing with the profile kind "Remote file" is performed in three steps: | 301 | Syncing with the profile kind "Remote file" is performed in three steps: |
287 | i) download the remote file to your local machine to a temp file | 302 | i) download the remote file to your local machine to a temp file |
288 | ii) sync with this temp file | 303 | ii) sync with this temp file |
289 | iii) upload the synced file to the remote device | 304 | iii) upload the synced file to the remote device |
290 | 305 | ||
291 | The down-/uploading if i) and iii) is done via a command line command. | 306 | The down-/uploading if i) and iii) is done via a command line command. |
292 | Please specify the download/upload command ( like scp, ftp, ...) and the | 307 | Please specify the download/upload command ( like scp, ftp, ...) and the |
293 | file name of the temp file in the corresponding fields. | 308 | file name of the temp file in the corresponding fields. |
294 | 309 | ||
295 | d) Mobile device (cell phone) | 310 | d) Mobile device (cell phone) |
296 | Note: On the Zaurus you have to install the kammu_xxx_arm.ipk package | 311 | Note: On the Zaurus you have to install the kammu_xxx_arm.ipk package |
297 | to be able to access mobile phones. | 312 | to be able to access mobile phones. |
298 | We mention here only KO/Pi, but the same is valid for KA/Pi. | 313 | We mention here only KO/Pi, but the same is valid for KA/Pi. |
299 | Note: | 314 | Note: |
300 | It is only possible to sync a mobile phone with one particular device | 315 | It is only possible to sync a mobile phone with one particular device |
301 | running KO/Pi. If you want to be able to write data of more than one device | 316 | running KO/Pi. If you want to be able to write data of more than one device |
302 | to the mobile phone (e.g. from your Zaurus and from your Windows Laptop) | 317 | to the mobile phone (e.g. from your Zaurus and from your Windows Laptop) |
303 | do not sync with the mobile phone at all, but use the | 318 | do not sync with the mobile phone at all, but use the |
304 | "Export to phone" functionality from the different devices. | 319 | "Export to phone" functionality from the different devices. |
305 | Using "Export to phone" makes it not possible to get back data from the | 320 | Using "Export to phone" makes it not possible to get back data from the |
306 | phone, if it was changed there, of course. | 321 | phone, if it was changed there, of course. |
307 | If you sync with the phone, do not use "Export to phone" from any device. | 322 | If you sync with the phone, do not use "Export to phone" from any device. |
308 | (And do not sync, as mentioned above, from any other device with that phone). | 323 | (And do not sync, as mentioned above, from any other device with that phone). |
309 | It would delete the needed information for syncing with that phone! | 324 | It would delete the needed information for syncing with that phone! |
310 | 325 | ||
311 | We are using Gammu (Version: 0.98.9) ( http://freshmeat.net/projects/gammu/ ) | 326 | We are using Gammu (Version: 0.98.9) ( http://freshmeat.net/projects/gammu/ ) |
312 | for accessing the phones. | 327 | for accessing the phones. |
313 | Note: You cannot use the original Gammu for syncing KDE-Pim/Pi, because | 328 | Note: You cannot use the original Gammu for syncing KDE-Pim/Pi, because |
314 | we have modified the original version to make it useable for syncing! | 329 | we have modified the original version to make it useable for syncing! |
315 | Gammu allows access to many phones in many ways (Irda, Bluetooth, serial,...). | 330 | Gammu allows access to many phones in many ways (Irda, Bluetooth, serial,...). |
316 | The recommended phone access using Gammu with KDE-Pim/Pi is Irda (infrared). | 331 | The recommended phone access using Gammu with KDE-Pim/Pi is Irda (infrared). |
317 | Bluetooth access is disabled on the Zaurus, but may work on Windows. | 332 | Bluetooth access is disabled on the Zaurus, but may work on Windows. |
318 | Please look at the Gammu homepage and documentation about more details | 333 | Please look at the Gammu homepage and documentation about more details |
319 | configuring Gammu how to access your phone. | 334 | configuring Gammu how to access your phone. |
320 | If you have problems accessing your phone, start KO/Pi from the konsole | 335 | If you have problems accessing your phone, start KO/Pi from the konsole |
321 | and you will get a more detailed output what went wrong. | 336 | and you will get a more detailed output what went wrong. |
322 | About Gammu from the Gammu homepage: | 337 | About Gammu from the Gammu homepage: |
323 | Gammu (formerly known as MyGnokii2) is a cellular | 338 | Gammu (formerly known as MyGnokii2) is a cellular |
324 | manager for various mobile phones/modems. | 339 | manager for various mobile phones/modems. |
325 | It supports the Nokia 2100, 3100, 32xx, 33xx, | 340 | It supports the Nokia 2100, 3100, 32xx, 33xx, |
326 | 3410, 35xx, 51xx, 5210, 5510, 61xx, 62xx, | 341 | 3410, 35xx, 51xx, 5210, 5510, 61xx, 62xx, |
327 | 63xx, 6510, 6610, 6800, 71xx, 7210, 7250, | 342 | 63xx, 6510, 6610, 6800, 71xx, 7210, 7250, |
328 | 7250i, 82xx, 83xx, 8910, 9110, 9210 | 343 | 7250i, 82xx, 83xx, 8910, 9110, 9210 |
329 | and compatible and AT devices (Siemens, Alcatel, | 344 | and compatible and AT devices (Siemens, Alcatel, |
330 | Falcom, WaveCom, IPAQ, Samsung, SE, and others) | 345 | Falcom, WaveCom, IPAQ, Samsung, SE, and others) |
331 | over cables/infrared/BlueTooth. | 346 | over cables/infrared/BlueTooth. |
332 | 347 | ||
333 | Here is an example what to specify to access a Nokia 6310i via infrared: | 348 | Here is an example what to specify to access a Nokia 6310i via infrared: |
334 | On Linux (Zaurus): | 349 | On Linux (Zaurus): |
335 | I/O device: /dev/ircomm | 350 | I/O device: /dev/ircomm |
336 | Connection: irda | 351 | Connection: irda |
337 | Model: <leave empty> | 352 | Model: <leave empty> |
338 | 353 | ||
339 | On Windows: | 354 | On Windows: |
340 | I/O device: <ignored - i.e. leave empty> | 355 | I/O device: <ignored - i.e. leave empty> |
341 | Connection: irda | 356 | Connection: irda |
342 | Model: <leave empty> | 357 | Model: <leave empty> |
343 | 358 | ||
344 | Here is the overview from the Gammu documentation, | 359 | Here is the overview from the Gammu documentation, |
345 | how to specify the connection settings for | 360 | how to specify the connection settings for |
346 | I/O device: | 361 | I/O device: |
347 | Connection: | 362 | Connection: |
348 | Model: | 363 | Model: |
349 | 364 | ||
350 | Note: The documentation uses the term "port", | 365 | Note: The documentation uses the term "port", |
351 | where we use the term "I/O device". | 366 | where we use the term "I/O device". |
352 | Note: You do not have to create/change the gammurc configuration file. | 367 | Note: You do not have to create/change the gammurc configuration file. |
353 | That will do KO/Pi for you. | 368 | That will do KO/Pi for you. |
354 | Note: For a known model, leave "Model:" always empty, | 369 | Note: For a known model, leave "Model:" always empty, |
355 | such that Gammu can auto detect the model. | 370 | such that Gammu can auto detect the model. |
356 | 371 | ||
357 | # This is a sample ~/.gammurc file. | 372 | # This is a sample ~/.gammurc file. |
358 | # In Unix/Linux copy it into your home directory and name it .gammurc | 373 | # In Unix/Linux copy it into your home directory and name it .gammurc |
359 | # or into /etc and name it gammurc | 374 | # or into /etc and name it gammurc |
360 | # In Win32 copy it into directory with Gammu.exe and name gammurc | 375 | # In Win32 copy it into directory with Gammu.exe and name gammurc |
361 | # More about parameters later | 376 | # More about parameters later |
362 | # ----------------------------------------------------------------------------- | 377 | # ----------------------------------------------------------------------------- |
363 | 378 | ||
364 | [gammu] | 379 | [gammu] |
365 | 380 | ||
366 | port = com8: | 381 | port = com8: |
367 | #model = 6110 | 382 | #model = 6110 |
368 | connection = fbusblue | 383 | connection = fbusblue |
369 | #synchronizetime = yes | 384 | #synchronizetime = yes |
370 | #logfile = gammulog | 385 | #logfile = gammulog |
371 | #logformat = textall | 386 | #logformat = textall |
372 | #use_locking = yes | 387 | #use_locking = yes |
373 | #gammuloc = locfile | 388 | #gammuloc = locfile |
374 | #startinfo = yes | 389 | #startinfo = yes |
375 | #gammucoding = utf8 | 390 | #gammucoding = utf8 |
376 | 391 | ||
377 | [gammu1] | 392 | [gammu1] |
378 | 393 | ||
379 | port = com8: | 394 | port = com8: |
380 | #model = 6110 | 395 | #model = 6110 |
381 | connection = fbusblue | 396 | connection = fbusblue |
382 | #synchronizetime = yes | 397 | #synchronizetime = yes |
383 | #logfile = gammulog | 398 | #logfile = gammulog |
384 | #logformat = textall | 399 | #logformat = textall |
385 | #use_locking = yes | 400 | #use_locking = yes |
386 | #gammuloc = locfile | 401 | #gammuloc = locfile |
387 | #startinfo = yes | 402 | #startinfo = yes |
388 | #gammucoding = utf8 | 403 | #gammucoding = utf8 |
389 | 404 | ||
390 | # ----------------------------------------------------------------------------- | 405 | # ----------------------------------------------------------------------------- |
391 | # Now info about "Connection" parameter and connected with it port type | 406 | # Now info about "Connection" parameter and connected with it port type |
392 | # (more about port types later) | 407 | # (more about port types later) |
393 | # ----------------------------------------------------------------------------- | 408 | # ----------------------------------------------------------------------------- |
394 | # "Connection" parameter | Port type | More details | 409 | # "Connection" parameter | Port type | More details |
395 | # -----------------------|-----------|----------------------------------------- | 410 | # -----------------------|-----------|----------------------------------------- |
396 | # "fbus" | serial | Nokia FBUS2 | 411 | # "fbus" | serial | Nokia FBUS2 |
397 | # "fbusirda"/"infrared" | serial | Nokia FBUS2 over direct infrared device | 412 | # "fbusirda"/"infrared" | serial | Nokia FBUS2 over direct infrared device |
398 | # "fbusdlr3"/"dlr3" | serial | Nokia FBUS2 with DLR3 cable | 413 | # "fbusdlr3"/"dlr3" | serial | Nokia FBUS2 with DLR3 cable |
399 | # "fbusdku5" | dku5 | Nokia FBUS2 with DKU5 cable. WIN32 ONLY | 414 | # "fbusdku5" | dku5 | Nokia FBUS2 with DKU5 cable. WIN32 ONLY |
400 | # "fbuspl2303" | usb | Nokia FBUS2 with USB cable based on | 415 | # "fbuspl2303" | usb | Nokia FBUS2 with USB cable based on |
401 | # | | PL2303 chip. | 416 | # | | PL2303 chip. |
402 | # "fbusblue" | serial | Nokia FBUS2 over Bluetooth serial device | 417 | # "fbusblue" | serial | Nokia FBUS2 over Bluetooth serial device |
403 | # "phonetblue" | serial | Nokia PHONET FBUS over Bluetooth serial | 418 | # "phonetblue" | serial | Nokia PHONET FBUS over Bluetooth serial |
404 | # | | device | 419 | # | | device |
405 | # "mrouterblue" | serial | | 420 | # "mrouterblue" | serial | |
406 | # "mbus" | serial | Nokia MBUS2 | 421 | # "mbus" | serial | Nokia MBUS2 |
407 | # "at19200"/"at115200"/..| serial | AT commands.8 bits, None parity, 1 stop | 422 | # "at19200"/"at115200"/..| serial | AT commands.8 bits, None parity, 1 stop |
408 | # | | bit, no flow control | 423 | # | | bit, no flow control |
409 | # -----------------------|-----------|----------------------------------------- | 424 | # -----------------------|-----------|----------------------------------------- |
410 | # "irdaphonet"/"irda" | irda | Nokia PHONET FBUS over socket infrared | 425 | # "irdaphonet"/"irda" | irda | Nokia PHONET FBUS over socket infrared |
411 | # "irdaat" | irda | AT commands with socket infrared | 426 | # "irdaat" | irda | AT commands with socket infrared |
412 | # "irdaobex" | irda | OBEX over socket infrared. MODEL "obex" | 427 | # "irdaobex" | irda | OBEX over socket infrared. MODEL "obex" |
413 | # -----------------------|-----------|----------------------------------------- | 428 | # -----------------------|-----------|----------------------------------------- |
414 | # "bluephonet" | BT | Nokia PHONET FBUS with Bluetooth stack | 429 | # "bluephonet" | BT | Nokia PHONET FBUS with Bluetooth stack |
415 | # "bluefbus"/"dlr3blue" | BT | Nokia FBUS2 with Bluetooth stack | 430 | # "bluefbus"/"dlr3blue" | BT | Nokia FBUS2 with Bluetooth stack |
416 | # "blueat"/"atblue" | BT | AT commands with Bluetooth stack | 431 | # "blueat"/"atblue" | BT | AT commands with Bluetooth stack |
417 | # "blueobex" | BT | OBEX with Bluetooth. MODEL "obex" | 432 | # "blueobex" | BT | OBEX with Bluetooth. MODEL "obex" |
418 | # | 433 | # |
419 | # Now more about port types and connected with it "Port" parameter | 434 | # Now more about port types and connected with it "Port" parameter |
420 | # ----------------------------------------------------------------------------- | 435 | # ----------------------------------------------------------------------------- |
421 | # Port type | "Port" parameter in Windows/DOS | "Port" parameter in Linux/Unix | 436 | # Port type | "Port" parameter in Windows/DOS | "Port" parameter in Linux/Unix |
422 | # ----------|---------------------------------|-------------------------------- | 437 | # ----------|---------------------------------|-------------------------------- |
423 | # serial | "com*:" | "/dev/ttyS*" | 438 | # serial | "com*:" | "/dev/ttyS*" |
424 | # | (example "com1:") | (example "/dev/ttyS1") | 439 | # | (example "com1:") | (example "/dev/ttyS1") |
425 | # | | or "/dev/tts/**" (with DevFS) | 440 | # | | or "/dev/tts/**" (with DevFS) |
426 | # ----------|---------------------------------|-------------------------------- | 441 | # ----------|---------------------------------|-------------------------------- |
427 | # irda | ignored (can be empty) | "/dev/ircomm*" | 442 | # irda | ignored (can be empty) | "/dev/ircomm*" |
428 | # ----------|---------------------------------|-------------------------------- | 443 | # ----------|---------------------------------|-------------------------------- |
429 | # BT | Bluetooth device address | 444 | # BT | Bluetooth device address |
430 | # | (example "") | 445 | # | (example "") |
431 | # ----------|---------------------------------|-------------------------------- | 446 | # ----------|---------------------------------|-------------------------------- |
432 | # dku5 | ignored (can be empty) | connection with it not possible | 447 | # dku5 | ignored (can be empty) | connection with it not possible |
433 | # ----------|---------------------------------|-------------------------------- | 448 | # ----------|---------------------------------|-------------------------------- |
434 | # usb | connection with it not possible | "/dev/ttyUSB*" | 449 | # usb | connection with it not possible | "/dev/ttyUSB*" |
435 | # | 450 | # |
436 | # Other config parameters | 451 | # Other config parameters |
437 | # ----------------------------------------------------------------------------- | 452 | # ----------------------------------------------------------------------------- |
438 | # Parameter name | Description | 453 | # Parameter name | Description |
439 | # ----------------|------------------------------------------------------------ | 454 | # ----------------|------------------------------------------------------------ |
440 | # Model | use only, when Gammu doesn't recognize your phone model. | 455 | # Model | use only, when Gammu doesn't recognize your phone model. |
441 | # | Put it here. Example values: "6110", "6150", "6210", "8210" | 456 | # | Put it here. Example values: "6110", "6150", "6210", "8210" |
442 | # SynchronizeTime | if you want to set time from computer to phone during | 457 | # SynchronizeTime | if you want to set time from computer to phone during |
443 | # | starting connection. Do not rather use this option when | 458 | # | starting connection. Do not rather use this option when |
444 | # | when to reset phone during connection (in some phones need | 459 | # | when to reset phone during connection (in some phones need |
445 | # | to set time again after restart) | 460 | # | to set time again after restart) |
446 | # GammuLoc | name of localisation file | 461 | # GammuLoc | name of localisation file |
447 | # StartInfo | this option allow to set, that you want (setting "yes") | 462 | # StartInfo | this option allow to set, that you want (setting "yes") |
448 | # | to see message on the phone screen or phone should enable | 463 | # | to see message on the phone screen or phone should enable |
449 | # | light for a moment during starting connection. Phone | 464 | # | light for a moment during starting connection. Phone |
450 | # | WON'T beep during starting connection with this option. | 465 | # | WON'T beep during starting connection with this option. |
451 | # GammuCoding | forces using specified codepage (in win32 - for example | 466 | # GammuCoding | forces using specified codepage (in win32 - for example |
452 | # | "1250" will force CP1250) or UTF8 (in Linux - "utf8") | 467 | # | "1250" will force CP1250) or UTF8 (in Linux - "utf8") |
453 | # ----------------|------------------------------------------------------------ | 468 | # ----------------|------------------------------------------------------------ |
454 | # Logfile | Use, when want to have logfile from communication. | 469 | # Logfile | Use, when want to have logfile from communication. |
455 | # Logformat | What debug info and format should be used: | 470 | # Logformat | What debug info and format should be used: |
456 | # | "nothing" - no debug level (default) | 471 | # | "nothing" - no debug level (default) |
457 | # | "text" - transmission dump in text format | 472 | # | "text" - transmission dump in text format |
458 | # | "textall" - all possible info in text format | 473 | # | "textall" - all possible info in text format |
459 | # | "errors" - errors in text format | 474 | # | "errors" - errors in text format |
460 | # | "binary" - transmission dump in binary format | 475 | # | "binary" - transmission dump in binary format |
461 | # ----------------|------------------------------------------------------------ | 476 | # ----------------|------------------------------------------------------------ |
462 | # Use_Locking | under Unix/Linux use "yes", if want to lock used device | 477 | # Use_Locking | under Unix/Linux use "yes", if want to lock used device |
463 | # | to prevent using it by other applications. In win32 ignored | 478 | # | to prevent using it by other applications. In win32 ignored |
464 | 479 | ||
465 | 480 | ||
466 | 481 | ||
467 | 482 | ||
468 | \ No newline at end of file | 483 | \ No newline at end of file |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index b3e266a..0faa24d 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -356,821 +356,855 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) | |||
356 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 356 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
357 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 357 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
358 | else | 358 | else |
359 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 359 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
360 | if ( ! quick ) | 360 | if ( ! quick ) |
361 | mPrefs->mLastSyncedLocalFile = fn; | 361 | mPrefs->mLastSyncedLocalFile = fn; |
362 | } | 362 | } |
363 | return ret; | 363 | return ret; |
364 | } | 364 | } |
365 | 365 | ||
366 | void KSyncManager::quickSyncLocalFile() | 366 | void KSyncManager::quickSyncLocalFile() |
367 | { | 367 | { |
368 | 368 | ||
369 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { | 369 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { |
370 | qDebug("quick syncLocalFile() successful "); | 370 | qDebug("quick syncLocalFile() successful "); |
371 | 371 | ||
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | void KSyncManager::multiSync( bool askforPrefs ) | 375 | void KSyncManager::multiSync( bool askforPrefs ) |
376 | { | 376 | { |
377 | if (blockSave()) | 377 | if (blockSave()) |
378 | return; | 378 | return; |
379 | setBlockSave(true); | 379 | setBlockSave(true); |
380 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 380 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
381 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 381 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
382 | question, | 382 | question, |
383 | i18n("Yes"), i18n("No"), | 383 | i18n("Yes"), i18n("No"), |
384 | 0, 0 ) != 0 ) { | 384 | 0, 0 ) != 0 ) { |
385 | setBlockSave(false); | 385 | setBlockSave(false); |
386 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 386 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 389 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
390 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 390 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
391 | if ( askforPrefs ) { | 391 | if ( askforPrefs ) { |
392 | edit_sync_options(); | 392 | edit_sync_options(); |
393 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 393 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
394 | } | 394 | } |
395 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 395 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
396 | qApp->processEvents(); | 396 | qApp->processEvents(); |
397 | int num = ringSync() ; | 397 | int num = ringSync() ; |
398 | if ( num > 1 ) | 398 | if ( num > 1 ) |
399 | ringSync(); | 399 | ringSync(); |
400 | setBlockSave(false); | 400 | setBlockSave(false); |
401 | if ( num ) | 401 | if ( num ) |
402 | emit save(); | 402 | emit save(); |
403 | if ( num ) | 403 | if ( num ) |
404 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 404 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
405 | else | 405 | else |
406 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 406 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | 409 | ||
410 | int KSyncManager::ringSync() | 410 | int KSyncManager::ringSync() |
411 | { | 411 | { |
412 | int syncedProfiles = 0; | 412 | int syncedProfiles = 0; |
413 | unsigned int i; | 413 | unsigned int i; |
414 | QTime timer; | 414 | QTime timer; |
415 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 415 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
416 | QStringList syncProfileNames = mSyncProfileNames; | 416 | QStringList syncProfileNames = mSyncProfileNames; |
417 | KSyncProfile* temp = new KSyncProfile (); | 417 | KSyncProfile* temp = new KSyncProfile (); |
418 | mAskForPreferences = false; | 418 | mAskForPreferences = false; |
419 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 419 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
420 | mCurrentSyncProfile = i; | 420 | mCurrentSyncProfile = i; |
421 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 421 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
422 | temp->readConfig(&config); | 422 | temp->readConfig(&config); |
423 | 423 | ||
424 | QString includeInRingSync; | 424 | QString includeInRingSync; |
425 | switch(mTargetApp) | 425 | switch(mTargetApp) |
426 | { | 426 | { |
427 | case (KAPI): | 427 | case (KAPI): |
428 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 428 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
429 | break; | 429 | break; |
430 | case (KOPI): | 430 | case (KOPI): |
431 | includeInRingSync = temp->getIncludeInRingSync(); | 431 | includeInRingSync = temp->getIncludeInRingSync(); |
432 | break; | 432 | break; |
433 | case (PWMPI): | 433 | case (PWMPI): |
434 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 434 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
435 | break; | 435 | break; |
436 | default: | 436 | default: |
437 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 437 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
438 | break; | 438 | break; |
439 | 439 | ||
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 443 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
444 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 444 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
445 | ++syncedProfiles; | 445 | ++syncedProfiles; |
446 | // mAskForPreferences = temp->getAskForPreferences(); | 446 | // mAskForPreferences = temp->getAskForPreferences(); |
447 | mWriteBackFile = temp->getWriteBackFile(); | 447 | mWriteBackFile = temp->getWriteBackFile(); |
448 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 448 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
449 | mWriteBackInFuture = 0; | 449 | mWriteBackInFuture = 0; |
450 | if ( temp->getWriteBackFuture() ) | 450 | if ( temp->getWriteBackFuture() ) |
451 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 451 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
452 | mShowSyncSummary = false; | 452 | mShowSyncSummary = false; |
453 | mCurrentSyncDevice = syncProfileNames[i] ; | 453 | mCurrentSyncDevice = syncProfileNames[i] ; |
454 | mCurrentSyncName = mLocalMachineName; | 454 | mCurrentSyncName = mLocalMachineName; |
455 | if ( i == 0 ) { | 455 | if ( i == 0 ) { |
456 | syncSharp(); | 456 | syncSharp(); |
457 | } else { | 457 | } else { |
458 | if ( temp->getIsLocalFileSync() ) { | 458 | if ( temp->getIsLocalFileSync() ) { |
459 | switch(mTargetApp) | 459 | switch(mTargetApp) |
460 | { | 460 | { |
461 | case (KAPI): | 461 | case (KAPI): |
462 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 462 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
463 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 463 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
464 | break; | 464 | break; |
465 | case (KOPI): | 465 | case (KOPI): |
466 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 466 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
467 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 467 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
468 | break; | 468 | break; |
469 | case (PWMPI): | 469 | case (PWMPI): |
470 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 470 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
471 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 471 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
472 | break; | 472 | break; |
473 | default: | 473 | default: |
474 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 474 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | } else { | 477 | } else { |
478 | if ( temp->getIsPhoneSync() ) { | 478 | if ( temp->getIsPhoneSync() ) { |
479 | mPhoneDevice = temp->getPhoneDevice( ) ; | 479 | mPhoneDevice = temp->getPhoneDevice( ) ; |
480 | mPhoneConnection = temp->getPhoneConnection( ); | 480 | mPhoneConnection = temp->getPhoneConnection( ); |
481 | mPhoneModel = temp->getPhoneModel( ); | 481 | mPhoneModel = temp->getPhoneModel( ); |
482 | syncPhone(); | 482 | syncPhone(); |
483 | } else if ( temp->getIsPiSync() ) { | 483 | } else if ( temp->getIsPiSync() ) { |
484 | if ( mTargetApp == KAPI ) { | 484 | if ( mTargetApp == KAPI ) { |
485 | mPassWordPiSync = temp->getRemotePwAB(); | 485 | mPassWordPiSync = temp->getRemotePwAB(); |
486 | mActiveSyncPort = temp->getRemotePortAB(); | 486 | mActiveSyncPort = temp->getRemotePortAB(); |
487 | mActiveSyncIP = temp->getRemoteIPAB(); | 487 | mActiveSyncIP = temp->getRemoteIPAB(); |
488 | } else if ( mTargetApp == KOPI ) { | 488 | } else if ( mTargetApp == KOPI ) { |
489 | mPassWordPiSync = temp->getRemotePw(); | 489 | mPassWordPiSync = temp->getRemotePw(); |
490 | mActiveSyncPort = temp->getRemotePort(); | 490 | mActiveSyncPort = temp->getRemotePort(); |
491 | mActiveSyncIP = temp->getRemoteIP(); | 491 | mActiveSyncIP = temp->getRemoteIP(); |
492 | } else { | 492 | } else { |
493 | mPassWordPiSync = temp->getRemotePwPWM(); | 493 | mPassWordPiSync = temp->getRemotePwPWM(); |
494 | mActiveSyncPort = temp->getRemotePortPWM(); | 494 | mActiveSyncPort = temp->getRemotePortPWM(); |
495 | mActiveSyncIP = temp->getRemoteIPPWM(); | 495 | mActiveSyncIP = temp->getRemoteIPPWM(); |
496 | } | 496 | } |
497 | syncPi(); | 497 | syncPi(); |
498 | } else | 498 | } else |
499 | syncRemote( temp, false ); | 499 | syncRemote( temp, false ); |
500 | 500 | ||
501 | } | 501 | } |
502 | } | 502 | } |
503 | timer.start(); | 503 | timer.start(); |
504 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 504 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
505 | while ( timer.elapsed () < 2000 ) { | 505 | while ( timer.elapsed () < 2000 ) { |
506 | qApp->processEvents(); | 506 | qApp->processEvents(); |
507 | #ifndef _WIN32_ | 507 | #ifndef _WIN32_ |
508 | sleep (1); | 508 | sleep (1); |
509 | #endif | 509 | #endif |
510 | } | 510 | } |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | } | 514 | } |
515 | delete temp; | 515 | delete temp; |
516 | return syncedProfiles; | 516 | return syncedProfiles; |
517 | } | 517 | } |
518 | 518 | ||
519 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 519 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
520 | { | 520 | { |
521 | QString question; | 521 | QString question; |
522 | if ( ask ) { | 522 | if ( ask ) { |
523 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 523 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
524 | if ( QMessageBox::information( mParent, i18n("Sync"), | 524 | if ( QMessageBox::information( mParent, i18n("Sync"), |
525 | question, | 525 | question, |
526 | i18n("Yes"), i18n("No"), | 526 | i18n("Yes"), i18n("No"), |
527 | 0, 0 ) != 0 ) | 527 | 0, 0 ) != 0 ) |
528 | return; | 528 | return; |
529 | } | 529 | } |
530 | 530 | ||
531 | QString preCommand; | 531 | QString preCommand; |
532 | QString localTempFile; | 532 | QString localTempFile; |
533 | QString postCommand; | 533 | QString postCommand; |
534 | 534 | ||
535 | switch(mTargetApp) | 535 | switch(mTargetApp) |
536 | { | 536 | { |
537 | case (KAPI): | 537 | case (KAPI): |
538 | preCommand = prof->getPreSyncCommandAB(); | 538 | preCommand = prof->getPreSyncCommandAB(); |
539 | postCommand = prof->getPostSyncCommandAB(); | 539 | postCommand = prof->getPostSyncCommandAB(); |
540 | localTempFile = prof->getLocalTempFileAB(); | 540 | localTempFile = prof->getLocalTempFileAB(); |
541 | break; | 541 | break; |
542 | case (KOPI): | 542 | case (KOPI): |
543 | preCommand = prof->getPreSyncCommand(); | 543 | preCommand = prof->getPreSyncCommand(); |
544 | postCommand = prof->getPostSyncCommand(); | 544 | postCommand = prof->getPostSyncCommand(); |
545 | localTempFile = prof->getLocalTempFile(); | 545 | localTempFile = prof->getLocalTempFile(); |
546 | break; | 546 | break; |
547 | case (PWMPI): | 547 | case (PWMPI): |
548 | preCommand = prof->getPreSyncCommandPWM(); | 548 | preCommand = prof->getPreSyncCommandPWM(); |
549 | postCommand = prof->getPostSyncCommandPWM(); | 549 | postCommand = prof->getPostSyncCommandPWM(); |
550 | localTempFile = prof->getLocalTempFilePWM(); | 550 | localTempFile = prof->getLocalTempFilePWM(); |
551 | break; | 551 | break; |
552 | default: | 552 | default: |
553 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 553 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
554 | break; | 554 | break; |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | int fi; | 558 | int fi; |
559 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 559 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
560 | QString pwd = getPassword(); | 560 | QString pwd = getPassword(); |
561 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 561 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
562 | 562 | ||
563 | } | 563 | } |
564 | int maxlen = 30; | 564 | int maxlen = 30; |
565 | if ( QApplication::desktop()->width() > 320 ) | 565 | if ( QApplication::desktop()->width() > 320 ) |
566 | maxlen += 25; | 566 | maxlen += 25; |
567 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 567 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
568 | int fileSize = 0; | 568 | int fileSize = 0; |
569 | int result = system ( preCommand ); | 569 | int result = system ( preCommand ); |
570 | // 0 : okay | 570 | // 0 : okay |
571 | // 256: no such file or dir | 571 | // 256: no such file or dir |
572 | // | 572 | // |
573 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 573 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
574 | if ( result != 0 ) { | 574 | if ( result != 0 ) { |
575 | unsigned int len = maxlen; | 575 | unsigned int len = maxlen; |
576 | while ( len < preCommand.length() ) { | 576 | while ( len < preCommand.length() ) { |
577 | preCommand.insert( len , "\n" ); | 577 | preCommand.insert( len , "\n" ); |
578 | len += maxlen +2; | 578 | len += maxlen +2; |
579 | } | 579 | } |
580 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 580 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
581 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 581 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
582 | question, | 582 | question, |
583 | i18n("Okay!")) ; | 583 | i18n("Okay!")) ; |
584 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 584 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
585 | return; | 585 | return; |
586 | } | 586 | } |
587 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 587 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
588 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 588 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
589 | 589 | ||
590 | if ( syncWithFile( localTempFile, true ) ) { | 590 | if ( syncWithFile( localTempFile, true ) ) { |
591 | 591 | ||
592 | if ( mWriteBackFile ) { | 592 | if ( mWriteBackFile ) { |
593 | int fi; | 593 | int fi; |
594 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 594 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
595 | QString pwd = getPassword(); | 595 | QString pwd = getPassword(); |
596 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 596 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
597 | 597 | ||
598 | } | 598 | } |
599 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 599 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
600 | result = system ( postCommand ); | 600 | result = system ( postCommand ); |
601 | qDebug("Writing back file result: %d ", result); | 601 | qDebug("Writing back file result: %d ", result); |
602 | if ( result != 0 ) { | 602 | if ( result != 0 ) { |
603 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 603 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
604 | return; | 604 | return; |
605 | } else { | 605 | } else { |
606 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 606 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
607 | } | 607 | } |
608 | } | 608 | } |
609 | } | 609 | } |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | 612 | void KSyncManager::edit_pisync_options() | |
613 | { | ||
614 | QDialog dia( mParent, "dia", true ); | ||
615 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | ||
616 | QVBoxLayout lay ( &dia ); | ||
617 | lay.setSpacing( 5 ); | ||
618 | lay.setMargin( 3 ); | ||
619 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | ||
620 | lay.addWidget( &lab1 ); | ||
621 | QLineEdit le1 (&dia ); | ||
622 | lay.addWidget( &le1 ); | ||
623 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | ||
624 | lay.addWidget( &lab2 ); | ||
625 | QLineEdit le2 (&dia ); | ||
626 | lay.addWidget( &le2 ); | ||
627 | QLabel lab3 ( i18n("Remote port number:"), &dia); | ||
628 | lay.addWidget( &lab3 ); | ||
629 | QLineEdit le3 (&dia ); | ||
630 | lay.addWidget( &le3 ); | ||
631 | QPushButton pb ( "OK", &dia); | ||
632 | lay.addWidget( &pb ); | ||
633 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
634 | le1.setText( mPassWordPiSync ); | ||
635 | le2.setText( mActiveSyncIP ); | ||
636 | le3.setText( mActiveSyncPort ); | ||
637 | if ( dia.exec() ) { | ||
638 | mPassWordPiSync = le1.text(); | ||
639 | mActiveSyncPort = le3.text(); | ||
640 | mActiveSyncIP = le2.text(); | ||
641 | } | ||
642 | |||
643 | } | ||
613 | void KSyncManager::edit_sync_options() | 644 | void KSyncManager::edit_sync_options() |
614 | { | 645 | { |
615 | //mDialogManager->showSyncOptions(); | 646 | |
616 | //mSyncAlgoPrefs | ||
617 | QDialog dia( mParent, "dia", true ); | 647 | QDialog dia( mParent, "dia", true ); |
618 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 648 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
619 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 649 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
620 | QVBoxLayout lay ( &dia ); | 650 | QVBoxLayout lay ( &dia ); |
621 | lay.setSpacing( 2 ); | 651 | lay.setSpacing( 2 ); |
622 | lay.setMargin( 3 ); | 652 | lay.setMargin( 3 ); |
623 | lay.addWidget(&gr); | 653 | lay.addWidget(&gr); |
624 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 654 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
625 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 655 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
626 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 656 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
627 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 657 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
628 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 658 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
629 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 659 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
630 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 660 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
631 | QPushButton pb ( "OK", &dia); | 661 | QPushButton pb ( "OK", &dia); |
632 | lay.addWidget( &pb ); | 662 | lay.addWidget( &pb ); |
633 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 663 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
634 | switch ( mSyncAlgoPrefs ) { | 664 | switch ( mSyncAlgoPrefs ) { |
635 | case 0: | 665 | case 0: |
636 | loc.setChecked( true); | 666 | loc.setChecked( true); |
637 | break; | 667 | break; |
638 | case 1: | 668 | case 1: |
639 | rem.setChecked( true ); | 669 | rem.setChecked( true ); |
640 | break; | 670 | break; |
641 | case 2: | 671 | case 2: |
642 | newest.setChecked( true); | 672 | newest.setChecked( true); |
643 | break; | 673 | break; |
644 | case 3: | 674 | case 3: |
645 | ask.setChecked( true); | 675 | ask.setChecked( true); |
646 | break; | 676 | break; |
647 | case 4: | 677 | case 4: |
648 | f_loc.setChecked( true); | 678 | f_loc.setChecked( true); |
649 | break; | 679 | break; |
650 | case 5: | 680 | case 5: |
651 | f_rem.setChecked( true); | 681 | f_rem.setChecked( true); |
652 | break; | 682 | break; |
653 | case 6: | 683 | case 6: |
654 | // both.setChecked( true); | 684 | // both.setChecked( true); |
655 | break; | 685 | break; |
656 | default: | 686 | default: |
657 | break; | 687 | break; |
658 | } | 688 | } |
659 | if ( dia.exec() ) { | 689 | if ( dia.exec() ) { |
660 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 690 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
661 | } | 691 | } |
662 | 692 | ||
663 | 693 | ||
664 | } | 694 | } |
665 | 695 | ||
666 | QString KSyncManager::getPassword( ) | 696 | QString KSyncManager::getPassword( ) |
667 | { | 697 | { |
668 | QString retfile = ""; | 698 | QString retfile = ""; |
669 | QDialog dia ( mParent, "input-dialog", true ); | 699 | QDialog dia ( mParent, "input-dialog", true ); |
670 | QLineEdit lab ( &dia ); | 700 | QLineEdit lab ( &dia ); |
671 | lab.setEchoMode( QLineEdit::Password ); | 701 | lab.setEchoMode( QLineEdit::Password ); |
672 | QVBoxLayout lay( &dia ); | 702 | QVBoxLayout lay( &dia ); |
673 | lay.setMargin(7); | 703 | lay.setMargin(7); |
674 | lay.setSpacing(7); | 704 | lay.setSpacing(7); |
675 | lay.addWidget( &lab); | 705 | lay.addWidget( &lab); |
676 | dia.setFixedSize( 230,50 ); | 706 | dia.setFixedSize( 230,50 ); |
677 | dia.setCaption( i18n("Enter password") ); | 707 | dia.setCaption( i18n("Enter password") ); |
678 | QPushButton pb ( "OK", &dia); | 708 | QPushButton pb ( "OK", &dia); |
679 | lay.addWidget( &pb ); | 709 | lay.addWidget( &pb ); |
680 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 710 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
681 | dia.show(); | 711 | dia.show(); |
682 | int res = dia.exec(); | 712 | int res = dia.exec(); |
683 | if ( res ) | 713 | if ( res ) |
684 | retfile = lab.text(); | 714 | retfile = lab.text(); |
685 | dia.hide(); | 715 | dia.hide(); |
686 | qApp->processEvents(); | 716 | qApp->processEvents(); |
687 | return retfile; | 717 | return retfile; |
688 | 718 | ||
689 | } | 719 | } |
690 | 720 | ||
691 | 721 | ||
692 | void KSyncManager::confSync() | 722 | void KSyncManager::confSync() |
693 | { | 723 | { |
694 | static KSyncPrefsDialog* sp = 0; | 724 | static KSyncPrefsDialog* sp = 0; |
695 | if ( ! sp ) { | 725 | if ( ! sp ) { |
696 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 726 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
697 | } | 727 | } |
698 | sp->usrReadConfig(); | 728 | sp->usrReadConfig(); |
699 | #ifndef DESKTOP_VERSION | 729 | #ifndef DESKTOP_VERSION |
700 | sp->showMaximized(); | 730 | sp->showMaximized(); |
701 | #else | 731 | #else |
702 | sp->show(); | 732 | sp->show(); |
703 | #endif | 733 | #endif |
704 | sp->exec(); | 734 | sp->exec(); |
705 | mSyncProfileNames = sp->getSyncProfileNames(); | 735 | mSyncProfileNames = sp->getSyncProfileNames(); |
706 | mLocalMachineName = sp->getLocalMachineName (); | 736 | mLocalMachineName = sp->getLocalMachineName (); |
707 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 737 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
708 | } | 738 | } |
709 | 739 | ||
710 | void KSyncManager::syncSharp() | 740 | void KSyncManager::syncSharp() |
711 | { | 741 | { |
712 | 742 | ||
713 | if ( ! syncExternalApplication("sharp") ) | 743 | if ( ! syncExternalApplication("sharp") ) |
714 | qDebug("ERROR sync sharp ");; | 744 | qDebug("ERROR sync sharp ");; |
715 | } | 745 | } |
716 | 746 | ||
717 | bool KSyncManager::syncExternalApplication(QString resource) | 747 | bool KSyncManager::syncExternalApplication(QString resource) |
718 | { | 748 | { |
719 | 749 | ||
720 | emit save(); | 750 | emit save(); |
721 | 751 | ||
722 | if ( mAskForPreferences ) | 752 | if ( mAskForPreferences ) |
723 | edit_sync_options(); | 753 | edit_sync_options(); |
724 | 754 | ||
725 | qDebug("sync %s", resource.latin1()); | 755 | qDebug("sync %s", resource.latin1()); |
726 | 756 | ||
727 | bool syncOK = mImplementation->syncExternal(this, resource); | 757 | bool syncOK = mImplementation->syncExternal(this, resource); |
728 | 758 | ||
729 | return syncOK; | 759 | return syncOK; |
730 | 760 | ||
731 | } | 761 | } |
732 | 762 | ||
733 | void KSyncManager::syncPhone() | 763 | void KSyncManager::syncPhone() |
734 | { | 764 | { |
735 | 765 | ||
736 | syncExternalApplication("phone"); | 766 | syncExternalApplication("phone"); |
737 | 767 | ||
738 | } | 768 | } |
739 | 769 | ||
740 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 770 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
741 | { | 771 | { |
742 | if (!bar->isVisible()) | 772 | if (!bar->isVisible()) |
743 | { | 773 | { |
744 | bar->setCaption (caption); | 774 | bar->setCaption (caption); |
745 | bar->setTotalSteps ( total ) ; | 775 | bar->setTotalSteps ( total ) ; |
746 | 776 | ||
747 | bar->show(); | 777 | bar->show(); |
748 | } | 778 | } |
749 | 779 | ||
750 | bar->setProgress( percentage ); | 780 | bar->setProgress( percentage ); |
751 | } | 781 | } |
752 | 782 | ||
753 | void KSyncManager::hideProgressBar() | 783 | void KSyncManager::hideProgressBar() |
754 | { | 784 | { |
755 | bar->hide(); | 785 | bar->hide(); |
756 | } | 786 | } |
757 | 787 | ||
758 | bool KSyncManager::isProgressBarCanceled() | 788 | bool KSyncManager::isProgressBarCanceled() |
759 | { | 789 | { |
760 | return !bar->isVisible(); | 790 | return !bar->isVisible(); |
761 | } | 791 | } |
762 | 792 | ||
763 | QString KSyncManager::syncFileName() | 793 | QString KSyncManager::syncFileName() |
764 | { | 794 | { |
765 | 795 | ||
766 | QString fn = "tempfile"; | 796 | QString fn = "tempfile"; |
767 | switch(mTargetApp) | 797 | switch(mTargetApp) |
768 | { | 798 | { |
769 | case (KAPI): | 799 | case (KAPI): |
770 | fn = "tempsyncab.vcf"; | 800 | fn = "tempsyncab.vcf"; |
771 | break; | 801 | break; |
772 | case (KOPI): | 802 | case (KOPI): |
773 | fn = "tempsynccal.ics"; | 803 | fn = "tempsynccal.ics"; |
774 | break; | 804 | break; |
775 | case (PWMPI): | 805 | case (PWMPI): |
776 | fn = "tempsyncpw.pwm"; | 806 | fn = "tempsyncpw.pwm"; |
777 | break; | 807 | break; |
778 | default: | 808 | default: |
779 | break; | 809 | break; |
780 | } | 810 | } |
781 | #ifdef _WIN32_ | 811 | #ifdef _WIN32_ |
782 | return locateLocal( "tmp", fn ); | 812 | return locateLocal( "tmp", fn ); |
783 | #else | 813 | #else |
784 | return (QString( "/tmp/" )+ fn ); | 814 | return (QString( "/tmp/" )+ fn ); |
785 | #endif | 815 | #endif |
786 | } | 816 | } |
787 | 817 | ||
788 | |||
789 | void KSyncManager::syncPi() | 818 | void KSyncManager::syncPi() |
790 | { | 819 | { |
791 | qApp->processEvents(); | 820 | qApp->processEvents(); |
821 | if ( mAskForPreferences ) | ||
822 | edit_pisync_options(); | ||
792 | bool ok; | 823 | bool ok; |
793 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 824 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
794 | if ( ! ok ) { | 825 | if ( ! ok ) { |
795 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 826 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
796 | return; | 827 | return; |
797 | } | 828 | } |
798 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 829 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
799 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 830 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
800 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 831 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
801 | commandSocket->readFile( syncFileName() ); | 832 | commandSocket->readFile( syncFileName() ); |
802 | } | 833 | } |
803 | 834 | ||
804 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 835 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
805 | { | 836 | { |
806 | qDebug("MainWindow::deleteCommandSocket %d", state); | 837 | qDebug("MainWindow::deleteCommandSocket %d", state); |
807 | 838 | ||
808 | //enum { success, errorW, errorR, quiet }; | 839 | //enum { success, errorW, errorR, quiet }; |
809 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 840 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
810 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 841 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
811 | delete s; | 842 | delete s; |
812 | if ( state == KCommandSocket::errorR ) { | 843 | if ( state == KCommandSocket::errorR ) { |
813 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 844 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
814 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 845 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
815 | commandSocket->sendStop(); | 846 | commandSocket->sendStop(); |
816 | } | 847 | } |
817 | return; | 848 | return; |
818 | 849 | ||
819 | } else if ( state == KCommandSocket::errorW ) { | 850 | } else if ( state == KCommandSocket::errorW ) { |
820 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 851 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
821 | 852 | ||
822 | } else if ( state == KCommandSocket::successR ) { | 853 | } else if ( state == KCommandSocket::successR ) { |
823 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 854 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
824 | 855 | ||
825 | } else if ( state == KCommandSocket::successW ) { | 856 | } else if ( state == KCommandSocket::successW ) { |
826 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 857 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
827 | } | 858 | } |
828 | 859 | ||
829 | delete s; | 860 | delete s; |
830 | } | 861 | } |
831 | 862 | ||
832 | void KSyncManager::readFileFromSocket() | 863 | void KSyncManager::readFileFromSocket() |
833 | { | 864 | { |
834 | QString fileName = syncFileName(); | 865 | QString fileName = syncFileName(); |
835 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 866 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
836 | if ( ! syncWithFile( fileName , true ) ) { | 867 | if ( ! syncWithFile( fileName , true ) ) { |
837 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 868 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
838 | qDebug("Syncing failed "); | 869 | qDebug("Syncing failed "); |
839 | return; | 870 | return; |
840 | } | 871 | } |
841 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 872 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
842 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 873 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
843 | if ( mWriteBackFile ) | 874 | if ( mWriteBackFile ) |
844 | commandSocket->writeFile( fileName ); | 875 | commandSocket->writeFile( fileName ); |
845 | else { | 876 | else { |
846 | commandSocket->sendStop(); | 877 | commandSocket->sendStop(); |
847 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 878 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
848 | } | 879 | } |
849 | } | 880 | } |
850 | 881 | ||
851 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 882 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
852 | { | 883 | { |
853 | mPassWord = pw; | 884 | mPassWord = pw; |
854 | mSocket = 0; | 885 | mSocket = 0; |
855 | mSyncActionDialog = 0; | 886 | mSyncActionDialog = 0; |
856 | blockRC = false; | 887 | blockRC = false; |
857 | }; | 888 | }; |
858 | 889 | ||
859 | void KServerSocket::newConnection ( int socket ) | 890 | void KServerSocket::newConnection ( int socket ) |
860 | { | 891 | { |
861 | // qDebug("KServerSocket:New connection %d ", socket); | 892 | // qDebug("KServerSocket:New connection %d ", socket); |
862 | if ( mSocket ) { | 893 | if ( mSocket ) { |
863 | qDebug("KServerSocket::newConnection Socket deleted! "); | 894 | qDebug("KServerSocket::newConnection Socket deleted! "); |
864 | delete mSocket; | 895 | delete mSocket; |
865 | mSocket = 0; | 896 | mSocket = 0; |
866 | } | 897 | } |
867 | mSocket = new QSocket( this ); | 898 | mSocket = new QSocket( this ); |
868 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 899 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
869 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 900 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
870 | mSocket->setSocket( socket ); | 901 | mSocket->setSocket( socket ); |
871 | } | 902 | } |
872 | 903 | ||
873 | void KServerSocket::discardClient() | 904 | void KServerSocket::discardClient() |
874 | { | 905 | { |
875 | //qDebug(" KServerSocket::discardClient()"); | 906 | //qDebug(" KServerSocket::discardClient()"); |
876 | if ( mSocket ) { | 907 | if ( mSocket ) { |
877 | delete mSocket; | 908 | delete mSocket; |
878 | mSocket = 0; | 909 | mSocket = 0; |
879 | } | 910 | } |
880 | //emit endConnect(); | 911 | //emit endConnect(); |
881 | } | 912 | } |
882 | void KServerSocket::readClient() | 913 | void KServerSocket::readClient() |
883 | { | 914 | { |
884 | if ( blockRC ) | 915 | if ( blockRC ) |
885 | return; | 916 | return; |
886 | if ( mSocket == 0 ) { | 917 | if ( mSocket == 0 ) { |
887 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 918 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
888 | return; | 919 | return; |
889 | } | 920 | } |
890 | qDebug("KServerSocket readClient()"); | 921 | qDebug("KServerSocket readClient()"); |
891 | if ( mSocket->canReadLine() ) { | 922 | if ( mSocket->canReadLine() ) { |
892 | QString line = mSocket->readLine(); | 923 | QString line = mSocket->readLine(); |
893 | qDebug("KServerSocket readline: %s ", line.latin1()); | 924 | qDebug("KServerSocket readline: %s ", line.latin1()); |
894 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 925 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
895 | if ( tokens[0] == "GET" ) { | 926 | if ( tokens[0] == "GET" ) { |
896 | if ( tokens[1] == mPassWord ) | 927 | if ( tokens[1] == mPassWord ) |
897 | //emit sendFile( mSocket ); | 928 | //emit sendFile( mSocket ); |
898 | send_file(); | 929 | send_file(); |
899 | else { | 930 | else { |
900 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 931 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
901 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 932 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
902 | } | 933 | } |
903 | } | 934 | } |
904 | if ( tokens[0] == "PUT" ) { | 935 | if ( tokens[0] == "PUT" ) { |
905 | if ( tokens[1] == mPassWord ) { | 936 | if ( tokens[1] == mPassWord ) { |
906 | //emit getFile( mSocket ); | 937 | //emit getFile( mSocket ); |
907 | blockRC = true; | 938 | blockRC = true; |
908 | get_file(); | 939 | get_file(); |
909 | } | 940 | } |
910 | else { | 941 | else { |
911 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 942 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
912 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 943 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
913 | } | 944 | } |
914 | } | 945 | } |
915 | if ( tokens[0] == "STOP" ) { | 946 | if ( tokens[0] == "STOP" ) { |
916 | //emit endConnect(); | 947 | //emit endConnect(); |
917 | end_connect(); | 948 | end_connect(); |
918 | } | 949 | } |
919 | } | 950 | } |
920 | } | 951 | } |
921 | void KServerSocket::end_connect() | 952 | void KServerSocket::end_connect() |
922 | { | 953 | { |
923 | delete mSyncActionDialog; | 954 | delete mSyncActionDialog; |
924 | mSyncActionDialog = 0; | 955 | mSyncActionDialog = 0; |
925 | } | 956 | } |
926 | void KServerSocket::send_file() | 957 | void KServerSocket::send_file() |
927 | { | 958 | { |
928 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 959 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
929 | if ( mSyncActionDialog ) | 960 | if ( mSyncActionDialog ) |
930 | delete mSyncActionDialog; | 961 | delete mSyncActionDialog; |
931 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 962 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
932 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 963 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
933 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 964 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
934 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 965 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
935 | lay->addWidget( label); | 966 | lay->addWidget( label); |
936 | lay->setMargin(7); | 967 | lay->setMargin(7); |
937 | lay->setSpacing(7); | 968 | lay->setSpacing(7); |
938 | mSyncActionDialog->setFixedSize( 230, 120); | 969 | mSyncActionDialog->setFixedSize( 230, 120); |
939 | mSyncActionDialog->show(); | 970 | mSyncActionDialog->show(); |
940 | mSyncActionDialog->raise(); | 971 | mSyncActionDialog->raise(); |
941 | qDebug("KSS::saving ... "); | 972 | qDebug("KSS::saving ... "); |
942 | emit request_file(); | 973 | emit request_file(); |
943 | qApp->processEvents(); | 974 | qApp->processEvents(); |
944 | QString fileName = mFileName; | 975 | QString fileName = mFileName; |
945 | QFile file( fileName ); | 976 | QFile file( fileName ); |
946 | if (!file.open( IO_ReadOnly ) ) { | 977 | if (!file.open( IO_ReadOnly ) ) { |
947 | delete mSyncActionDialog; | 978 | delete mSyncActionDialog; |
948 | mSyncActionDialog = 0; | 979 | mSyncActionDialog = 0; |
949 | qDebug("KSS::error open file "); | 980 | qDebug("KSS::error open file "); |
950 | mSocket->close(); | 981 | mSocket->close(); |
951 | if ( mSocket->state() == QSocket::Idle ) | 982 | if ( mSocket->state() == QSocket::Idle ) |
952 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 983 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
953 | return ; | 984 | return ; |
954 | 985 | ||
955 | } | 986 | } |
956 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 987 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
957 | QTextStream ts( &file ); | 988 | QTextStream ts( &file ); |
958 | ts.setEncoding( QTextStream::Latin1 ); | 989 | ts.setEncoding( QTextStream::Latin1 ); |
959 | 990 | ||
960 | QTextStream os( mSocket ); | 991 | QTextStream os( mSocket ); |
961 | os.setEncoding( QTextStream::Latin1 ); | 992 | os.setEncoding( QTextStream::Latin1 ); |
962 | while ( ! ts.atEnd() ) { | 993 | while ( ! ts.atEnd() ) { |
963 | os << ts.readLine() << "\n"; | 994 | os << ts.readLine() << "\n"; |
964 | } | 995 | } |
965 | //os << ts.read(); | 996 | //os << ts.read(); |
966 | file.close(); | 997 | file.close(); |
967 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 998 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
968 | mSocket->close(); | 999 | mSocket->close(); |
969 | if ( mSocket->state() == QSocket::Idle ) | 1000 | if ( mSocket->state() == QSocket::Idle ) |
970 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1001 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
971 | } | 1002 | } |
972 | void KServerSocket::get_file() | 1003 | void KServerSocket::get_file() |
973 | { | 1004 | { |
974 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1005 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
975 | 1006 | ||
976 | piTime.start(); | 1007 | piTime.start(); |
977 | piFileString = ""; | 1008 | piFileString = ""; |
978 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1009 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
979 | } | 1010 | } |
980 | 1011 | ||
981 | 1012 | ||
982 | void KServerSocket::readBackFileFromSocket() | 1013 | void KServerSocket::readBackFileFromSocket() |
983 | { | 1014 | { |
984 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1015 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
985 | while ( mSocket->canReadLine () ) { | 1016 | while ( mSocket->canReadLine () ) { |
986 | piTime.restart(); | 1017 | piTime.restart(); |
987 | QString line = mSocket->readLine (); | 1018 | QString line = mSocket->readLine (); |
988 | piFileString += line; | 1019 | piFileString += line; |
989 | //qDebug("readline: %s ", line.latin1()); | 1020 | //qDebug("readline: %s ", line.latin1()); |
990 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1021 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
991 | 1022 | ||
992 | } | 1023 | } |
993 | if ( piTime.elapsed () < 3000 ) { | 1024 | if ( piTime.elapsed () < 3000 ) { |
994 | // wait for more | 1025 | // wait for more |
995 | //qDebug("waitformore "); | 1026 | //qDebug("waitformore "); |
996 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1027 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
997 | return; | 1028 | return; |
998 | } | 1029 | } |
999 | QString fileName = mFileName; | 1030 | QString fileName = mFileName; |
1000 | QFile file ( fileName ); | 1031 | QFile file ( fileName ); |
1001 | if (!file.open( IO_WriteOnly ) ) { | 1032 | if (!file.open( IO_WriteOnly ) ) { |
1002 | delete mSyncActionDialog; | 1033 | delete mSyncActionDialog; |
1003 | mSyncActionDialog = 0; | 1034 | mSyncActionDialog = 0; |
1004 | qDebug("error open cal file "); | 1035 | qDebug("error open cal file "); |
1005 | piFileString = ""; | 1036 | piFileString = ""; |
1006 | emit file_received( false ); | 1037 | emit file_received( false ); |
1007 | blockRC = false; | 1038 | blockRC = false; |
1008 | return ; | 1039 | return ; |
1009 | 1040 | ||
1010 | } | 1041 | } |
1011 | 1042 | ||
1012 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1043 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1013 | QTextStream ts ( &file ); | 1044 | QTextStream ts ( &file ); |
1014 | ts.setEncoding( QTextStream::Latin1 ); | 1045 | ts.setEncoding( QTextStream::Latin1 ); |
1015 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1046 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1016 | ts << piFileString; | 1047 | ts << piFileString; |
1017 | mSocket->close(); | 1048 | mSocket->close(); |
1018 | if ( mSocket->state() == QSocket::Idle ) | 1049 | if ( mSocket->state() == QSocket::Idle ) |
1019 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1050 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1020 | file.close(); | 1051 | file.close(); |
1021 | delete mSyncActionDialog; | 1052 | delete mSyncActionDialog; |
1022 | mSyncActionDialog = 0; | 1053 | mSyncActionDialog = 0; |
1023 | piFileString = ""; | 1054 | piFileString = ""; |
1024 | blockRC = false; | 1055 | blockRC = false; |
1025 | emit file_received( true ); | 1056 | emit file_received( true ); |
1026 | 1057 | ||
1027 | } | 1058 | } |
1028 | 1059 | ||
1029 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1060 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1030 | { | 1061 | { |
1031 | mPassWord = password; | 1062 | mPassWord = password; |
1032 | mSocket = 0; | 1063 | mSocket = 0; |
1033 | mPort = port; | 1064 | mPort = port; |
1034 | mHost = host; | 1065 | mHost = host; |
1035 | 1066 | ||
1036 | mRetVal = quiet; | 1067 | mRetVal = quiet; |
1037 | mTimerSocket = new QTimer ( this ); | 1068 | mTimerSocket = new QTimer ( this ); |
1038 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1069 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1039 | } | 1070 | } |
1040 | void KCommandSocket::readFile( QString fn ) | 1071 | void KCommandSocket::readFile( QString fn ) |
1041 | { | 1072 | { |
1042 | if ( !mSocket ) { | 1073 | if ( !mSocket ) { |
1043 | mSocket = new QSocket( this ); | 1074 | mSocket = new QSocket( this ); |
1044 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1075 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1045 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1076 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1046 | } | 1077 | } |
1047 | mFileString = ""; | 1078 | mFileString = ""; |
1048 | mFileName = fn; | 1079 | mFileName = fn; |
1049 | mFirst = true; | 1080 | mFirst = true; |
1050 | mSocket->connectToHost( mHost, mPort ); | 1081 | mSocket->connectToHost( mHost, mPort ); |
1051 | QTextStream os( mSocket ); | 1082 | QTextStream os( mSocket ); |
1052 | os.setEncoding( QTextStream::Latin1 ); | 1083 | os.setEncoding( QTextStream::Latin1 ); |
1053 | os << "GET " << mPassWord << "\r\n"; | 1084 | os << "GET " << mPassWord << "\r\n"; |
1054 | mTimerSocket->start( 10000 ); | 1085 | mTimerSocket->start( 10000 ); |
1055 | } | 1086 | } |
1056 | 1087 | ||
1057 | void KCommandSocket::writeFile( QString fileName ) | 1088 | void KCommandSocket::writeFile( QString fileName ) |
1058 | { | 1089 | { |
1059 | if ( !mSocket ) { | 1090 | if ( !mSocket ) { |
1060 | mSocket = new QSocket( this ); | 1091 | mSocket = new QSocket( this ); |
1061 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1092 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1062 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1093 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1063 | } | 1094 | } |
1064 | mFileName = fileName ; | 1095 | mFileName = fileName ; |
1065 | mSocket->connectToHost( mHost, mPort ); | 1096 | mSocket->connectToHost( mHost, mPort ); |
1066 | } | 1097 | } |
1067 | void KCommandSocket::writeFileToSocket() | 1098 | void KCommandSocket::writeFileToSocket() |
1068 | { | 1099 | { |
1069 | QFile file2( mFileName ); | 1100 | QFile file2( mFileName ); |
1070 | if (!file2.open( IO_ReadOnly ) ) { | 1101 | if (!file2.open( IO_ReadOnly ) ) { |
1071 | mRetVal= errorW; | 1102 | mRetVal= errorW; |
1072 | mSocket->close(); | 1103 | mSocket->close(); |
1073 | if ( mSocket->state() == QSocket::Idle ) | 1104 | if ( mSocket->state() == QSocket::Idle ) |
1074 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1105 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1075 | return ; | 1106 | return ; |
1076 | } | 1107 | } |
1077 | QTextStream ts2( &file2 ); | 1108 | QTextStream ts2( &file2 ); |
1078 | ts2.setEncoding( QTextStream::Latin1 ); | 1109 | ts2.setEncoding( QTextStream::Latin1 ); |
1079 | QTextStream os2( mSocket ); | 1110 | QTextStream os2( mSocket ); |
1080 | os2.setEncoding( QTextStream::Latin1 ); | 1111 | os2.setEncoding( QTextStream::Latin1 ); |
1081 | os2 << "PUT " << mPassWord << "\r\n";; | 1112 | os2 << "PUT " << mPassWord << "\r\n";; |
1082 | while ( ! ts2.atEnd() ) { | 1113 | while ( ! ts2.atEnd() ) { |
1083 | os2 << ts2.readLine() << "\n"; | 1114 | os2 << ts2.readLine() << "\n"; |
1084 | } | 1115 | } |
1085 | mRetVal= successW; | 1116 | mRetVal= successW; |
1086 | file2.close(); | 1117 | file2.close(); |
1087 | mSocket->close(); | 1118 | mSocket->close(); |
1088 | if ( mSocket->state() == QSocket::Idle ) | 1119 | if ( mSocket->state() == QSocket::Idle ) |
1089 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1120 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1090 | } | 1121 | } |
1091 | void KCommandSocket::sendStop() | 1122 | void KCommandSocket::sendStop() |
1092 | { | 1123 | { |
1093 | if ( !mSocket ) { | 1124 | if ( !mSocket ) { |
1094 | mSocket = new QSocket( this ); | 1125 | mSocket = new QSocket( this ); |
1095 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1126 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1096 | } | 1127 | } |
1097 | mSocket->connectToHost( mHost, mPort ); | 1128 | mSocket->connectToHost( mHost, mPort ); |
1098 | QTextStream os2( mSocket ); | 1129 | QTextStream os2( mSocket ); |
1099 | os2.setEncoding( QTextStream::Latin1 ); | 1130 | os2.setEncoding( QTextStream::Latin1 ); |
1100 | os2 << "STOP\r\n"; | 1131 | os2 << "STOP\r\n"; |
1101 | mSocket->close(); | 1132 | mSocket->close(); |
1102 | if ( mSocket->state() == QSocket::Idle ) | 1133 | if ( mSocket->state() == QSocket::Idle ) |
1103 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1134 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1104 | } | 1135 | } |
1105 | 1136 | ||
1106 | void KCommandSocket::startReadFileFromSocket() | 1137 | void KCommandSocket::startReadFileFromSocket() |
1107 | { | 1138 | { |
1108 | if ( ! mFirst ) | 1139 | if ( ! mFirst ) |
1109 | return; | 1140 | return; |
1110 | mFirst = false; | 1141 | mFirst = false; |
1111 | mTimerSocket->stop(); | 1142 | mTimerSocket->stop(); |
1112 | mFileString = ""; | 1143 | mFileString = ""; |
1113 | mTime.start(); | 1144 | mTime.start(); |
1114 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1145 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1115 | 1146 | ||
1116 | } | 1147 | } |
1117 | void KCommandSocket::readFileFromSocket() | 1148 | void KCommandSocket::readFileFromSocket() |
1118 | { | 1149 | { |
1119 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1150 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1120 | while ( mSocket->canReadLine () ) { | 1151 | while ( mSocket->canReadLine () ) { |
1121 | mTime.restart(); | 1152 | mTime.restart(); |
1122 | QString line = mSocket->readLine (); | 1153 | QString line = mSocket->readLine (); |
1123 | mFileString += line; | 1154 | mFileString += line; |
1124 | //qDebug("readline: %s ", line.latin1()); | 1155 | //qDebug("readline: %s ", line.latin1()); |
1125 | } | 1156 | } |
1126 | if ( mTime.elapsed () < 3000 ) { | 1157 | if ( mTime.elapsed () < 3000 ) { |
1127 | // wait for more | 1158 | // wait for more |
1128 | //qDebug("waitformore "); | 1159 | //qDebug("waitformore "); |
1129 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1160 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1130 | return; | 1161 | return; |
1131 | } | 1162 | } |
1132 | QString fileName = mFileName; | 1163 | QString fileName = mFileName; |
1133 | QFile file ( fileName ); | 1164 | QFile file ( fileName ); |
1134 | if (!file.open( IO_WriteOnly ) ) { | 1165 | if (!file.open( IO_WriteOnly ) ) { |
1135 | mFileString = ""; | 1166 | mFileString = ""; |
1136 | mRetVal = errorR; | 1167 | mRetVal = errorR; |
1137 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 1168 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
1138 | deleteSocket(); | 1169 | deleteSocket(); |
1139 | return ; | 1170 | return ; |
1140 | 1171 | ||
1141 | } | 1172 | } |
1142 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1173 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1143 | QTextStream ts ( &file ); | 1174 | QTextStream ts ( &file ); |
1144 | ts.setEncoding( QTextStream::Latin1 ); | 1175 | ts.setEncoding( QTextStream::Latin1 ); |
1145 | ts << mFileString; | 1176 | ts << mFileString; |
1146 | file.close(); | 1177 | file.close(); |
1147 | mFileString = ""; | 1178 | mFileString = ""; |
1148 | mRetVal = successR; | 1179 | mRetVal = successR; |
1149 | mSocket->close(); | 1180 | mSocket->close(); |
1150 | // if state is not idle, deleteSocket(); is called via | 1181 | // if state is not idle, deleteSocket(); is called via |
1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1182 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1152 | if ( mSocket->state() == QSocket::Idle ) | 1183 | if ( mSocket->state() == QSocket::Idle ) |
1153 | deleteSocket(); | 1184 | deleteSocket(); |
1154 | } | 1185 | } |
1155 | 1186 | ||
1156 | void KCommandSocket::deleteSocket() | 1187 | void KCommandSocket::deleteSocket() |
1157 | { | 1188 | { |
1189 | //qDebug("KCommandSocket::deleteSocket() "); | ||
1158 | if ( mTimerSocket->isActive () ) { | 1190 | if ( mTimerSocket->isActive () ) { |
1159 | mTimerSocket->stop(); | 1191 | mTimerSocket->stop(); |
1160 | mRetVal = errorTO; | 1192 | mRetVal = errorTO; |
1193 | qDebug("Connection to remote host timed out"); | ||
1161 | if ( mSocket ) { | 1194 | if ( mSocket ) { |
1162 | mSocket->close(); | 1195 | mSocket->close(); |
1163 | if ( mSocket->state() == QSocket::Idle ) | 1196 | //if ( mSocket->state() == QSocket::Idle ) |
1164 | deleteSocket(); | 1197 | // deleteSocket(); |
1165 | return; | 1198 | delete mSocket; |
1199 | mSocket = 0; | ||
1166 | } | 1200 | } |
1201 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1202 | emit commandFinished( this, mRetVal ); | ||
1203 | return; | ||
1167 | } | 1204 | } |
1168 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1205 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1169 | if ( mSocket) | 1206 | if ( mSocket) |
1170 | delete mSocket; | 1207 | delete mSocket; |
1171 | mSocket = 0; | 1208 | mSocket = 0; |
1172 | if ( mRetVal == errorTO) | ||
1173 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1174 | |||
1175 | emit commandFinished( this, mRetVal ); | 1209 | emit commandFinished( this, mRetVal ); |
1176 | } | 1210 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 1f7c7e7..5b05383 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,207 +1,208 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | 32 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class KServerSocket : public QServerSocket |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
48 | 48 | ||
49 | void newConnection ( int socket ) ; | 49 | void newConnection ( int socket ) ; |
50 | void setFileName( QString fn ) {mFileName = fn;}; | 50 | void setFileName( QString fn ) {mFileName = fn;}; |
51 | signals: | 51 | signals: |
52 | void file_received( bool ); | 52 | void file_received( bool ); |
53 | void request_file(); | 53 | void request_file(); |
54 | void saveFile(); | 54 | void saveFile(); |
55 | void endConnect(); | 55 | void endConnect(); |
56 | private slots: | 56 | private slots: |
57 | void discardClient(); | 57 | void discardClient(); |
58 | void readClient(); | 58 | void readClient(); |
59 | void readBackFileFromSocket(); | 59 | void readBackFileFromSocket(); |
60 | private : | 60 | private : |
61 | bool blockRC; | 61 | bool blockRC; |
62 | void send_file(); | 62 | void send_file(); |
63 | void get_file(); | 63 | void get_file(); |
64 | void end_connect(); | 64 | void end_connect(); |
65 | QDialog* mSyncActionDialog; | 65 | QDialog* mSyncActionDialog; |
66 | QSocket* mSocket; | 66 | QSocket* mSocket; |
67 | QString mPassWord; | 67 | QString mPassWord; |
68 | QString mFileName; | 68 | QString mFileName; |
69 | QTime piTime; | 69 | QTime piTime; |
70 | QString piFileString; | 70 | QString piFileString; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | class KCommandSocket : public QObject | 73 | class KCommandSocket : public QObject |
74 | { | 74 | { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
79 | void readFile( QString ); | 79 | void readFile( QString ); |
80 | void writeFile( QString ); | 80 | void writeFile( QString ); |
81 | void sendStop(); | 81 | void sendStop(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void commandFinished( KCommandSocket*, int ); | 84 | void commandFinished( KCommandSocket*, int ); |
85 | private slots: | 85 | private slots: |
86 | void startReadFileFromSocket(); | 86 | void startReadFileFromSocket(); |
87 | void readFileFromSocket(); | 87 | void readFileFromSocket(); |
88 | void deleteSocket(); | 88 | void deleteSocket(); |
89 | void writeFileToSocket(); | 89 | void writeFileToSocket(); |
90 | private : | 90 | private : |
91 | QSocket* mSocket; | 91 | QSocket* mSocket; |
92 | QString mPassWord; | 92 | QString mPassWord; |
93 | Q_UINT16 mPort; | 93 | Q_UINT16 mPort; |
94 | QString mHost; | 94 | QString mHost; |
95 | QString mFileName; | 95 | QString mFileName; |
96 | QTimer* mTimerSocket; | 96 | QTimer* mTimerSocket; |
97 | int mRetVal; | 97 | int mRetVal; |
98 | QTime mTime; | 98 | QTime mTime; |
99 | QString mFileString; | 99 | QString mFileString; |
100 | bool mFirst; | 100 | bool mFirst; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | class KSyncManager : public QObject | 104 | class KSyncManager : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | enum TargetApp { | 109 | enum TargetApp { |
110 | KOPI = 0, | 110 | KOPI = 0, |
111 | KAPI = 1, | 111 | KAPI = 1, |
112 | PWMPI = 2 }; | 112 | PWMPI = 2 }; |
113 | 113 | ||
114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
115 | ~KSyncManager() ; | 115 | ~KSyncManager() ; |
116 | 116 | ||
117 | void multiSync( bool askforPrefs ); | 117 | void multiSync( bool askforPrefs ); |
118 | bool blockSave() { return mBlockSaveFlag; } | 118 | bool blockSave() { return mBlockSaveFlag; } |
119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
120 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 120 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
121 | QString defaultFileName() { return mDefFileName ;} | 121 | QString defaultFileName() { return mDefFileName ;} |
122 | QString syncFileName(); | 122 | QString syncFileName(); |
123 | 123 | ||
124 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 124 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
125 | QString getCurrentSyncName() { return mCurrentSyncName; } | 125 | QString getCurrentSyncName() { return mCurrentSyncName; } |
126 | 126 | ||
127 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 127 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
128 | void hideProgressBar(); | 128 | void hideProgressBar(); |
129 | bool isProgressBarCanceled(); | 129 | bool isProgressBarCanceled(); |
130 | 130 | ||
131 | // sync stuff | 131 | // sync stuff |
132 | QString mLocalMachineName; | 132 | QString mLocalMachineName; |
133 | QStringList mExternSyncProfiles; | 133 | QStringList mExternSyncProfiles; |
134 | QStringList mSyncProfileNames; | 134 | QStringList mSyncProfileNames; |
135 | bool mAskForPreferences; | 135 | bool mAskForPreferences; |
136 | bool mShowSyncSummary; | 136 | bool mShowSyncSummary; |
137 | bool mWriteBackExistingOnly; | 137 | bool mWriteBackExistingOnly; |
138 | int mSyncAlgoPrefs; | 138 | int mSyncAlgoPrefs; |
139 | bool mWriteBackFile; | 139 | bool mWriteBackFile; |
140 | int mWriteBackInFuture; | 140 | int mWriteBackInFuture; |
141 | QString mPhoneDevice; | 141 | QString mPhoneDevice; |
142 | QString mPhoneConnection; | 142 | QString mPhoneConnection; |
143 | QString mPhoneModel; | 143 | QString mPhoneModel; |
144 | QString mPassWordPiSync; | 144 | QString mPassWordPiSync; |
145 | QString mActiveSyncPort; | 145 | QString mActiveSyncPort; |
146 | QString mActiveSyncIP ; | 146 | QString mActiveSyncIP ; |
147 | 147 | ||
148 | signals: | 148 | signals: |
149 | void save(); | 149 | void save(); |
150 | void request_file(); | 150 | void request_file(); |
151 | void getFile( bool ); | 151 | void getFile( bool ); |
152 | 152 | ||
153 | public slots: | 153 | public slots: |
154 | void slotSyncMenu( int ); | 154 | void slotSyncMenu( int ); |
155 | void deleteCommandSocket(KCommandSocket*s, int state); | 155 | void deleteCommandSocket(KCommandSocket*s, int state); |
156 | void readFileFromSocket(); | 156 | void readFileFromSocket(); |
157 | void fillSyncMenu(); | 157 | void fillSyncMenu(); |
158 | 158 | ||
159 | private: | 159 | private: |
160 | void syncPi(); | 160 | void syncPi(); |
161 | KServerSocket * mServerSocket; | 161 | KServerSocket * mServerSocket; |
162 | void enableQuick(); | 162 | void enableQuick(); |
163 | KPimPrefs* mPrefs; | 163 | KPimPrefs* mPrefs; |
164 | QString mDefFileName; | 164 | QString mDefFileName; |
165 | QString mCurrentSyncDevice; | 165 | QString mCurrentSyncDevice; |
166 | QString mCurrentSyncName; | 166 | QString mCurrentSyncName; |
167 | void quickSyncLocalFile(); | 167 | void quickSyncLocalFile(); |
168 | bool syncWithFile( QString fn , bool quick ); | 168 | bool syncWithFile( QString fn , bool quick ); |
169 | void syncLocalFile(); | 169 | void syncLocalFile(); |
170 | void syncPhone(); | 170 | void syncPhone(); |
171 | void syncSharp(); | 171 | void syncSharp(); |
172 | bool syncExternalApplication(QString); | 172 | bool syncExternalApplication(QString); |
173 | int mCurrentSyncProfile ; | 173 | int mCurrentSyncProfile ; |
174 | void syncRemote( KSyncProfile* prof, bool ask = true); | 174 | void syncRemote( KSyncProfile* prof, bool ask = true); |
175 | void edit_sync_options(); | 175 | void edit_sync_options(); |
176 | void edit_pisync_options(); | ||
176 | int ringSync(); | 177 | int ringSync(); |
177 | QString getPassword( ); | 178 | QString getPassword( ); |
178 | 179 | ||
179 | private slots: | 180 | private slots: |
180 | void confSync(); | 181 | void confSync(); |
181 | private: | 182 | private: |
182 | bool mBlockSaveFlag; | 183 | bool mBlockSaveFlag; |
183 | QWidget* mParent; | 184 | QWidget* mParent; |
184 | KSyncInterface* mImplementation; | 185 | KSyncInterface* mImplementation; |
185 | TargetApp mTargetApp; | 186 | TargetApp mTargetApp; |
186 | QPopupMenu* mSyncMenu; | 187 | QPopupMenu* mSyncMenu; |
187 | QProgressBar* bar; | 188 | QProgressBar* bar; |
188 | 189 | ||
189 | }; | 190 | }; |
190 | 191 | ||
191 | 192 | ||
192 | class KSyncInterface | 193 | class KSyncInterface |
193 | { | 194 | { |
194 | public : | 195 | public : |
195 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 196 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
196 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 197 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
197 | { | 198 | { |
198 | // empty implementation, because some syncable applications do not | 199 | // empty implementation, because some syncable applications do not |
199 | // have an external(sharpdtm) syncmode, like pwmanager. | 200 | // have an external(sharpdtm) syncmode, like pwmanager. |
200 | return false; | 201 | return false; |
201 | } | 202 | } |
202 | 203 | ||
203 | 204 | ||
204 | }; | 205 | }; |
205 | 206 | ||
206 | 207 | ||
207 | #endif | 208 | #endif |