-rw-r--r-- | bin/kdepim/WhatsNew.txt | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 8264410..fd29b51 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,298 +1,301 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.1.18 ************ | 3 | ********** VERSION 2.1.18 ************ |
4 | 4 | ||
5 | Pi-Sync mode: | ||
6 | The "Write back file" status dialog was updated too often such that writing back the file on the Z was very slow. Fixed. | ||
7 | |||
5 | KO/Pi: | 8 | KO/Pi: |
6 | 9 | ||
7 | 10 | ||
8 | ********** VERSION 2.1.17 ************ | 11 | ********** VERSION 2.1.17 ************ |
9 | 12 | ||
10 | KO/Pi: | 13 | KO/Pi: |
11 | Added option to display times in What's Next View on two lines. | 14 | Added option to display times in What's Next View on two lines. |
12 | (Useful for display on the Zaurus with 240x320 screen) | 15 | (Useful for display on the Zaurus with 240x320 screen) |
13 | Removed "Allday" for allday events of one day duration in What's Next View. | 16 | Removed "Allday" for allday events of one day duration in What's Next View. |
14 | Added date range for allday events of more than one day duration in What's Next View. | 17 | Added date range for allday events of more than one day duration in What's Next View. |
15 | Fixed two problems in the data importing from Outlook: | 18 | Fixed two problems in the data importing from Outlook: |
16 | Fixed the duplicated import if the summary, location or description had whitespaces at the end. | 19 | Fixed the duplicated import if the summary, location or description had whitespaces at the end. |
17 | Fixed a problem importing certain recurrence rules. | 20 | Fixed a problem importing certain recurrence rules. |
18 | 21 | ||
19 | A journal in an ics file may have no dtStart value (as files from KNotes, which stores its notes in an ics journal file). | 22 | A journal in an ics file may have no dtStart value (as files from KNotes, which stores its notes in an ics journal file). |
20 | If now a journal has no dtStart value the dtStart value is set to the created value of the journal when loading the file. That makes it possible to view and edit "notes" from KNotes. Simply add another Resource in KO/Pi which is a copy of the ics file from KNotes. You will find the "notes" in KO/Pi as a journal entry on the date you created it. | 23 | If now a journal has no dtStart value the dtStart value is set to the created value of the journal when loading the file. That makes it possible to view and edit "notes" from KNotes. Simply add another Resource in KO/Pi which is a copy of the ics file from KNotes. You will find the "notes" in KO/Pi as a journal entry on the date you created it. |
21 | 24 | ||
22 | And some minor fixes in KO/Pi. | 25 | And some minor fixes in KO/Pi. |
23 | 26 | ||
24 | Fixed a crash on the desktop when closing KO/Pi after accessing adressbook data (Linux + Windows ). | 27 | Fixed a crash on the desktop when closing KO/Pi after accessing adressbook data (Linux + Windows ). |
25 | 28 | ||
26 | 29 | ||
27 | ********** VERSION 2.1.16 ************ | 30 | ********** VERSION 2.1.16 ************ |
28 | 31 | ||
29 | Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. | 32 | Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. |
30 | Added columns for datetime in todo view: Last modified, created and last modified subtodo | 33 | Added columns for datetime in todo view: Last modified, created and last modified subtodo |
31 | Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. | 34 | Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. |
32 | Made conflict detection up to 4 times faster. | 35 | Made conflict detection up to 4 times faster. |
33 | 36 | ||
34 | ********** VERSION 2.1.15 ************ | 37 | ********** VERSION 2.1.15 ************ |
35 | 38 | ||
36 | Fixed two layout problems on the Z: | 39 | Fixed two layout problems on the Z: |
37 | Made the with of the newly added buttons on the Quick-Todo smaller. | 40 | Made the with of the newly added buttons on the Quick-Todo smaller. |
38 | Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. | 41 | Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. |
39 | 42 | ||
40 | 43 | ||
41 | ********** VERSION 2.1.14 ************ | 44 | ********** VERSION 2.1.14 ************ |
42 | 45 | ||
43 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. | 46 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. |
44 | Added a button to add a subtodo quickly. | 47 | Added a button to add a subtodo quickly. |
45 | 48 | ||
46 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). | 49 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). |
47 | Added an option to change the layout of the list week to column mode. | 50 | Added an option to change the layout of the list week to column mode. |
48 | 51 | ||
49 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. | 52 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. |
50 | 53 | ||
51 | Fixed pi-sync problems with the new multi calendar feature. | 54 | Fixed pi-sync problems with the new multi calendar feature. |
52 | Now pi-sync behaviour should be: | 55 | Now pi-sync behaviour should be: |
53 | 1) Local sends file request ( as usual ) | 56 | 1) Local sends file request ( as usual ) |
54 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. | 57 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. |
55 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). | 58 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). |
56 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. | 59 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. |
57 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. | 60 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. |
58 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. | 61 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. |
59 | 62 | ||
60 | Summary: | 63 | Summary: |
61 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. | 64 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. |
62 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. | 65 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. |
63 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. | 66 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. |
64 | 67 | ||
65 | ********** VERSION 2.1.13 ************ | 68 | ********** VERSION 2.1.13 ************ |
66 | 69 | ||
67 | Fixed a problem in KA/Pi search. | 70 | Fixed a problem in KA/Pi search. |
68 | Fixed some minor problems in KO/Pi. | 71 | Fixed some minor problems in KO/Pi. |
69 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. | 72 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. |
70 | 73 | ||
71 | Fixed memory usage problems in KA/Pi: | 74 | Fixed memory usage problems in KA/Pi: |
72 | When loading data KA/Pi did load the file data twice. | 75 | When loading data KA/Pi did load the file data twice. |
73 | Example: | 76 | Example: |
74 | A 600k file did consume 1200k memory during loading process. | 77 | A 600k file did consume 1200k memory during loading process. |
75 | This is fixed, it does now consume only 600k during loading process. | 78 | This is fixed, it does now consume only 600k during loading process. |
76 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. | 79 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. |
77 | This is fixed. | 80 | This is fixed. |
78 | Example: | 81 | Example: |
79 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. | 82 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. |
80 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. | 83 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. |
81 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. | 84 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. |
82 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. | 85 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. |
83 | The saving of data may be a bit slower now. | 86 | The saving of data may be a bit slower now. |
84 | 87 | ||
85 | Fixed memory usage problems in KO/Pi: | 88 | Fixed memory usage problems in KO/Pi: |
86 | When KO/Pi did save the data to file, it did not release the used buffers after saving. | 89 | When KO/Pi did save the data to file, it did not release the used buffers after saving. |
87 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. | 90 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. |
88 | This is fixed. | 91 | This is fixed. |
89 | Example: | 92 | Example: |
90 | When saving a 400k file KO/Pi do now use 400k less memory now. | 93 | When saving a 400k file KO/Pi do now use 400k less memory now. |
91 | 94 | ||
92 | Optimized memory usage in KO/Pi Agenda view: | 95 | Optimized memory usage in KO/Pi Agenda view: |
93 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. | 96 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. |
94 | These buffers were not made smaller (i.e. downsized) because of performance reasons. | 97 | These buffers were not made smaller (i.e. downsized) because of performance reasons. |
95 | The handling of these buffers are now much smarter: | 98 | The handling of these buffers are now much smarter: |
96 | Two (of six) buffers are removed completely. | 99 | Two (of six) buffers are removed completely. |
97 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. | 100 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. |
98 | Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi. | 101 | Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi. |
99 | 102 | ||
100 | Worst case example ( for a maximum size agenda content): | 103 | Worst case example ( for a maximum size agenda content): |
101 | When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem. | 104 | When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem. |
102 | 105 | ||
103 | When switching to an unused Agenda view now KO/Pi is upizing the buffers again. This takes less than a second. Such that switching to Agenda view (after not using it for more than 45 seconds) is now a bit slower. | 106 | When switching to an unused Agenda view now KO/Pi is upizing the buffers again. This takes less than a second. Such that switching to Agenda view (after not using it for more than 45 seconds) is now a bit slower. |
104 | 107 | ||
105 | Summary: | 108 | Summary: |
106 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. | 109 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. |
107 | 110 | ||
108 | ********** VERSION 2.1.12 ************ | 111 | ********** VERSION 2.1.12 ************ |
109 | 112 | ||
110 | KO/Pi: | 113 | KO/Pi: |
111 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. | 114 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. |
112 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. | 115 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. |
113 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). | 116 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). |
114 | Fixed some other small problems. | 117 | Fixed some other small problems. |
115 | 118 | ||
116 | ********** VERSION 2.1.11 ************ | 119 | ********** VERSION 2.1.11 ************ |
117 | 120 | ||
118 | KO/Pi: | 121 | KO/Pi: |
119 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. | 122 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. |
120 | Added features to handle (and add ) more than one journal entry per day. | 123 | Added features to handle (and add ) more than one journal entry per day. |
121 | Added option for a journal title. | 124 | Added option for a journal title. |
122 | 125 | ||
123 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. | 126 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. |
124 | Fixed a problem of the alarm of completed recurring todos. | 127 | Fixed a problem of the alarm of completed recurring todos. |
125 | Added to the event/todo editor to set quickly the category of an item. | 128 | Added to the event/todo editor to set quickly the category of an item. |
126 | 129 | ||
127 | 130 | ||
128 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. | 131 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. |
129 | 132 | ||
130 | Added KA/Pi multi sync to the multi sync called from the alarm applet. | 133 | Added KA/Pi multi sync to the multi sync called from the alarm applet. |
131 | 134 | ||
132 | ********** VERSION 2.1.10 ************ | 135 | ********** VERSION 2.1.10 ************ |
133 | 136 | ||
134 | KO/Pi: | 137 | KO/Pi: |
135 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. | 138 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. |
136 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. | 139 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. |
137 | Fixed a bug in searching for a small timerange, i.e. one day. | 140 | Fixed a bug in searching for a small timerange, i.e. one day. |
138 | 141 | ||
139 | KA/Pi: | 142 | KA/Pi: |
140 | Fixed two problems in csv export. | 143 | Fixed two problems in csv export. |
141 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. | 144 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. |
142 | 145 | ||
143 | ********** VERSION 2.1.9 ************ | 146 | ********** VERSION 2.1.9 ************ |
144 | 147 | ||
145 | KO/Pi: | 148 | KO/Pi: |
146 | Fixed some problems of the new search options in the search dialog. | 149 | Fixed some problems of the new search options in the search dialog. |
147 | Fixed some problems in the new resource config options. | 150 | Fixed some problems in the new resource config options. |
148 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. | 151 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. |
149 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: | 152 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: |
150 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. | 153 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. |
151 | 154 | ||
152 | Fixed a problem in recurrence range in syncing with DTM. | 155 | Fixed a problem in recurrence range in syncing with DTM. |
153 | 156 | ||
154 | KA/Pi: | 157 | KA/Pi: |
155 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) | 158 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) |
156 | 159 | ||
157 | PwM/Pi: | 160 | PwM/Pi: |
158 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. | 161 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. |
159 | 162 | ||
160 | ********** VERSION 2.1.8 ************ | 163 | ********** VERSION 2.1.8 ************ |
161 | 164 | ||
162 | KO/Pi: | 165 | KO/Pi: |
163 | Added info about the completion state of a todo in the ListView/Searchdialog. | 166 | Added info about the completion state of a todo in the ListView/Searchdialog. |
164 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. | 167 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. |
165 | Fixed some updating problems when changing the filter. | 168 | Fixed some updating problems when changing the filter. |
166 | 169 | ||
167 | KA/Pi: | 170 | KA/Pi: |
168 | In the addressee selection dialog now the formatted name is shown, if not empty. | 171 | In the addressee selection dialog now the formatted name is shown, if not empty. |
169 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. | 172 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. |
170 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. | 173 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. |
171 | 174 | ||
172 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. | 175 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. |
173 | Fixed the sorting for size in the file selector on the Z. | 176 | Fixed the sorting for size in the file selector on the Z. |
174 | 177 | ||
175 | Changed the color selection dialog on the Zaurus to a more user friendly version. | 178 | Changed the color selection dialog on the Zaurus to a more user friendly version. |
176 | 179 | ||
177 | ********** VERSION 2.1.7 ************ | 180 | ********** VERSION 2.1.7 ************ |
178 | 181 | ||
179 | KO/Pi: | 182 | KO/Pi: |
180 | Fixed several problems in the new Resource handling. | 183 | Fixed several problems in the new Resource handling. |
181 | Added more options to the search dialog. | 184 | Added more options to the search dialog. |
182 | Fixed a problem in the Month view. | 185 | Fixed a problem in the Month view. |
183 | Added more options to the dialog when setting a todo to stopped. | 186 | Added more options to the dialog when setting a todo to stopped. |
184 | 187 | ||
185 | Fixed two small problems in KO/Pi Alarm applet. | 188 | Fixed two small problems in KO/Pi Alarm applet. |
186 | 189 | ||
187 | ********** VERSION 2.1.6 ************ | 190 | ********** VERSION 2.1.6 ************ |
188 | 191 | ||
189 | This release is for testing only. | 192 | This release is for testing only. |
190 | 193 | ||
191 | KO/Pi: | 194 | KO/Pi: |
192 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 195 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
193 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 196 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
194 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 197 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
195 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 198 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
196 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | 199 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. |
197 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | 200 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. |
198 | 201 | ||
199 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. | 202 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. |
200 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. | 203 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. |
201 | Now on every sync the set of calendars is synced which are enabled in the resource view. | 204 | Now on every sync the set of calendars is synced which are enabled in the resource view. |
202 | 205 | ||
203 | A calendar is enabled in the resource view if the "eye" column is checked. | 206 | A calendar is enabled in the resource view if the "eye" column is checked. |
204 | You can set a calendar to be the default for new items( "+" column ). | 207 | You can set a calendar to be the default for new items( "+" column ). |
205 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. | 208 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. |
206 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... | 209 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... |
207 | 210 | ||
208 | 211 | ||
209 | ********** VERSION 2.1.5 ************ | 212 | ********** VERSION 2.1.5 ************ |
210 | 213 | ||
211 | This is the new stable version. | 214 | This is the new stable version. |
212 | Bugfix: | 215 | Bugfix: |
213 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 216 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
214 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 217 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
215 | Added config option to not display completed todos in agenda view. | 218 | Added config option to not display completed todos in agenda view. |
216 | Addressee view is now using the formatted name, if defined. | 219 | Addressee view is now using the formatted name, if defined. |
217 | That makes it possible to display "lastname, firstname" in that view now. | 220 | That makes it possible to display "lastname, firstname" in that view now. |
218 | To set the formatted name for all contacts, please use menu: | 221 | To set the formatted name for all contacts, please use menu: |
219 | Edit->Change->Set formatted name. | 222 | Edit->Change->Set formatted name. |
220 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 223 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
221 | 224 | ||
222 | ********** VERSION 2.1.4 ************ | 225 | ********** VERSION 2.1.4 ************ |
223 | 226 | ||
224 | Fixed two more bugs in the KA/Pi CSV import dialog: | 227 | Fixed two more bugs in the KA/Pi CSV import dialog: |
225 | Made it possible to read multi-line fields and import it to the "Note" field. | 228 | Made it possible to read multi-line fields and import it to the "Note" field. |
226 | Fixed a problem in mapping custom fields, whatever a custem field is... | 229 | Fixed a problem in mapping custom fields, whatever a custem field is... |
227 | 230 | ||
228 | ********** VERSION 2.1.3 ************ | 231 | ********** VERSION 2.1.3 ************ |
229 | 232 | ||
230 | Changed the menu structure of the alarm applet: | 233 | Changed the menu structure of the alarm applet: |
231 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 234 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
232 | 235 | ||
233 | Fixed several problems in the KA/Pi CSV import dialog: | 236 | Fixed several problems in the KA/Pi CSV import dialog: |
234 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 237 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
235 | 238 | ||
236 | 239 | ||
237 | ********** VERSION 2.1.2 ************ | 240 | ********** VERSION 2.1.2 ************ |
238 | 241 | ||
239 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 242 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
240 | 243 | ||
241 | Fixed a problem when importing data from Outlook with mutiple categories set. | 244 | Fixed a problem when importing data from Outlook with mutiple categories set. |
242 | 245 | ||
243 | Changed display of days in datenavigator: | 246 | Changed display of days in datenavigator: |
244 | Birthdays are now blue, not dark green. | 247 | Birthdays are now blue, not dark green. |
245 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 248 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
246 | When journal view is shown, only holidays are shown and days with journals are blue. | 249 | When journal view is shown, only holidays are shown and days with journals are blue. |
247 | 250 | ||
248 | Added Backup options to global config: | 251 | Added Backup options to global config: |
249 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). | 252 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). |
250 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. | 253 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. |
251 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. | 254 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. |
252 | 255 | ||
253 | ********** VERSION 2.1.1 ************ | 256 | ********** VERSION 2.1.1 ************ |
254 | 257 | ||
255 | Stable release 2.1.1! | 258 | Stable release 2.1.1! |
256 | 259 | ||
257 | KO/Pi: | 260 | KO/Pi: |
258 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 261 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
259 | 262 | ||
260 | ********** VERSION 2.1.0 ************ | 263 | ********** VERSION 2.1.0 ************ |
261 | 264 | ||
262 | Stable release 2.1.0! | 265 | Stable release 2.1.0! |
263 | 266 | ||
264 | Summary of changes/fixes compared to version 2.0.6: | 267 | Summary of changes/fixes compared to version 2.0.6: |
265 | 268 | ||
266 | Many bugs of version 2.0.6 fixed. | 269 | Many bugs of version 2.0.6 fixed. |
267 | Most of them were small bugs, but some of them were important. | 270 | Most of them were small bugs, but some of them were important. |
268 | It is recommended to use version 2.1.0 and not version 2.0.6. | 271 | It is recommended to use version 2.1.0 and not version 2.0.6. |
269 | 272 | ||
270 | Important changes: | 273 | Important changes: |
271 | 274 | ||
272 | Added recurring todos to KO/Pi. | 275 | Added recurring todos to KO/Pi. |
273 | 276 | ||
274 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 277 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
275 | 278 | ||
276 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 279 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
277 | 280 | ||
278 | Datenavigator can now display many months. Very useful on the desktop. | 281 | Datenavigator can now display many months. Very useful on the desktop. |
279 | 282 | ||
280 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 283 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
281 | 284 | ||
282 | Made alarm sound working on Linux desktop. | 285 | Made alarm sound working on Linux desktop. |
283 | 286 | ||
284 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 287 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
285 | 288 | ||
286 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 289 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
287 | 290 | ||
288 | Many other usebility enhancements. | 291 | Many other usebility enhancements. |
289 | Special thanks to Ben for his suggestions! | 292 | Special thanks to Ben for his suggestions! |
290 | 293 | ||
291 | You can find the complete changelog | 294 | You can find the complete changelog |
292 | from version 1.7.7 to 2.1.0 | 295 | from version 1.7.7 to 2.1.0 |
293 | in the source package or on | 296 | in the source package or on |
294 | 297 | ||
295 | http://www.pi-sync.net/html/changelog.html | 298 | http://www.pi-sync.net/html/changelog.html |
296 | 299 | ||
297 | 300 | ||
298 | 301 | ||
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index f2ee0ab..2a75bfb 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1714 +1,1720 @@ | |||
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 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qapplication.h> | 52 | #include <qapplication.h> |
53 | 53 | ||
54 | #include <klocale.h> | 54 | #include <klocale.h> |
55 | #include <kglobal.h> | 55 | #include <kglobal.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | 58 | ||
59 | QDateTime KSyncManager::mRequestedSyncEvent; | 59 | QDateTime KSyncManager::mRequestedSyncEvent; |
60 | 60 | ||
61 | 61 | ||
62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
64 | { | 64 | { |
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | KSyncManager::~KSyncManager() | 73 | KSyncManager::~KSyncManager() |
74 | { | 74 | { |
75 | delete bar; | 75 | delete bar; |
76 | } | 76 | } |
77 | 77 | ||
78 | void KSyncManager::setDefaultFileName( QString s) | 78 | void KSyncManager::setDefaultFileName( QString s) |
79 | { | 79 | { |
80 | mDefFileName = s ; | 80 | mDefFileName = s ; |
81 | if ( mPrefs->mPassiveSyncAutoStart ) | 81 | if ( mPrefs->mPassiveSyncAutoStart ) |
82 | enableQuick( false ); | 82 | enableQuick( false ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KSyncManager::fillSyncMenu() | 85 | void KSyncManager::fillSyncMenu() |
86 | { | 86 | { |
87 | if ( mSyncMenu->count() ) | 87 | if ( mSyncMenu->count() ) |
88 | mSyncMenu->clear(); | 88 | mSyncMenu->clear(); |
89 | 89 | ||
90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
91 | mSyncMenu->insertSeparator(); | 91 | mSyncMenu->insertSeparator(); |
92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
95 | clearMenu->insertSeparator(); | 95 | clearMenu->insertSeparator(); |
96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
97 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
98 | if ( mServerSocket == 0 ) { | 98 | if ( mServerSocket == 0 ) { |
99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
100 | } else { | 100 | } else { |
101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
102 | } | 102 | } |
103 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
105 | mSyncMenu->insertSeparator(); | 105 | mSyncMenu->insertSeparator(); |
106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
107 | config.setGroup("General"); | 107 | config.setGroup("General"); |
108 | QStringList prof = config.readListEntry("SyncProfileNames"); | 108 | QStringList prof = config.readListEntry("SyncProfileNames"); |
109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
110 | if ( prof.count() < 2 ) { | 110 | if ( prof.count() < 2 ) { |
111 | prof.clear(); | 111 | prof.clear(); |
112 | QString externalName; | 112 | QString externalName; |
113 | #ifdef DESKTOP_VERSION | 113 | #ifdef DESKTOP_VERSION |
114 | #ifdef _WIN32_ | 114 | #ifdef _WIN32_ |
115 | externalName = "OutLook(not_implemented)"; | 115 | externalName = "OutLook(not_implemented)"; |
116 | #else | 116 | #else |
117 | externalName = "KDE_Desktop"; | 117 | externalName = "KDE_Desktop"; |
118 | #endif | 118 | #endif |
119 | #else | 119 | #else |
120 | externalName = "Sharp_DTM"; | 120 | externalName = "Sharp_DTM"; |
121 | #endif | 121 | #endif |
122 | prof << externalName; | 122 | prof << externalName; |
123 | prof << i18n("Local_file"); | 123 | prof << i18n("Local_file"); |
124 | prof << i18n("Last_file"); | 124 | prof << i18n("Last_file"); |
125 | KSyncProfile* temp = new KSyncProfile (); | 125 | KSyncProfile* temp = new KSyncProfile (); |
126 | temp->setName( prof[0] ); | 126 | temp->setName( prof[0] ); |
127 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
128 | temp->setName( prof[1] ); | 128 | temp->setName( prof[1] ); |
129 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
130 | temp->setName( prof[2] ); | 130 | temp->setName( prof[2] ); |
131 | temp->writeConfig(&config); | 131 | temp->writeConfig(&config); |
132 | config.setGroup("General"); | 132 | config.setGroup("General"); |
133 | config.writeEntry("SyncProfileNames",prof); | 133 | config.writeEntry("SyncProfileNames",prof); |
134 | config.writeEntry("ExternSyncProfiles",externalName); | 134 | config.writeEntry("ExternSyncProfiles",externalName); |
135 | config.sync(); | 135 | config.sync(); |
136 | delete temp; | 136 | delete temp; |
137 | } | 137 | } |
138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
139 | mSyncProfileNames = prof; | 139 | mSyncProfileNames = prof; |
140 | unsigned int i; | 140 | unsigned int i; |
141 | for ( i = 0; i < prof.count(); ++i ) { | 141 | for ( i = 0; i < prof.count(); ++i ) { |
142 | QString insertText = prof[i]; | 142 | QString insertText = prof[i]; |
143 | if ( i == 0 ) { | 143 | if ( i == 0 ) { |
144 | #ifdef DESKTOP_VERSION | 144 | #ifdef DESKTOP_VERSION |
145 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
146 | insertText = "OutLook(not_implemented)"; | 146 | insertText = "OutLook(not_implemented)"; |
147 | #else | 147 | #else |
148 | insertText = "KDE_Desktop"; | 148 | insertText = "KDE_Desktop"; |
149 | #endif | 149 | #endif |
150 | #else | 150 | #else |
151 | insertText = "Sharp_DTM"; | 151 | insertText = "Sharp_DTM"; |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | mSyncMenu->insertItem( insertText, 1000+i ); | 154 | mSyncMenu->insertItem( insertText, 1000+i ); |
155 | clearMenu->insertItem( insertText, 1000+i ); | 155 | clearMenu->insertItem( insertText, 1000+i ); |
156 | if ( i == 2 ) | 156 | if ( i == 2 ) |
157 | mSyncMenu->insertSeparator(); | 157 | mSyncMenu->insertSeparator(); |
158 | } | 158 | } |
159 | QDir app_dir; | 159 | QDir app_dir; |
160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
161 | if ( mTargetApp == PWMPI) { | 161 | if ( mTargetApp == PWMPI) { |
162 | mSyncMenu->removeItem( 1000 ); | 162 | mSyncMenu->removeItem( 1000 ); |
163 | clearMenu->removeItem( 1000 ); | 163 | clearMenu->removeItem( 1000 ); |
164 | } | 164 | } |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
167 | mSyncMenu->removeItem( 1000 ); | 167 | mSyncMenu->removeItem( 1000 ); |
168 | clearMenu->removeItem( 1000 ); | 168 | clearMenu->removeItem( 1000 ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mSyncMenu->removeItem( 1002 ); | 171 | mSyncMenu->removeItem( 1002 ); |
172 | clearMenu->removeItem( 1002 ); | 172 | clearMenu->removeItem( 1002 ); |
173 | } | 173 | } |
174 | void KSyncManager::slotClearMenu( int action ) | 174 | void KSyncManager::slotClearMenu( int action ) |
175 | { | 175 | { |
176 | QString syncDevice; | 176 | QString syncDevice; |
177 | if ( action > 999 ) { | 177 | if ( action > 999 ) { |
178 | syncDevice = mSyncProfileNames[action - 1000] ; | 178 | syncDevice = mSyncProfileNames[action - 1000] ; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | int result = 0; | 183 | int result = 0; |
184 | QString sd; | 184 | QString sd; |
185 | if ( syncDevice.isEmpty() ) | 185 | if ( syncDevice.isEmpty() ) |
186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
187 | else | 187 | else |
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | if ( action == 5000 ) | 199 | if ( action == 5000 ) |
200 | return; | 200 | return; |
201 | mSyncWithDesktop = false; | 201 | mSyncWithDesktop = false; |
202 | if ( action == 0 ) { | 202 | if ( action == 0 ) { |
203 | 203 | ||
204 | // seems to be a Qt2 event handling bug | 204 | // seems to be a Qt2 event handling bug |
205 | // syncmenu.clear causes a segfault at first time | 205 | // syncmenu.clear causes a segfault at first time |
206 | // when we call it after the main event loop, it is ok | 206 | // when we call it after the main event loop, it is ok |
207 | // same behaviour when calling OM/Pi via QCOP for the first time | 207 | // same behaviour when calling OM/Pi via QCOP for the first time |
208 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
209 | //confSync(); | 209 | //confSync(); |
210 | 210 | ||
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | if ( action == 1 ) { | 213 | if ( action == 1 ) { |
214 | multiSync( true ); | 214 | multiSync( true ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | if ( action == 2 ) { | 217 | if ( action == 2 ) { |
218 | enableQuick(); | 218 | enableQuick(); |
219 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 219 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | if ( action == 3 ) { | 222 | if ( action == 3 ) { |
223 | delete mServerSocket; | 223 | delete mServerSocket; |
224 | mServerSocket = 0; | 224 | mServerSocket = 0; |
225 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 225 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | if (blockSave()) | 229 | if (blockSave()) |
230 | return; | 230 | return; |
231 | 231 | ||
232 | setBlockSave(true); | 232 | setBlockSave(true); |
233 | bool silent = false; | 233 | bool silent = false; |
234 | if ( action == 999 ) { | 234 | if ( action == 999 ) { |
235 | //special mode for silent syncing | 235 | //special mode for silent syncing |
236 | action = 1000; | 236 | action = 1000; |
237 | silent = true; | 237 | silent = true; |
238 | } | 238 | } |
239 | 239 | ||
240 | mCurrentSyncProfile = action - 1000 ; | 240 | mCurrentSyncProfile = action - 1000 ; |
241 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 241 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
242 | mCurrentSyncName = mLocalMachineName ; | 242 | mCurrentSyncName = mLocalMachineName ; |
243 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 243 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
244 | KSyncProfile* temp = new KSyncProfile (); | 244 | KSyncProfile* temp = new KSyncProfile (); |
245 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 245 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
246 | temp->readConfig(&config); | 246 | temp->readConfig(&config); |
247 | if (silent) { | 247 | if (silent) { |
248 | mAskForPreferences = false; | 248 | mAskForPreferences = false; |
249 | mShowSyncSummary = false; | 249 | mShowSyncSummary = false; |
250 | mWriteBackFile = true; | 250 | mWriteBackFile = true; |
251 | mSyncAlgoPrefs = 2;// take newest | 251 | mSyncAlgoPrefs = 2;// take newest |
252 | } | 252 | } |
253 | else { | 253 | else { |
254 | mAskForPreferences = temp->getAskForPreferences(); | 254 | mAskForPreferences = temp->getAskForPreferences(); |
255 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 255 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
256 | mWriteBackFile = temp->getWriteBackFile(); | 256 | mWriteBackFile = temp->getWriteBackFile(); |
257 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 257 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
258 | } | 258 | } |
259 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 259 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
260 | mIsKapiFile = temp->getIsKapiFile(); | 260 | mIsKapiFile = temp->getIsKapiFile(); |
261 | mWriteBackInFuture = 0; | 261 | mWriteBackInFuture = 0; |
262 | if ( temp->getWriteBackFuture() ) { | 262 | if ( temp->getWriteBackFuture() ) { |
263 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 263 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
264 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 264 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
265 | } | 265 | } |
266 | mFilterInCal = temp->getFilterInCal(); | 266 | mFilterInCal = temp->getFilterInCal(); |
267 | mFilterOutCal = temp->getFilterOutCal(); | 267 | mFilterOutCal = temp->getFilterOutCal(); |
268 | mFilterInAB = temp->getFilterInAB(); | 268 | mFilterInAB = temp->getFilterInAB(); |
269 | mFilterOutAB = temp->getFilterOutAB(); | 269 | mFilterOutAB = temp->getFilterOutAB(); |
270 | 270 | ||
271 | if ( action == 1000 ) { | 271 | if ( action == 1000 ) { |
272 | mIsKapiFile = false; | 272 | mIsKapiFile = false; |
273 | #ifdef DESKTOP_VERSION | 273 | #ifdef DESKTOP_VERSION |
274 | syncKDE(); | 274 | syncKDE(); |
275 | #else | 275 | #else |
276 | syncSharp(); | 276 | syncSharp(); |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | } else if ( action == 1001 ) { | 279 | } else if ( action == 1001 ) { |
280 | syncLocalFile(); | 280 | syncLocalFile(); |
281 | 281 | ||
282 | } else if ( action == 1002 ) { | 282 | } else if ( action == 1002 ) { |
283 | mWriteBackFile = false; | 283 | mWriteBackFile = false; |
284 | mAskForPreferences = false; | 284 | mAskForPreferences = false; |
285 | mShowSyncSummary = false; | 285 | mShowSyncSummary = false; |
286 | mSyncAlgoPrefs = 3; | 286 | mSyncAlgoPrefs = 3; |
287 | quickSyncLocalFile(); | 287 | quickSyncLocalFile(); |
288 | 288 | ||
289 | } else if ( action >= 1003 ) { | 289 | } else if ( action >= 1003 ) { |
290 | if ( temp->getIsLocalFileSync() ) { | 290 | if ( temp->getIsLocalFileSync() ) { |
291 | switch(mTargetApp) | 291 | switch(mTargetApp) |
292 | { | 292 | { |
293 | case (KAPI): | 293 | case (KAPI): |
294 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 294 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
295 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 295 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
296 | break; | 296 | break; |
297 | case (KOPI): | 297 | case (KOPI): |
298 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 298 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
299 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 299 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
300 | break; | 300 | break; |
301 | case (PWMPI): | 301 | case (PWMPI): |
302 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 302 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
303 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 303 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
304 | break; | 304 | break; |
305 | default: | 305 | default: |
306 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 306 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
307 | break; | 307 | break; |
308 | 308 | ||
309 | } | 309 | } |
310 | } else { | 310 | } else { |
311 | if ( temp->getIsPhoneSync() ) { | 311 | if ( temp->getIsPhoneSync() ) { |
312 | mPhoneDevice = temp->getPhoneDevice( ) ; | 312 | mPhoneDevice = temp->getPhoneDevice( ) ; |
313 | mPhoneConnection = temp->getPhoneConnection( ); | 313 | mPhoneConnection = temp->getPhoneConnection( ); |
314 | mPhoneModel = temp->getPhoneModel( ); | 314 | mPhoneModel = temp->getPhoneModel( ); |
315 | syncPhone(); | 315 | syncPhone(); |
316 | } else if ( temp->getIsPiSync() ) { | 316 | } else if ( temp->getIsPiSync() ) { |
317 | if ( mTargetApp == KAPI ) { | 317 | if ( mTargetApp == KAPI ) { |
318 | mPassWordPiSync = temp->getRemotePwAB(); | 318 | mPassWordPiSync = temp->getRemotePwAB(); |
319 | mActiveSyncPort = temp->getRemotePortAB(); | 319 | mActiveSyncPort = temp->getRemotePortAB(); |
320 | mActiveSyncIP = temp->getRemoteIPAB(); | 320 | mActiveSyncIP = temp->getRemoteIPAB(); |
321 | } else if ( mTargetApp == KOPI ) { | 321 | } else if ( mTargetApp == KOPI ) { |
322 | mPassWordPiSync = temp->getRemotePw(); | 322 | mPassWordPiSync = temp->getRemotePw(); |
323 | mActiveSyncPort = temp->getRemotePort(); | 323 | mActiveSyncPort = temp->getRemotePort(); |
324 | mActiveSyncIP = temp->getRemoteIP(); | 324 | mActiveSyncIP = temp->getRemoteIP(); |
325 | } else { | 325 | } else { |
326 | mPassWordPiSync = temp->getRemotePwPWM(); | 326 | mPassWordPiSync = temp->getRemotePwPWM(); |
327 | mActiveSyncPort = temp->getRemotePortPWM(); | 327 | mActiveSyncPort = temp->getRemotePortPWM(); |
328 | mActiveSyncIP = temp->getRemoteIPPWM(); | 328 | mActiveSyncIP = temp->getRemoteIPPWM(); |
329 | } | 329 | } |
330 | syncPi(); | 330 | syncPi(); |
331 | while ( !mPisyncFinished ) { | 331 | while ( !mPisyncFinished ) { |
332 | //qDebug("waiting "); | 332 | //qDebug("waiting "); |
333 | qApp->processEvents(); | 333 | qApp->processEvents(); |
334 | } | 334 | } |
335 | } else | 335 | } else |
336 | syncRemote( temp ); | 336 | syncRemote( temp ); |
337 | 337 | ||
338 | } | 338 | } |
339 | } | 339 | } |
340 | delete temp; | 340 | delete temp; |
341 | setBlockSave(false); | 341 | setBlockSave(false); |
342 | } | 342 | } |
343 | 343 | ||
344 | void KSyncManager::enableQuick( bool ask ) | 344 | void KSyncManager::enableQuick( bool ask ) |
345 | { | 345 | { |
346 | bool autoStart; | 346 | bool autoStart; |
347 | bool changed = false; | 347 | bool changed = false; |
348 | if ( ask ) { | 348 | if ( ask ) { |
349 | QDialog dia ( 0, "input-dialog", true ); | 349 | QDialog dia ( 0, "input-dialog", true ); |
350 | QLineEdit lab ( &dia ); | 350 | QLineEdit lab ( &dia ); |
351 | QVBoxLayout lay( &dia ); | 351 | QVBoxLayout lay( &dia ); |
352 | lab.setText( mPrefs->mPassiveSyncPort ); | 352 | lab.setText( mPrefs->mPassiveSyncPort ); |
353 | lay.setMargin(7); | 353 | lay.setMargin(7); |
354 | lay.setSpacing(7); | 354 | lay.setSpacing(7); |
355 | int po = 9197+mTargetApp; | 355 | int po = 9197+mTargetApp; |
356 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 356 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
357 | lay.addWidget( &label); | 357 | lay.addWidget( &label); |
358 | lay.addWidget( &lab); | 358 | lay.addWidget( &lab); |
359 | 359 | ||
360 | QLineEdit lepw ( &dia ); | 360 | QLineEdit lepw ( &dia ); |
361 | lepw.setText( mPrefs->mPassiveSyncPw ); | 361 | lepw.setText( mPrefs->mPassiveSyncPw ); |
362 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 362 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
363 | lay.addWidget( &label2); | 363 | lay.addWidget( &label2); |
364 | lay.addWidget( &lepw); | 364 | lay.addWidget( &lepw); |
365 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 365 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
366 | lay.addWidget( &autostart); | 366 | lay.addWidget( &autostart); |
367 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 367 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
368 | #ifdef DESKTOP_VERSION | 368 | #ifdef DESKTOP_VERSION |
369 | #ifdef _WIN32_ | 369 | #ifdef _WIN32_ |
370 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 370 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
371 | syncdesktop.hide();// not implemented! | 371 | syncdesktop.hide();// not implemented! |
372 | #else | 372 | #else |
373 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 373 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
374 | #endif | 374 | #endif |
375 | lay.addWidget( &syncdesktop); | 375 | lay.addWidget( &syncdesktop); |
376 | #else | 376 | #else |
377 | mPrefs->mPassiveSyncWithDesktop = false; | 377 | mPrefs->mPassiveSyncWithDesktop = false; |
378 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 378 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
379 | syncdesktop.hide(); | 379 | syncdesktop.hide(); |
380 | #endif | 380 | #endif |
381 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 381 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
382 | 382 | ||
383 | QPushButton pb ( "OK", &dia); | 383 | QPushButton pb ( "OK", &dia); |
384 | lay.addWidget( &pb ); | 384 | lay.addWidget( &pb ); |
385 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 385 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
386 | dia.resize( 230,120 ); | 386 | dia.resize( 230,120 ); |
387 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 387 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
388 | dia.show(); | 388 | dia.show(); |
389 | #ifndef DESKTOP_VERSION | 389 | #ifndef DESKTOP_VERSION |
390 | int dw = QApplication::desktop()->width(); | 390 | int dw = QApplication::desktop()->width(); |
391 | int dh = QApplication::desktop()->height(); | 391 | int dh = QApplication::desktop()->height(); |
392 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 392 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
393 | #endif | 393 | #endif |
394 | if ( ! dia.exec() ) | 394 | if ( ! dia.exec() ) |
395 | return; | 395 | return; |
396 | dia.hide(); | 396 | dia.hide(); |
397 | qApp->processEvents(); | 397 | qApp->processEvents(); |
398 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 398 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
399 | changed = true; | 399 | changed = true; |
400 | mPrefs->mPassiveSyncPw = lepw.text(); | 400 | mPrefs->mPassiveSyncPw = lepw.text(); |
401 | } | 401 | } |
402 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 402 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
403 | mPrefs->mPassiveSyncPort = lab.text(); | 403 | mPrefs->mPassiveSyncPort = lab.text(); |
404 | changed = true; | 404 | changed = true; |
405 | } | 405 | } |
406 | autoStart = autostart.isChecked(); | 406 | autoStart = autostart.isChecked(); |
407 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 407 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
408 | changed = true; | 408 | changed = true; |
409 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 409 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
410 | } | 410 | } |
411 | } | 411 | } |
412 | else | 412 | else |
413 | autoStart = mPrefs->mPassiveSyncAutoStart; | 413 | autoStart = mPrefs->mPassiveSyncAutoStart; |
414 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 414 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
415 | changed = true; | 415 | changed = true; |
416 | bool ok; | 416 | bool ok; |
417 | mPrefs->mPassiveSyncAutoStart = false; | 417 | mPrefs->mPassiveSyncAutoStart = false; |
418 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 418 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
419 | qDebug("%d ", port_t); | 419 | qDebug("%d ", port_t); |
420 | if ( ! ok || port_t > 65535 ) { | 420 | if ( ! ok || port_t > 65535 ) { |
421 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 421 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
422 | return; | 422 | return; |
423 | } | 423 | } |
424 | Q_UINT16 port = port_t; | 424 | Q_UINT16 port = port_t; |
425 | //qDebug("port %d ", port); | 425 | //qDebug("port %d ", port); |
426 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 426 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
427 | mServerSocket->setFileName( defaultFileName() );//bbb | 427 | mServerSocket->setFileName( defaultFileName() );//bbb |
428 | if ( !mServerSocket->ok() ) { | 428 | if ( !mServerSocket->ok() ) { |
429 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 429 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
430 | delete mServerSocket; | 430 | delete mServerSocket; |
431 | mServerSocket = 0; | 431 | mServerSocket = 0; |
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | mPrefs->mPassiveSyncAutoStart = autoStart; | 434 | mPrefs->mPassiveSyncAutoStart = autoStart; |
435 | if ( changed ) { | 435 | if ( changed ) { |
436 | mPrefs->writeConfig(); | 436 | mPrefs->writeConfig(); |
437 | } | 437 | } |
438 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 438 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
439 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 439 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
440 | } | 440 | } |
441 | void KSyncManager::displayErrorPort() | 441 | void KSyncManager::displayErrorPort() |
442 | { | 442 | { |
443 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); | 443 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); |
444 | } | 444 | } |
445 | void KSyncManager::syncLocalFile() | 445 | void KSyncManager::syncLocalFile() |
446 | { | 446 | { |
447 | 447 | ||
448 | QString fn =mPrefs->mLastSyncedLocalFile; | 448 | QString fn =mPrefs->mLastSyncedLocalFile; |
449 | QString ext; | 449 | QString ext; |
450 | 450 | ||
451 | switch(mTargetApp) | 451 | switch(mTargetApp) |
452 | { | 452 | { |
453 | case (KAPI): | 453 | case (KAPI): |
454 | ext = "(*.vcf)"; | 454 | ext = "(*.vcf)"; |
455 | break; | 455 | break; |
456 | case (KOPI): | 456 | case (KOPI): |
457 | ext = "(*.ics/*.vcs)"; | 457 | ext = "(*.ics/*.vcs)"; |
458 | break; | 458 | break; |
459 | case (PWMPI): | 459 | case (PWMPI): |
460 | ext = "(*.pwm)"; | 460 | ext = "(*.pwm)"; |
461 | break; | 461 | break; |
462 | default: | 462 | default: |
463 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 463 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
464 | break; | 464 | break; |
465 | 465 | ||
466 | } | 466 | } |
467 | 467 | ||
468 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 468 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
469 | if ( fn == "" ) | 469 | if ( fn == "" ) |
470 | return; | 470 | return; |
471 | if ( syncWithFile( fn, false ) ) { | 471 | if ( syncWithFile( fn, false ) ) { |
472 | qDebug("KSM::syncLocalFile() successful "); | 472 | qDebug("KSM::syncLocalFile() successful "); |
473 | } | 473 | } |
474 | 474 | ||
475 | } | 475 | } |
476 | 476 | ||
477 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 477 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
478 | { | 478 | { |
479 | bool ret = false; | 479 | bool ret = false; |
480 | QFileInfo info; | 480 | QFileInfo info; |
481 | info.setFile( fn ); | 481 | info.setFile( fn ); |
482 | QString mess; | 482 | QString mess; |
483 | if ( !info. exists() ) { | 483 | if ( !info. exists() ) { |
484 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 484 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
485 | QMessageBox::warning( mParent, i18n("Warning!"), | 485 | QMessageBox::warning( mParent, i18n("Warning!"), |
486 | mess ); | 486 | mess ); |
487 | return ret; | 487 | return ret; |
488 | } | 488 | } |
489 | int result = 0; | 489 | int result = 0; |
490 | if ( !quick ) { | 490 | if ( !quick ) { |
491 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 491 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
492 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 492 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
493 | mess, | 493 | mess, |
494 | i18n("Sync"), i18n("Cancel"), 0, | 494 | i18n("Sync"), i18n("Cancel"), 0, |
495 | 0, 1 ); | 495 | 0, 1 ); |
496 | if ( result ) | 496 | if ( result ) |
497 | return false; | 497 | return false; |
498 | } | 498 | } |
499 | if ( mAskForPreferences ) | 499 | if ( mAskForPreferences ) |
500 | if ( !edit_sync_options()) { | 500 | if ( !edit_sync_options()) { |
501 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 501 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
502 | return false; | 502 | return false; |
503 | } | 503 | } |
504 | if ( result == 0 ) { | 504 | if ( result == 0 ) { |
505 | //qDebug("Now sycing ... "); | 505 | //qDebug("Now sycing ... "); |
506 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 506 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
507 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 507 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
508 | else | 508 | else |
509 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 509 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
510 | if ( ! quick ) | 510 | if ( ! quick ) |
511 | mPrefs->mLastSyncedLocalFile = fn; | 511 | mPrefs->mLastSyncedLocalFile = fn; |
512 | } | 512 | } |
513 | return ret; | 513 | return ret; |
514 | } | 514 | } |
515 | 515 | ||
516 | void KSyncManager::quickSyncLocalFile() | 516 | void KSyncManager::quickSyncLocalFile() |
517 | { | 517 | { |
518 | 518 | ||
519 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 519 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
520 | qDebug("KSM::quick syncLocalFile() successful "); | 520 | qDebug("KSM::quick syncLocalFile() successful "); |
521 | 521 | ||
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | void KSyncManager::multiSync( bool askforPrefs ) | 525 | void KSyncManager::multiSync( bool askforPrefs ) |
526 | { | 526 | { |
527 | if (blockSave()) | 527 | if (blockSave()) |
528 | return; | 528 | return; |
529 | setBlockSave(true); | 529 | setBlockSave(true); |
530 | if ( askforPrefs ) { | 530 | if ( askforPrefs ) { |
531 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 531 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
532 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 532 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
533 | question, | 533 | question, |
534 | i18n("Yes"), i18n("No"), | 534 | i18n("Yes"), i18n("No"), |
535 | 0, 0 ) != 0 ) { | 535 | 0, 0 ) != 0 ) { |
536 | setBlockSave(false); | 536 | setBlockSave(false); |
537 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 537 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
538 | return; | 538 | return; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 541 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
542 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 542 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
543 | if ( askforPrefs ) { | 543 | if ( askforPrefs ) { |
544 | if ( !edit_sync_options()) { | 544 | if ( !edit_sync_options()) { |
545 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 545 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
546 | return; | 546 | return; |
547 | } | 547 | } |
548 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 548 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
549 | } | 549 | } |
550 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 550 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
551 | qApp->processEvents(); | 551 | qApp->processEvents(); |
552 | int num = ringSync() ; | 552 | int num = ringSync() ; |
553 | if ( num > 1 ) | 553 | if ( num > 1 ) |
554 | ringSync(); | 554 | ringSync(); |
555 | setBlockSave(false); | 555 | setBlockSave(false); |
556 | if ( num ) | 556 | if ( num ) |
557 | emit save(); | 557 | emit save(); |
558 | if ( num ) | 558 | if ( num ) |
559 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 559 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
560 | else | 560 | else |
561 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 561 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | 564 | ||
565 | int KSyncManager::ringSync() | 565 | int KSyncManager::ringSync() |
566 | { | 566 | { |
567 | 567 | ||
568 | int syncedProfiles = 0; | 568 | int syncedProfiles = 0; |
569 | unsigned int i; | 569 | unsigned int i; |
570 | QTime timer; | 570 | QTime timer; |
571 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 571 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
572 | QStringList syncProfileNames = mSyncProfileNames; | 572 | QStringList syncProfileNames = mSyncProfileNames; |
573 | KSyncProfile* temp = new KSyncProfile (); | 573 | KSyncProfile* temp = new KSyncProfile (); |
574 | mAskForPreferences = false; | 574 | mAskForPreferences = false; |
575 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 575 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
576 | mCurrentSyncProfile = i; | 576 | mCurrentSyncProfile = i; |
577 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 577 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
578 | temp->readConfig(&config); | 578 | temp->readConfig(&config); |
579 | 579 | ||
580 | bool includeInRingSync = false; | 580 | bool includeInRingSync = false; |
581 | switch(mTargetApp) | 581 | switch(mTargetApp) |
582 | { | 582 | { |
583 | case (KAPI): | 583 | case (KAPI): |
584 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 584 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
585 | break; | 585 | break; |
586 | case (KOPI): | 586 | case (KOPI): |
587 | includeInRingSync = temp->getIncludeInRingSync(); | 587 | includeInRingSync = temp->getIncludeInRingSync(); |
588 | break; | 588 | break; |
589 | case (PWMPI): | 589 | case (PWMPI): |
590 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 590 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
591 | break; | 591 | break; |
592 | default: | 592 | default: |
593 | qDebug("KSM::ringSync: invalid apptype selected"); | 593 | qDebug("KSM::ringSync: invalid apptype selected"); |
594 | break; | 594 | break; |
595 | 595 | ||
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 599 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
600 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 600 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
601 | ++syncedProfiles; | 601 | ++syncedProfiles; |
602 | mSyncWithDesktop = false; | 602 | mSyncWithDesktop = false; |
603 | // mAskForPreferences = temp->getAskForPreferences(); | 603 | // mAskForPreferences = temp->getAskForPreferences(); |
604 | mWriteBackFile = temp->getWriteBackFile(); | 604 | mWriteBackFile = temp->getWriteBackFile(); |
605 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 605 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
606 | mIsKapiFile = temp->getIsKapiFile(); | 606 | mIsKapiFile = temp->getIsKapiFile(); |
607 | mWriteBackInFuture = 0; | 607 | mWriteBackInFuture = 0; |
608 | if ( temp->getWriteBackFuture() ) { | 608 | if ( temp->getWriteBackFuture() ) { |
609 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 609 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
610 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 610 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
611 | } | 611 | } |
612 | mFilterInCal = temp->getFilterInCal(); | 612 | mFilterInCal = temp->getFilterInCal(); |
613 | mFilterOutCal = temp->getFilterOutCal(); | 613 | mFilterOutCal = temp->getFilterOutCal(); |
614 | mFilterInAB = temp->getFilterInAB(); | 614 | mFilterInAB = temp->getFilterInAB(); |
615 | mFilterOutAB = temp->getFilterOutAB(); | 615 | mFilterOutAB = temp->getFilterOutAB(); |
616 | mShowSyncSummary = false; | 616 | mShowSyncSummary = false; |
617 | mCurrentSyncDevice = syncProfileNames[i] ; | 617 | mCurrentSyncDevice = syncProfileNames[i] ; |
618 | mCurrentSyncName = mLocalMachineName; | 618 | mCurrentSyncName = mLocalMachineName; |
619 | if ( i == 0 ) { | 619 | if ( i == 0 ) { |
620 | mIsKapiFile = false; | 620 | mIsKapiFile = false; |
621 | #ifdef DESKTOP_VERSION | 621 | #ifdef DESKTOP_VERSION |
622 | syncKDE(); | 622 | syncKDE(); |
623 | #else | 623 | #else |
624 | syncSharp(); | 624 | syncSharp(); |
625 | #endif | 625 | #endif |
626 | } else { | 626 | } else { |
627 | if ( temp->getIsLocalFileSync() ) { | 627 | if ( temp->getIsLocalFileSync() ) { |
628 | switch(mTargetApp) | 628 | switch(mTargetApp) |
629 | { | 629 | { |
630 | case (KAPI): | 630 | case (KAPI): |
631 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 631 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
632 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 632 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
633 | break; | 633 | break; |
634 | case (KOPI): | 634 | case (KOPI): |
635 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 635 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
636 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 636 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
637 | break; | 637 | break; |
638 | case (PWMPI): | 638 | case (PWMPI): |
639 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 639 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
640 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 640 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
641 | break; | 641 | break; |
642 | default: | 642 | default: |
643 | qDebug("KSM: invalid apptype selected"); | 643 | qDebug("KSM: invalid apptype selected"); |
644 | break; | 644 | break; |
645 | } | 645 | } |
646 | } else { | 646 | } else { |
647 | if ( temp->getIsPhoneSync() ) { | 647 | if ( temp->getIsPhoneSync() ) { |
648 | mPhoneDevice = temp->getPhoneDevice( ) ; | 648 | mPhoneDevice = temp->getPhoneDevice( ) ; |
649 | mPhoneConnection = temp->getPhoneConnection( ); | 649 | mPhoneConnection = temp->getPhoneConnection( ); |
650 | mPhoneModel = temp->getPhoneModel( ); | 650 | mPhoneModel = temp->getPhoneModel( ); |
651 | syncPhone(); | 651 | syncPhone(); |
652 | } else if ( temp->getIsPiSync() ) { | 652 | } else if ( temp->getIsPiSync() ) { |
653 | if ( mTargetApp == KAPI ) { | 653 | if ( mTargetApp == KAPI ) { |
654 | mPassWordPiSync = temp->getRemotePwAB(); | 654 | mPassWordPiSync = temp->getRemotePwAB(); |
655 | mActiveSyncPort = temp->getRemotePortAB(); | 655 | mActiveSyncPort = temp->getRemotePortAB(); |
656 | mActiveSyncIP = temp->getRemoteIPAB(); | 656 | mActiveSyncIP = temp->getRemoteIPAB(); |
657 | } else if ( mTargetApp == KOPI ) { | 657 | } else if ( mTargetApp == KOPI ) { |
658 | mPassWordPiSync = temp->getRemotePw(); | 658 | mPassWordPiSync = temp->getRemotePw(); |
659 | mActiveSyncPort = temp->getRemotePort(); | 659 | mActiveSyncPort = temp->getRemotePort(); |
660 | mActiveSyncIP = temp->getRemoteIP(); | 660 | mActiveSyncIP = temp->getRemoteIP(); |
661 | } else { | 661 | } else { |
662 | mPassWordPiSync = temp->getRemotePwPWM(); | 662 | mPassWordPiSync = temp->getRemotePwPWM(); |
663 | mActiveSyncPort = temp->getRemotePortPWM(); | 663 | mActiveSyncPort = temp->getRemotePortPWM(); |
664 | mActiveSyncIP = temp->getRemoteIPPWM(); | 664 | mActiveSyncIP = temp->getRemoteIPPWM(); |
665 | } | 665 | } |
666 | syncPi(); | 666 | syncPi(); |
667 | while ( !mPisyncFinished ) { | 667 | while ( !mPisyncFinished ) { |
668 | //qDebug("waiting "); | 668 | //qDebug("waiting "); |
669 | qApp->processEvents(); | 669 | qApp->processEvents(); |
670 | } | 670 | } |
671 | timer.start(); | 671 | timer.start(); |
672 | while ( timer.elapsed () < 2000 ) { | 672 | while ( timer.elapsed () < 2000 ) { |
673 | qApp->processEvents(); | 673 | qApp->processEvents(); |
674 | } | 674 | } |
675 | } else | 675 | } else |
676 | syncRemote( temp, false ); | 676 | syncRemote( temp, false ); |
677 | 677 | ||
678 | } | 678 | } |
679 | } | 679 | } |
680 | timer.start(); | 680 | timer.start(); |
681 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 681 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
682 | while ( timer.elapsed () < 2000 ) { | 682 | while ( timer.elapsed () < 2000 ) { |
683 | qApp->processEvents(); | 683 | qApp->processEvents(); |
684 | #ifndef _WIN32_ | 684 | #ifndef _WIN32_ |
685 | sleep (1); | 685 | sleep (1); |
686 | #endif | 686 | #endif |
687 | } | 687 | } |
688 | 688 | ||
689 | } | 689 | } |
690 | 690 | ||
691 | } | 691 | } |
692 | delete temp; | 692 | delete temp; |
693 | return syncedProfiles; | 693 | return syncedProfiles; |
694 | } | 694 | } |
695 | 695 | ||
696 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 696 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
697 | { | 697 | { |
698 | QString question; | 698 | QString question; |
699 | if ( ask ) { | 699 | if ( ask ) { |
700 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 700 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
701 | if ( QMessageBox::information( mParent, i18n("Sync"), | 701 | if ( QMessageBox::information( mParent, i18n("Sync"), |
702 | question, | 702 | question, |
703 | i18n("Yes"), i18n("No"), | 703 | i18n("Yes"), i18n("No"), |
704 | 0, 0 ) != 0 ) | 704 | 0, 0 ) != 0 ) |
705 | return; | 705 | return; |
706 | } | 706 | } |
707 | 707 | ||
708 | QString preCommand; | 708 | QString preCommand; |
709 | QString localTempFile; | 709 | QString localTempFile; |
710 | QString postCommand; | 710 | QString postCommand; |
711 | 711 | ||
712 | switch(mTargetApp) | 712 | switch(mTargetApp) |
713 | { | 713 | { |
714 | case (KAPI): | 714 | case (KAPI): |
715 | preCommand = prof->getPreSyncCommandAB(); | 715 | preCommand = prof->getPreSyncCommandAB(); |
716 | postCommand = prof->getPostSyncCommandAB(); | 716 | postCommand = prof->getPostSyncCommandAB(); |
717 | localTempFile = prof->getLocalTempFileAB(); | 717 | localTempFile = prof->getLocalTempFileAB(); |
718 | break; | 718 | break; |
719 | case (KOPI): | 719 | case (KOPI): |
720 | preCommand = prof->getPreSyncCommand(); | 720 | preCommand = prof->getPreSyncCommand(); |
721 | postCommand = prof->getPostSyncCommand(); | 721 | postCommand = prof->getPostSyncCommand(); |
722 | localTempFile = prof->getLocalTempFile(); | 722 | localTempFile = prof->getLocalTempFile(); |
723 | break; | 723 | break; |
724 | case (PWMPI): | 724 | case (PWMPI): |
725 | preCommand = prof->getPreSyncCommandPWM(); | 725 | preCommand = prof->getPreSyncCommandPWM(); |
726 | postCommand = prof->getPostSyncCommandPWM(); | 726 | postCommand = prof->getPostSyncCommandPWM(); |
727 | localTempFile = prof->getLocalTempFilePWM(); | 727 | localTempFile = prof->getLocalTempFilePWM(); |
728 | break; | 728 | break; |
729 | default: | 729 | default: |
730 | qDebug("KSM::syncRemote: invalid apptype selected"); | 730 | qDebug("KSM::syncRemote: invalid apptype selected"); |
731 | break; | 731 | break; |
732 | } | 732 | } |
733 | 733 | ||
734 | 734 | ||
735 | int fi; | 735 | int fi; |
736 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 736 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
737 | QString pwd = getPassword(); | 737 | QString pwd = getPassword(); |
738 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 738 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
739 | 739 | ||
740 | } | 740 | } |
741 | int maxlen = 30; | 741 | int maxlen = 30; |
742 | if ( QApplication::desktop()->width() > 320 ) | 742 | if ( QApplication::desktop()->width() > 320 ) |
743 | maxlen += 25; | 743 | maxlen += 25; |
744 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 744 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
745 | int fileSize = 0; | 745 | int fileSize = 0; |
746 | int result = system ( preCommand ); | 746 | int result = system ( preCommand ); |
747 | // 0 : okay | 747 | // 0 : okay |
748 | // 256: no such file or dir | 748 | // 256: no such file or dir |
749 | // | 749 | // |
750 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); | 750 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
751 | if ( result != 0 ) { | 751 | if ( result != 0 ) { |
752 | unsigned int len = maxlen; | 752 | unsigned int len = maxlen; |
753 | while ( len < preCommand.length() ) { | 753 | while ( len < preCommand.length() ) { |
754 | preCommand.insert( len , "\n" ); | 754 | preCommand.insert( len , "\n" ); |
755 | len += maxlen +2; | 755 | len += maxlen +2; |
756 | } | 756 | } |
757 | 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) ; | 757 | 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) ; |
758 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 758 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
759 | question, | 759 | question, |
760 | i18n("Okay!")) ; | 760 | i18n("Okay!")) ; |
761 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 761 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
762 | return; | 762 | return; |
763 | } | 763 | } |
764 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 764 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
765 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 765 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
766 | 766 | ||
767 | if ( syncWithFile( localTempFile, true ) ) { | 767 | if ( syncWithFile( localTempFile, true ) ) { |
768 | 768 | ||
769 | if ( mWriteBackFile ) { | 769 | if ( mWriteBackFile ) { |
770 | int fi; | 770 | int fi; |
771 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 771 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
772 | QString pwd = getPassword(); | 772 | QString pwd = getPassword(); |
773 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 773 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
774 | 774 | ||
775 | } | 775 | } |
776 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 776 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
777 | result = system ( postCommand ); | 777 | result = system ( postCommand ); |
778 | qDebug("KSM::Sync:Writing back file result: %d ", result); | 778 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
779 | if ( result != 0 ) { | 779 | if ( result != 0 ) { |
780 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 780 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
781 | return; | 781 | return; |
782 | } else { | 782 | } else { |
783 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 783 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | } | 786 | } |
787 | return; | 787 | return; |
788 | } | 788 | } |
789 | bool KSyncManager::edit_pisync_options() | 789 | bool KSyncManager::edit_pisync_options() |
790 | { | 790 | { |
791 | QDialog dia( mParent, "dia", true ); | 791 | QDialog dia( mParent, "dia", true ); |
792 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 792 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
793 | QVBoxLayout lay ( &dia ); | 793 | QVBoxLayout lay ( &dia ); |
794 | lay.setSpacing( 5 ); | 794 | lay.setSpacing( 5 ); |
795 | lay.setMargin( 3 ); | 795 | lay.setMargin( 3 ); |
796 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 796 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
797 | lay.addWidget( &lab1 ); | 797 | lay.addWidget( &lab1 ); |
798 | QLineEdit le1 (&dia ); | 798 | QLineEdit le1 (&dia ); |
799 | lay.addWidget( &le1 ); | 799 | lay.addWidget( &le1 ); |
800 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 800 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
801 | lay.addWidget( &lab2 ); | 801 | lay.addWidget( &lab2 ); |
802 | QLineEdit le2 (&dia ); | 802 | QLineEdit le2 (&dia ); |
803 | lay.addWidget( &le2 ); | 803 | lay.addWidget( &le2 ); |
804 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); | 804 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); |
805 | lay.addWidget( &lab3 ); | 805 | lay.addWidget( &lab3 ); |
806 | QLineEdit le3 (&dia ); | 806 | QLineEdit le3 (&dia ); |
807 | lay.addWidget( &le3 ); | 807 | lay.addWidget( &le3 ); |
808 | QPushButton pb ( "OK", &dia); | 808 | QPushButton pb ( "OK", &dia); |
809 | lay.addWidget( &pb ); | 809 | lay.addWidget( &pb ); |
810 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 810 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
811 | le1.setText( mPassWordPiSync ); | 811 | le1.setText( mPassWordPiSync ); |
812 | le2.setText( mActiveSyncIP ); | 812 | le2.setText( mActiveSyncIP ); |
813 | le3.setText( mActiveSyncPort ); | 813 | le3.setText( mActiveSyncPort ); |
814 | if ( dia.exec() ) { | 814 | if ( dia.exec() ) { |
815 | mPassWordPiSync = le1.text(); | 815 | mPassWordPiSync = le1.text(); |
816 | mActiveSyncPort = le3.text(); | 816 | mActiveSyncPort = le3.text(); |
817 | mActiveSyncIP = le2.text(); | 817 | mActiveSyncIP = le2.text(); |
818 | return true; | 818 | return true; |
819 | } | 819 | } |
820 | return false; | 820 | return false; |
821 | } | 821 | } |
822 | bool KSyncManager::edit_sync_options() | 822 | bool KSyncManager::edit_sync_options() |
823 | { | 823 | { |
824 | 824 | ||
825 | QDialog dia( mParent, "dia", true ); | 825 | QDialog dia( mParent, "dia", true ); |
826 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 826 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
827 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 827 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
828 | QVBoxLayout lay ( &dia ); | 828 | QVBoxLayout lay ( &dia ); |
829 | lay.setSpacing( 2 ); | 829 | lay.setSpacing( 2 ); |
830 | lay.setMargin( 3 ); | 830 | lay.setMargin( 3 ); |
831 | lay.addWidget(&gr); | 831 | lay.addWidget(&gr); |
832 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 832 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
833 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 833 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
834 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 834 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
835 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 835 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
836 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 836 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
837 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 837 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
838 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 838 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
839 | QPushButton pb ( "OK", &dia); | 839 | QPushButton pb ( "OK", &dia); |
840 | lay.addWidget( &pb ); | 840 | lay.addWidget( &pb ); |
841 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 841 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
842 | switch ( mSyncAlgoPrefs ) { | 842 | switch ( mSyncAlgoPrefs ) { |
843 | case 0: | 843 | case 0: |
844 | loc.setChecked( true); | 844 | loc.setChecked( true); |
845 | break; | 845 | break; |
846 | case 1: | 846 | case 1: |
847 | rem.setChecked( true ); | 847 | rem.setChecked( true ); |
848 | break; | 848 | break; |
849 | case 2: | 849 | case 2: |
850 | newest.setChecked( true); | 850 | newest.setChecked( true); |
851 | break; | 851 | break; |
852 | case 3: | 852 | case 3: |
853 | ask.setChecked( true); | 853 | ask.setChecked( true); |
854 | break; | 854 | break; |
855 | case 4: | 855 | case 4: |
856 | f_loc.setChecked( true); | 856 | f_loc.setChecked( true); |
857 | break; | 857 | break; |
858 | case 5: | 858 | case 5: |
859 | f_rem.setChecked( true); | 859 | f_rem.setChecked( true); |
860 | break; | 860 | break; |
861 | case 6: | 861 | case 6: |
862 | // both.setChecked( true); | 862 | // both.setChecked( true); |
863 | break; | 863 | break; |
864 | default: | 864 | default: |
865 | break; | 865 | break; |
866 | } | 866 | } |
867 | if ( dia.exec() ) { | 867 | if ( dia.exec() ) { |
868 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 868 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
869 | return true; | 869 | return true; |
870 | } | 870 | } |
871 | return false; | 871 | return false; |
872 | } | 872 | } |
873 | 873 | ||
874 | QString KSyncManager::getPassword( ) | 874 | QString KSyncManager::getPassword( ) |
875 | { | 875 | { |
876 | QString retfile = ""; | 876 | QString retfile = ""; |
877 | QDialog dia ( mParent, "input-dialog", true ); | 877 | QDialog dia ( mParent, "input-dialog", true ); |
878 | QLineEdit lab ( &dia ); | 878 | QLineEdit lab ( &dia ); |
879 | lab.setEchoMode( QLineEdit::Password ); | 879 | lab.setEchoMode( QLineEdit::Password ); |
880 | QVBoxLayout lay( &dia ); | 880 | QVBoxLayout lay( &dia ); |
881 | lay.setMargin(7); | 881 | lay.setMargin(7); |
882 | lay.setSpacing(7); | 882 | lay.setSpacing(7); |
883 | lay.addWidget( &lab); | 883 | lay.addWidget( &lab); |
884 | dia.setFixedSize( 230,50 ); | 884 | dia.setFixedSize( 230,50 ); |
885 | dia.setCaption( i18n("Enter password") ); | 885 | dia.setCaption( i18n("Enter password") ); |
886 | QPushButton pb ( "OK", &dia); | 886 | QPushButton pb ( "OK", &dia); |
887 | lay.addWidget( &pb ); | 887 | lay.addWidget( &pb ); |
888 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 888 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
889 | dia.show(); | 889 | dia.show(); |
890 | int res = dia.exec(); | 890 | int res = dia.exec(); |
891 | if ( res ) | 891 | if ( res ) |
892 | retfile = lab.text(); | 892 | retfile = lab.text(); |
893 | dia.hide(); | 893 | dia.hide(); |
894 | qApp->processEvents(); | 894 | qApp->processEvents(); |
895 | return retfile; | 895 | return retfile; |
896 | 896 | ||
897 | } | 897 | } |
898 | 898 | ||
899 | 899 | ||
900 | void KSyncManager::confSync() | 900 | void KSyncManager::confSync() |
901 | { | 901 | { |
902 | static KSyncPrefsDialog* sp = 0; | 902 | static KSyncPrefsDialog* sp = 0; |
903 | if ( ! sp ) { | 903 | if ( ! sp ) { |
904 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 904 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
905 | } | 905 | } |
906 | sp->usrReadConfig(); | 906 | sp->usrReadConfig(); |
907 | #ifndef DESKTOP_VERSION | 907 | #ifndef DESKTOP_VERSION |
908 | sp->showMaximized(); | 908 | sp->showMaximized(); |
909 | #else | 909 | #else |
910 | sp->show(); | 910 | sp->show(); |
911 | #endif | 911 | #endif |
912 | sp->exec(); | 912 | sp->exec(); |
913 | QStringList oldSyncProfileNames = mSyncProfileNames; | 913 | QStringList oldSyncProfileNames = mSyncProfileNames; |
914 | mSyncProfileNames = sp->getSyncProfileNames(); | 914 | mSyncProfileNames = sp->getSyncProfileNames(); |
915 | mLocalMachineName = sp->getLocalMachineName (); | 915 | mLocalMachineName = sp->getLocalMachineName (); |
916 | int ii; | 916 | int ii; |
917 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 917 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
918 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 918 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
919 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 919 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
920 | } | 920 | } |
921 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 921 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
922 | } | 922 | } |
923 | void KSyncManager::syncKDE() | 923 | void KSyncManager::syncKDE() |
924 | { | 924 | { |
925 | mSyncWithDesktop = true; | 925 | mSyncWithDesktop = true; |
926 | emit save(); | 926 | emit save(); |
927 | switch(mTargetApp) | 927 | switch(mTargetApp) |
928 | { | 928 | { |
929 | case (KAPI): | 929 | case (KAPI): |
930 | { | 930 | { |
931 | #ifdef DESKTOP_VERSION | 931 | #ifdef DESKTOP_VERSION |
932 | QString command = "kdeabdump33"; | 932 | QString command = "kdeabdump33"; |
933 | QString commandfile = "kdeabdump33"; | 933 | QString commandfile = "kdeabdump33"; |
934 | QString commandpath = qApp->applicationDirPath () + "/"; | 934 | QString commandpath = qApp->applicationDirPath () + "/"; |
935 | #else | 935 | #else |
936 | QString command = "kdeabdump33"; | 936 | QString command = "kdeabdump33"; |
937 | QString commandfile = "kdeabdump33"; | 937 | QString commandfile = "kdeabdump33"; |
938 | QString commandpath = QDir::homeDirPath ()+"/"; | 938 | QString commandpath = QDir::homeDirPath ()+"/"; |
939 | #endif | 939 | #endif |
940 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 940 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
941 | command = commandfile; | 941 | command = commandfile; |
942 | else | 942 | else |
943 | command = commandpath+commandfile; | 943 | command = commandpath+commandfile; |
944 | 944 | ||
945 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 945 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
946 | int result = system ( command.latin1()); | 946 | int result = system ( command.latin1()); |
947 | qDebug("AB dump 33 command call result: %d ", result); | 947 | qDebug("AB dump 33 command call result: %d ", result); |
948 | if ( result != 0 ) { | 948 | if ( result != 0 ) { |
949 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 949 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
950 | commandfile = "kdeabdump34"; | 950 | commandfile = "kdeabdump34"; |
951 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 951 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
952 | command = commandfile; | 952 | command = commandfile; |
953 | else | 953 | else |
954 | command = commandpath+commandfile; | 954 | command = commandpath+commandfile; |
955 | result = system ( command.latin1()); | 955 | result = system ( command.latin1()); |
956 | qDebug("AB dump 34 command call result: %d ", result); | 956 | qDebug("AB dump 34 command call result: %d ", result); |
957 | if ( result != 0 ) { | 957 | if ( result != 0 ) { |
958 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 958 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
959 | return; | 959 | return; |
960 | } | 960 | } |
961 | } | 961 | } |
962 | if ( syncWithFile( fileName,true ) ) { | 962 | if ( syncWithFile( fileName,true ) ) { |
963 | if ( mWriteBackFile ) { | 963 | if ( mWriteBackFile ) { |
964 | command += " --read"; | 964 | command += " --read"; |
965 | system ( command.latin1()); | 965 | system ( command.latin1()); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | 968 | ||
969 | } | 969 | } |
970 | break; | 970 | break; |
971 | case (KOPI): | 971 | case (KOPI): |
972 | { | 972 | { |
973 | #ifdef DESKTOP_VERSION | 973 | #ifdef DESKTOP_VERSION |
974 | QString command = "kdecaldump33"; | 974 | QString command = "kdecaldump33"; |
975 | QString commandfile = "kdecaldump33"; | 975 | QString commandfile = "kdecaldump33"; |
976 | QString commandpath = qApp->applicationDirPath () + "/"; | 976 | QString commandpath = qApp->applicationDirPath () + "/"; |
977 | #else | 977 | #else |
978 | QString command = "kdecaldump33"; | 978 | QString command = "kdecaldump33"; |
979 | QString commandfile = "kdecaldump33"; | 979 | QString commandfile = "kdecaldump33"; |
980 | QString commandpath = QDir::homeDirPath ()+"/"; | 980 | QString commandpath = QDir::homeDirPath ()+"/"; |
981 | #endif | 981 | #endif |
982 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 982 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
983 | command = commandfile; | 983 | command = commandfile; |
984 | else | 984 | else |
985 | command = commandpath+commandfile; | 985 | command = commandpath+commandfile; |
986 | 986 | ||
987 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 987 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
988 | int result = system ( command.latin1()); | 988 | int result = system ( command.latin1()); |
989 | qDebug("Cal dump 33 command call result result: %d ", result); | 989 | qDebug("Cal dump 33 command call result result: %d ", result); |
990 | if ( result != 0 ) { | 990 | if ( result != 0 ) { |
991 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 991 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
992 | commandfile = "kdecaldump34"; | 992 | commandfile = "kdecaldump34"; |
993 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 993 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
994 | command = commandfile; | 994 | command = commandfile; |
995 | else | 995 | else |
996 | command = commandpath+commandfile; | 996 | command = commandpath+commandfile; |
997 | result = system ( command.latin1()); | 997 | result = system ( command.latin1()); |
998 | qDebug("Cal dump 34 command call result result: %d ", result); | 998 | qDebug("Cal dump 34 command call result result: %d ", result); |
999 | if ( result != 0 ) { | 999 | if ( result != 0 ) { |
1000 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1000 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
1001 | return; | 1001 | return; |
1002 | } | 1002 | } |
1003 | } | 1003 | } |
1004 | if ( syncWithFile( fileName,true ) ) { | 1004 | if ( syncWithFile( fileName,true ) ) { |
1005 | if ( mWriteBackFile ) { | 1005 | if ( mWriteBackFile ) { |
1006 | command += " --read"; | 1006 | command += " --read"; |
1007 | system ( command.latin1()); | 1007 | system ( command.latin1()); |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | } | 1011 | } |
1012 | break; | 1012 | break; |
1013 | case (PWMPI): | 1013 | case (PWMPI): |
1014 | 1014 | ||
1015 | break; | 1015 | break; |
1016 | default: | 1016 | default: |
1017 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 1017 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
1018 | break; | 1018 | break; |
1019 | 1019 | ||
1020 | } | 1020 | } |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void KSyncManager::syncSharp() | 1023 | void KSyncManager::syncSharp() |
1024 | { | 1024 | { |
1025 | 1025 | ||
1026 | if ( ! syncExternalApplication("sharp") ) | 1026 | if ( ! syncExternalApplication("sharp") ) |
1027 | qDebug("KSM::ERROR sync sharp "); | 1027 | qDebug("KSM::ERROR sync sharp "); |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | bool KSyncManager::syncExternalApplication(QString resource) | 1030 | bool KSyncManager::syncExternalApplication(QString resource) |
1031 | { | 1031 | { |
1032 | 1032 | ||
1033 | emit save(); | 1033 | emit save(); |
1034 | 1034 | ||
1035 | if ( mAskForPreferences ) | 1035 | if ( mAskForPreferences ) |
1036 | if ( !edit_sync_options()) { | 1036 | if ( !edit_sync_options()) { |
1037 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1037 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1038 | return false; | 1038 | return false; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1041 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1042 | 1042 | ||
1043 | bool syncOK = mImplementation->syncExternal(this, resource); | 1043 | bool syncOK = mImplementation->syncExternal(this, resource); |
1044 | 1044 | ||
1045 | return syncOK; | 1045 | return syncOK; |
1046 | 1046 | ||
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | void KSyncManager::syncPhone() | 1049 | void KSyncManager::syncPhone() |
1050 | { | 1050 | { |
1051 | 1051 | ||
1052 | syncExternalApplication("phone"); | 1052 | syncExternalApplication("phone"); |
1053 | 1053 | ||
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1056 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1057 | { | 1057 | { |
1058 | if (!bar->isVisible()) | 1058 | if (!bar->isVisible()) |
1059 | { | 1059 | { |
1060 | int w = 300; | 1060 | int w = 300; |
1061 | if ( QApplication::desktop()->width() < 320 ) | 1061 | if ( QApplication::desktop()->width() < 320 ) |
1062 | w = 220; | 1062 | w = 220; |
1063 | int h = bar->sizeHint().height() ; | 1063 | int h = bar->sizeHint().height() ; |
1064 | int dw = QApplication::desktop()->width(); | 1064 | int dw = QApplication::desktop()->width(); |
1065 | int dh = QApplication::desktop()->height(); | 1065 | int dh = QApplication::desktop()->height(); |
1066 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1066 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1067 | bar->setCaption (caption); | 1067 | bar->setCaption (caption); |
1068 | bar->setTotalSteps ( total ) ; | 1068 | bar->setTotalSteps ( total ) ; |
1069 | bar->show(); | 1069 | bar->show(); |
1070 | } | 1070 | } |
1071 | bar->raise(); | 1071 | bar->raise(); |
1072 | bar->setProgress( percentage ); | 1072 | bar->setProgress( percentage ); |
1073 | qApp->processEvents(); | 1073 | qApp->processEvents(); |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | void KSyncManager::hideProgressBar() | 1076 | void KSyncManager::hideProgressBar() |
1077 | { | 1077 | { |
1078 | bar->hide(); | 1078 | bar->hide(); |
1079 | qApp->processEvents(); | 1079 | qApp->processEvents(); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | bool KSyncManager::isProgressBarCanceled() | 1082 | bool KSyncManager::isProgressBarCanceled() |
1083 | { | 1083 | { |
1084 | return !bar->isVisible(); | 1084 | return !bar->isVisible(); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | QString KSyncManager::syncFileName() | 1087 | QString KSyncManager::syncFileName() |
1088 | { | 1088 | { |
1089 | 1089 | ||
1090 | QString fn = "tempfile"; | 1090 | QString fn = "tempfile"; |
1091 | switch(mTargetApp) | 1091 | switch(mTargetApp) |
1092 | { | 1092 | { |
1093 | case (KAPI): | 1093 | case (KAPI): |
1094 | fn = "tempsyncab.vcf"; | 1094 | fn = "tempsyncab.vcf"; |
1095 | break; | 1095 | break; |
1096 | case (KOPI): | 1096 | case (KOPI): |
1097 | fn = "tempsynccal.ics"; | 1097 | fn = "tempsynccal.ics"; |
1098 | break; | 1098 | break; |
1099 | case (PWMPI): | 1099 | case (PWMPI): |
1100 | fn = "tempsyncpw.pwm"; | 1100 | fn = "tempsyncpw.pwm"; |
1101 | break; | 1101 | break; |
1102 | default: | 1102 | default: |
1103 | break; | 1103 | break; |
1104 | } | 1104 | } |
1105 | #ifdef _WIN32_ | 1105 | #ifdef _WIN32_ |
1106 | return locateLocal( "tmp", fn ); | 1106 | return locateLocal( "tmp", fn ); |
1107 | #else | 1107 | #else |
1108 | return (QString( "/tmp/" )+ fn ); | 1108 | return (QString( "/tmp/" )+ fn ); |
1109 | #endif | 1109 | #endif |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | void KSyncManager::syncPi() | 1112 | void KSyncManager::syncPi() |
1113 | { | 1113 | { |
1114 | mIsKapiFile = true; | 1114 | mIsKapiFile = true; |
1115 | mPisyncFinished = false; | 1115 | mPisyncFinished = false; |
1116 | qApp->processEvents(); | 1116 | qApp->processEvents(); |
1117 | if ( mAskForPreferences ) | 1117 | if ( mAskForPreferences ) |
1118 | if ( !edit_pisync_options()) { | 1118 | if ( !edit_pisync_options()) { |
1119 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1119 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1120 | mPisyncFinished = true; | 1120 | mPisyncFinished = true; |
1121 | return; | 1121 | return; |
1122 | } | 1122 | } |
1123 | bool ok; | 1123 | bool ok; |
1124 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1124 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1125 | if ( ! ok ) { | 1125 | if ( ! ok ) { |
1126 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1126 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1127 | mPisyncFinished = true; | 1127 | mPisyncFinished = true; |
1128 | return; | 1128 | return; |
1129 | } | 1129 | } |
1130 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1130 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1131 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1131 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1132 | commandSocket->readFile( syncFileName() ); | 1132 | commandSocket->readFile( syncFileName() ); |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1135 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1136 | { | 1136 | { |
1137 | //enum { success, errorW, errorR, quiet }; | 1137 | //enum { success, errorW, errorR, quiet }; |
1138 | 1138 | ||
1139 | 1139 | ||
1140 | 1140 | ||
1141 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1141 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1142 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1142 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1143 | if ( state == KCommandSocket::errorPW ) | 1143 | if ( state == KCommandSocket::errorPW ) |
1144 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1144 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1145 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1145 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1146 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1146 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1147 | else if ( state == KCommandSocket::errorCA ) | 1147 | else if ( state == KCommandSocket::errorCA ) |
1148 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1148 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1149 | else if ( state == KCommandSocket::errorFI ) | 1149 | else if ( state == KCommandSocket::errorFI ) |
1150 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1150 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1151 | else if ( state == KCommandSocket::errorED ) | 1151 | else if ( state == KCommandSocket::errorED ) |
1152 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1152 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1153 | else if ( state == KCommandSocket::errorUN ) | 1153 | else if ( state == KCommandSocket::errorUN ) |
1154 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1154 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1155 | delete s; | 1155 | delete s; |
1156 | if ( state == KCommandSocket::errorR ) { | 1156 | if ( state == KCommandSocket::errorR ) { |
1157 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1157 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1158 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1158 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1159 | commandSocket->sendStop(); | 1159 | commandSocket->sendStop(); |
1160 | } | 1160 | } |
1161 | mPisyncFinished = true; | 1161 | mPisyncFinished = true; |
1162 | return; | 1162 | return; |
1163 | 1163 | ||
1164 | } else if ( state == KCommandSocket::errorW ) { | 1164 | } else if ( state == KCommandSocket::errorW ) { |
1165 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1165 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1166 | mPisyncFinished = true; | 1166 | mPisyncFinished = true; |
1167 | 1167 | ||
1168 | } else if ( state == KCommandSocket::successR ) { | 1168 | } else if ( state == KCommandSocket::successR ) { |
1169 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1169 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1170 | 1170 | ||
1171 | } else if ( state == KCommandSocket::successW ) { | 1171 | } else if ( state == KCommandSocket::successW ) { |
1172 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1172 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1173 | mPisyncFinished = true; | 1173 | mPisyncFinished = true; |
1174 | } else if ( state == KCommandSocket::quiet ){ | 1174 | } else if ( state == KCommandSocket::quiet ){ |
1175 | qDebug("KSS: quiet "); | 1175 | qDebug("KSS: quiet "); |
1176 | mPisyncFinished = true; | 1176 | mPisyncFinished = true; |
1177 | } else { | 1177 | } else { |
1178 | qDebug("KSS: Error: unknown state: %d ", state); | 1178 | qDebug("KSS: Error: unknown state: %d ", state); |
1179 | mPisyncFinished = true; | 1179 | mPisyncFinished = true; |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | delete s; | 1182 | delete s; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | void KSyncManager::readFileFromSocket() | 1185 | void KSyncManager::readFileFromSocket() |
1186 | { | 1186 | { |
1187 | QString fileName = syncFileName(); | 1187 | QString fileName = syncFileName(); |
1188 | bool syncOK = true; | 1188 | bool syncOK = true; |
1189 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1189 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1190 | if ( ! syncWithFile( fileName , true ) ) { | 1190 | if ( ! syncWithFile( fileName , true ) ) { |
1191 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1191 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1192 | syncOK = false; | 1192 | syncOK = false; |
1193 | } | 1193 | } |
1194 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); | 1194 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); |
1195 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1195 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1196 | if ( mWriteBackFile && syncOK ) { | 1196 | if ( mWriteBackFile && syncOK ) { |
1197 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); | 1197 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); |
1198 | commandSocket->writeFile( fileName ); | 1198 | commandSocket->writeFile( fileName ); |
1199 | } | 1199 | } |
1200 | else { | 1200 | else { |
1201 | commandSocket->sendStop(); | 1201 | commandSocket->sendStop(); |
1202 | if ( syncOK ) | 1202 | if ( syncOK ) |
1203 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1203 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1204 | mPisyncFinished = true; | 1204 | mPisyncFinished = true; |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1208 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1209 | { | 1209 | { |
1210 | mPassWord = pw; | 1210 | mPassWord = pw; |
1211 | mSocket = 0; | 1211 | mSocket = 0; |
1212 | mSyncActionDialog = 0; | 1212 | mSyncActionDialog = 0; |
1213 | blockRC = false; | 1213 | blockRC = false; |
1214 | mErrorMessage = 0; | 1214 | mErrorMessage = 0; |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | void KServerSocket::newConnection ( int socket ) | 1217 | void KServerSocket::newConnection ( int socket ) |
1218 | { | 1218 | { |
1219 | // qDebug("KServerSocket:New connection %d ", socket); | 1219 | // qDebug("KServerSocket:New connection %d ", socket); |
1220 | if ( mSocket ) { | 1220 | if ( mSocket ) { |
1221 | qDebug("KSS::newConnection Socket deleted! "); | 1221 | qDebug("KSS::newConnection Socket deleted! "); |
1222 | delete mSocket; | 1222 | delete mSocket; |
1223 | mSocket = 0; | 1223 | mSocket = 0; |
1224 | } | 1224 | } |
1225 | mSocket = new QSocket( this ); | 1225 | mSocket = new QSocket( this ); |
1226 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1226 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1227 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1227 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1228 | mSocket->setSocket( socket ); | 1228 | mSocket->setSocket( socket ); |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | void KServerSocket::discardClient() | 1231 | void KServerSocket::discardClient() |
1232 | { | 1232 | { |
1233 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1233 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1234 | } | 1234 | } |
1235 | void KServerSocket::deleteSocket() | 1235 | void KServerSocket::deleteSocket() |
1236 | { | 1236 | { |
1237 | qDebug("KSS::deleteSocket"); | 1237 | qDebug("KSS::deleteSocket"); |
1238 | if ( mSocket ) { | 1238 | if ( mSocket ) { |
1239 | delete mSocket; | 1239 | delete mSocket; |
1240 | mSocket = 0; | 1240 | mSocket = 0; |
1241 | } | 1241 | } |
1242 | if ( mErrorMessage ) | 1242 | if ( mErrorMessage ) |
1243 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); | 1243 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); |
1244 | } | 1244 | } |
1245 | void KServerSocket::readClient() | 1245 | void KServerSocket::readClient() |
1246 | { | 1246 | { |
1247 | if ( blockRC ) | 1247 | if ( blockRC ) |
1248 | return; | 1248 | return; |
1249 | if ( mSocket == 0 ) { | 1249 | if ( mSocket == 0 ) { |
1250 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1250 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1251 | return; | 1251 | return; |
1252 | } | 1252 | } |
1253 | if ( mErrorMessage ) { | 1253 | if ( mErrorMessage ) { |
1254 | mErrorMessage = 999; | 1254 | mErrorMessage = 999; |
1255 | error_connect("ERROR_ED\r\n\r\n"); | 1255 | error_connect("ERROR_ED\r\n\r\n"); |
1256 | return; | 1256 | return; |
1257 | } | 1257 | } |
1258 | mErrorMessage = 0; | 1258 | mErrorMessage = 0; |
1259 | //qDebug("KServerSocket::readClient()"); | 1259 | //qDebug("KServerSocket::readClient()"); |
1260 | if ( mSocket->canReadLine() ) { | 1260 | if ( mSocket->canReadLine() ) { |
1261 | QString line = mSocket->readLine(); | 1261 | QString line = mSocket->readLine(); |
1262 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1262 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1263 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1263 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1264 | if ( tokens[0] == "GET" ) { | 1264 | if ( tokens[0] == "GET" ) { |
1265 | if ( tokens[1] == mPassWord ) { | 1265 | if ( tokens[1] == mPassWord ) { |
1266 | //emit sendFile( mSocket ); | 1266 | //emit sendFile( mSocket ); |
1267 | bool ok = false; | 1267 | bool ok = false; |
1268 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1268 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1269 | if ( ok ) { | 1269 | if ( ok ) { |
1270 | KSyncManager::mRequestedSyncEvent = dt; | 1270 | KSyncManager::mRequestedSyncEvent = dt; |
1271 | } | 1271 | } |
1272 | else | 1272 | else |
1273 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1273 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1274 | send_file(); | 1274 | send_file(); |
1275 | } | 1275 | } |
1276 | else { | 1276 | else { |
1277 | mErrorMessage = 1; | 1277 | mErrorMessage = 1; |
1278 | error_connect("ERROR_PW\r\n\r\n"); | 1278 | error_connect("ERROR_PW\r\n\r\n"); |
1279 | } | 1279 | } |
1280 | } | 1280 | } |
1281 | if ( tokens[0] == "PUT" ) { | 1281 | if ( tokens[0] == "PUT" ) { |
1282 | if ( tokens[1] == mPassWord ) { | 1282 | if ( tokens[1] == mPassWord ) { |
1283 | //emit getFile( mSocket ); | 1283 | //emit getFile( mSocket ); |
1284 | blockRC = true; | 1284 | blockRC = true; |
1285 | get_file(); | 1285 | get_file(); |
1286 | } | 1286 | } |
1287 | else { | 1287 | else { |
1288 | mErrorMessage = 2; | 1288 | mErrorMessage = 2; |
1289 | error_connect("ERROR_PW\r\n\r\n"); | 1289 | error_connect("ERROR_PW\r\n\r\n"); |
1290 | end_connect(); | 1290 | end_connect(); |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | if ( tokens[0] == "STOP" ) { | 1293 | if ( tokens[0] == "STOP" ) { |
1294 | //emit endConnect(); | 1294 | //emit endConnect(); |
1295 | end_connect(); | 1295 | end_connect(); |
1296 | } | 1296 | } |
1297 | } | 1297 | } |
1298 | } | 1298 | } |
1299 | void KServerSocket::displayErrorMessage() | 1299 | void KServerSocket::displayErrorMessage() |
1300 | { | 1300 | { |
1301 | if ( mErrorMessage == 1 ) { | 1301 | if ( mErrorMessage == 1 ) { |
1302 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1302 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1303 | mErrorMessage = 0; | 1303 | mErrorMessage = 0; |
1304 | } | 1304 | } |
1305 | else if ( mErrorMessage == 2 ) { | 1305 | else if ( mErrorMessage == 2 ) { |
1306 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1306 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1307 | mErrorMessage = 0; | 1307 | mErrorMessage = 0; |
1308 | } | 1308 | } |
1309 | } | 1309 | } |
1310 | void KServerSocket::error_connect( QString errmess ) | 1310 | void KServerSocket::error_connect( QString errmess ) |
1311 | { | 1311 | { |
1312 | QTextStream os( mSocket ); | 1312 | QTextStream os( mSocket ); |
1313 | os.setEncoding( QTextStream::Latin1 ); | 1313 | os.setEncoding( QTextStream::Latin1 ); |
1314 | os << errmess ; | 1314 | os << errmess ; |
1315 | mSocket->close(); | 1315 | mSocket->close(); |
1316 | if ( mSocket->state() == QSocket::Idle ) { | 1316 | if ( mSocket->state() == QSocket::Idle ) { |
1317 | QTimer::singleShot( 0, this , SLOT ( discardClient())); | 1317 | QTimer::singleShot( 0, this , SLOT ( discardClient())); |
1318 | } | 1318 | } |
1319 | } | 1319 | } |
1320 | void KServerSocket::end_connect() | 1320 | void KServerSocket::end_connect() |
1321 | { | 1321 | { |
1322 | delete mSyncActionDialog; | 1322 | delete mSyncActionDialog; |
1323 | mSyncActionDialog = 0; | 1323 | mSyncActionDialog = 0; |
1324 | } | 1324 | } |
1325 | void KServerSocket::send_file() | 1325 | void KServerSocket::send_file() |
1326 | { | 1326 | { |
1327 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1327 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1328 | if ( mSyncActionDialog ) | 1328 | if ( mSyncActionDialog ) |
1329 | delete mSyncActionDialog; | 1329 | delete mSyncActionDialog; |
1330 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1330 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1331 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1331 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1332 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1332 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1333 | label->setAlignment ( Qt::AlignHCenter ); | 1333 | label->setAlignment ( Qt::AlignHCenter ); |
1334 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1334 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1335 | lay->addWidget( label); | 1335 | lay->addWidget( label); |
1336 | lay->setMargin(7); | 1336 | lay->setMargin(7); |
1337 | lay->setSpacing(7); | 1337 | lay->setSpacing(7); |
1338 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1338 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1339 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1339 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1340 | //secs = 333; | 1340 | //secs = 333; |
1341 | if ( secs < 0 ) | 1341 | if ( secs < 0 ) |
1342 | secs = secs * (-1); | 1342 | secs = secs * (-1); |
1343 | if ( secs > 30 ) | 1343 | if ( secs > 30 ) |
1344 | //if ( true ) | 1344 | //if ( true ) |
1345 | { | 1345 | { |
1346 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1346 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1347 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1347 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1348 | label->setAlignment ( Qt::AlignHCenter ); | 1348 | label->setAlignment ( Qt::AlignHCenter ); |
1349 | lay->addWidget( label); | 1349 | lay->addWidget( label); |
1350 | if ( secs > 180 ) | 1350 | if ( secs > 180 ) |
1351 | { | 1351 | { |
1352 | if ( secs > 300 ) { | 1352 | if ( secs > 300 ) { |
1353 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1353 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1354 | qDebug("KSS::Sync cancelled ,cs"); | 1354 | qDebug("KSS::Sync cancelled ,cs"); |
1355 | mErrorMessage = 0; | 1355 | mErrorMessage = 0; |
1356 | end_connect(); | 1356 | end_connect(); |
1357 | error_connect("ERROR_CA\r\n\r\n"); | 1357 | error_connect("ERROR_CA\r\n\r\n"); |
1358 | return ; | 1358 | return ; |
1359 | } | 1359 | } |
1360 | } | 1360 | } |
1361 | QFont f = label->font(); | 1361 | QFont f = label->font(); |
1362 | f.setPointSize ( f.pointSize() *2 ); | 1362 | f.setPointSize ( f.pointSize() *2 ); |
1363 | f. setBold (true ); | 1363 | f. setBold (true ); |
1364 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1364 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1365 | label->setFont( f ); | 1365 | label->setFont( f ); |
1366 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1366 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1367 | label->setText( warning ); | 1367 | label->setText( warning ); |
1368 | label->setAlignment ( Qt::AlignHCenter ); | 1368 | label->setAlignment ( Qt::AlignHCenter ); |
1369 | lay->addWidget( label); | 1369 | lay->addWidget( label); |
1370 | mSyncActionDialog->setFixedSize( 230, 300); | 1370 | mSyncActionDialog->setFixedSize( 230, 300); |
1371 | } else { | 1371 | } else { |
1372 | mSyncActionDialog->setFixedSize( 230, 200); | 1372 | mSyncActionDialog->setFixedSize( 230, 200); |
1373 | } | 1373 | } |
1374 | } else { | 1374 | } else { |
1375 | mSyncActionDialog->setFixedSize( 230, 120); | 1375 | mSyncActionDialog->setFixedSize( 230, 120); |
1376 | } | 1376 | } |
1377 | } else | 1377 | } else |
1378 | mSyncActionDialog->setFixedSize( 230, 120); | 1378 | mSyncActionDialog->setFixedSize( 230, 120); |
1379 | mSyncActionDialog->show(); | 1379 | mSyncActionDialog->show(); |
1380 | mSyncActionDialog->raise(); | 1380 | mSyncActionDialog->raise(); |
1381 | emit request_file(); | 1381 | emit request_file(); |
1382 | qApp->processEvents(); | 1382 | qApp->processEvents(); |
1383 | QString fileName = mFileName; | 1383 | QString fileName = mFileName; |
1384 | QFile file( fileName ); | 1384 | QFile file( fileName ); |
1385 | if (!file.open( IO_ReadOnly ) ) { | 1385 | if (!file.open( IO_ReadOnly ) ) { |
1386 | mErrorMessage = 0; | 1386 | mErrorMessage = 0; |
1387 | end_connect(); | 1387 | end_connect(); |
1388 | error_connect("ERROR_FI\r\n\r\n"); | 1388 | error_connect("ERROR_FI\r\n\r\n"); |
1389 | return ; | 1389 | return ; |
1390 | } | 1390 | } |
1391 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1391 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1392 | QTextStream ts( &file ); | 1392 | QTextStream ts( &file ); |
1393 | ts.setEncoding( QTextStream::Latin1 ); | 1393 | ts.setEncoding( QTextStream::Latin1 ); |
1394 | 1394 | ||
1395 | QTextStream os( mSocket ); | 1395 | QTextStream os( mSocket ); |
1396 | os.setEncoding( QTextStream::Latin1 ); | 1396 | os.setEncoding( QTextStream::Latin1 ); |
1397 | while ( ! ts.atEnd() ) { | 1397 | while ( ! ts.atEnd() ) { |
1398 | os << ts.readLine() << "\r\n"; | 1398 | os << ts.readLine() << "\r\n"; |
1399 | } | 1399 | } |
1400 | os << "\r\n"; | 1400 | os << "\r\n"; |
1401 | //os << ts.read(); | 1401 | //os << ts.read(); |
1402 | file.close(); | 1402 | file.close(); |
1403 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1403 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1404 | mSocket->close(); | 1404 | mSocket->close(); |
1405 | if ( mSocket->state() == QSocket::Idle ) | 1405 | if ( mSocket->state() == QSocket::Idle ) |
1406 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1406 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1407 | } | 1407 | } |
1408 | void KServerSocket::get_file() | 1408 | void KServerSocket::get_file() |
1409 | { | 1409 | { |
1410 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1410 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1411 | 1411 | ||
1412 | piTime.start(); | 1412 | piTime.start(); |
1413 | piFileString = ""; | 1413 | piFileString = ""; |
1414 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1414 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | 1417 | ||
1418 | void KServerSocket::readBackFileFromSocket() | 1418 | void KServerSocket::readBackFileFromSocket() |
1419 | { | 1419 | { |
1420 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1420 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1421 | while ( mSocket->canReadLine () ) { | 1421 | while ( mSocket->canReadLine () ) { |
1422 | piTime.restart(); | 1422 | piTime.restart(); |
1423 | QString line = mSocket->readLine (); | 1423 | QString line = mSocket->readLine (); |
1424 | piFileString += line; | 1424 | piFileString += line; |
1425 | //qDebug("readline: %s ", line.latin1()); | 1425 | //qDebug("readline: %s ", line.latin1()); |
1426 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1426 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1427 | 1427 | ||
1428 | } | 1428 | } |
1429 | if ( piTime.elapsed () < 3000 ) { | 1429 | if ( piTime.elapsed () < 3000 ) { |
1430 | // wait for more | 1430 | // wait for more |
1431 | //qDebug("waitformore "); | 1431 | //qDebug("waitformore "); |
1432 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1432 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1433 | return; | 1433 | return; |
1434 | } | 1434 | } |
1435 | QString fileName = mFileName; | 1435 | QString fileName = mFileName; |
1436 | QFile file ( fileName ); | 1436 | QFile file ( fileName ); |
1437 | if (!file.open( IO_WriteOnly ) ) { | 1437 | if (!file.open( IO_WriteOnly ) ) { |
1438 | delete mSyncActionDialog; | 1438 | delete mSyncActionDialog; |
1439 | mSyncActionDialog = 0; | 1439 | mSyncActionDialog = 0; |
1440 | qDebug("KSS:Error open read back file "); | 1440 | qDebug("KSS:Error open read back file "); |
1441 | piFileString = ""; | 1441 | piFileString = ""; |
1442 | emit file_received( false ); | 1442 | emit file_received( false ); |
1443 | blockRC = false; | 1443 | blockRC = false; |
1444 | return ; | 1444 | return ; |
1445 | 1445 | ||
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1449 | QTextStream ts ( &file ); | 1449 | QTextStream ts ( &file ); |
1450 | ts.setEncoding( QTextStream::Latin1 ); | 1450 | ts.setEncoding( QTextStream::Latin1 ); |
1451 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1451 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1452 | ts << piFileString; | 1452 | ts << piFileString; |
1453 | mSocket->close(); | 1453 | mSocket->close(); |
1454 | if ( mSocket->state() == QSocket::Idle ) | 1454 | if ( mSocket->state() == QSocket::Idle ) |
1455 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1455 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1456 | file.close(); | 1456 | file.close(); |
1457 | piFileString = ""; | 1457 | piFileString = ""; |
1458 | emit file_received( true ); | 1458 | emit file_received( true ); |
1459 | delete mSyncActionDialog; | 1459 | delete mSyncActionDialog; |
1460 | mSyncActionDialog = 0; | 1460 | mSyncActionDialog = 0; |
1461 | blockRC = false; | 1461 | blockRC = false; |
1462 | 1462 | ||
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) | 1465 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) |
1466 | { | 1466 | { |
1467 | mPassWord = password; | 1467 | mPassWord = password; |
1468 | mSocket = 0; | 1468 | mSocket = 0; |
1469 | mFirst = false; | 1469 | mFirst = false; |
1470 | mFirstLine = true; | 1470 | mFirstLine = true; |
1471 | mPort = port; | 1471 | mPort = port; |
1472 | mHost = host; | 1472 | mHost = host; |
1473 | tlw = cap; | 1473 | tlw = cap; |
1474 | mRetVal = quiet; | 1474 | mRetVal = quiet; |
1475 | mTimerSocket = new QTimer ( this ); | 1475 | mTimerSocket = new QTimer ( this ); |
1476 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); | 1476 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); |
1477 | mConnectProgress.setCaption( i18n("Pi-Sync") ); | 1477 | mConnectProgress.setCaption( i18n("Pi-Sync") ); |
1478 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); | 1478 | connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); |
1479 | mConnectCount = -1; | 1479 | mConnectCount = -1; |
1480 | } | 1480 | } |
1481 | void KCommandSocket::sendFileRequest() | 1481 | void KCommandSocket::sendFileRequest() |
1482 | { | 1482 | { |
1483 | if ( tlw ) | 1483 | if ( tlw ) |
1484 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); | 1484 | tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); |
1485 | mConnectProgress.hide(); | 1485 | mConnectProgress.hide(); |
1486 | mConnectCount = 300;mConnectMax = 300; | 1486 | mConnectCount = 300;mConnectMax = 300; |
1487 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); | 1487 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); |
1488 | mTimerSocket->start( 100, true ); | 1488 | mTimerSocket->start( 100, true ); |
1489 | QTextStream os( mSocket ); | 1489 | QTextStream os( mSocket ); |
1490 | os.setEncoding( QTextStream::Latin1 ); | 1490 | os.setEncoding( QTextStream::Latin1 ); |
1491 | 1491 | ||
1492 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1492 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1493 | os << "GET " << mPassWord << curDt <<"\r\n\r\n"; | 1493 | os << "GET " << mPassWord << curDt <<"\r\n\r\n"; |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | void KCommandSocket::readFile( QString fn ) | 1496 | void KCommandSocket::readFile( QString fn ) |
1497 | { | 1497 | { |
1498 | if ( !mSocket ) { | 1498 | if ( !mSocket ) { |
1499 | mSocket = new QSocket( this ); | 1499 | mSocket = new QSocket( this ); |
1500 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1500 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1501 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1501 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1502 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); | 1502 | connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); |
1503 | } | 1503 | } |
1504 | mFileString = ""; | 1504 | mFileString = ""; |
1505 | mFileName = fn; | 1505 | mFileName = fn; |
1506 | mFirst = true; | 1506 | mFirst = true; |
1507 | if ( tlw ) | 1507 | if ( tlw ) |
1508 | tlw->setCaption( i18n("Trying to connect to remote...") ); | 1508 | tlw->setCaption( i18n("Trying to connect to remote...") ); |
1509 | mConnectCount = 30;mConnectMax = 30; | 1509 | mConnectCount = 30;mConnectMax = 30; |
1510 | mTimerSocket->start( 1000, true ); | 1510 | mTimerSocket->start( 1000, true ); |
1511 | mSocket->connectToHost( mHost, mPort ); | 1511 | mSocket->connectToHost( mHost, mPort ); |
1512 | qDebug("KSS: Waiting for connection"); | 1512 | qDebug("KSS: Waiting for connection"); |
1513 | } | 1513 | } |
1514 | void KCommandSocket::updateConnectDialog() | 1514 | void KCommandSocket::updateConnectDialog() |
1515 | { | 1515 | { |
1516 | 1516 | ||
1517 | if ( mConnectCount == mConnectMax ) { | 1517 | if ( mConnectCount == mConnectMax ) { |
1518 | //qDebug("MAXX %d", mConnectMax); | 1518 | //qDebug("MAXX %d", mConnectMax); |
1519 | mConnectProgress.setTotalSteps ( 30 ); | 1519 | mConnectProgress.setTotalSteps ( 30 ); |
1520 | mConnectProgress.show(); | 1520 | mConnectProgress.show(); |
1521 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); | 1521 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); |
1522 | } | 1522 | } |
1523 | //qDebug("updateConnectDialog() %d", mConnectCount); | 1523 | //qDebug("updateConnectDialog() %d", mConnectCount); |
1524 | mConnectProgress.raise(); | 1524 | mConnectProgress.raise(); |
1525 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); | 1525 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); |
1526 | --mConnectCount; | 1526 | --mConnectCount; |
1527 | if ( mConnectCount > 0 ) | 1527 | if ( mConnectCount > 0 ) |
1528 | mTimerSocket->start( 1000, true ); | 1528 | mTimerSocket->start( 1000, true ); |
1529 | else | 1529 | else |
1530 | deleteSocket(); | 1530 | deleteSocket(); |
1531 | 1531 | ||
1532 | } | 1532 | } |
1533 | void KCommandSocket::writeFile( QString fileName ) | 1533 | void KCommandSocket::writeFile( QString fileName ) |
1534 | { | 1534 | { |
1535 | if ( !mSocket ) { | 1535 | if ( !mSocket ) { |
1536 | mSocket = new QSocket( this ); | 1536 | mSocket = new QSocket( this ); |
1537 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1537 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1538 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1538 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1539 | } | 1539 | } |
1540 | mFileName = fileName ; | 1540 | mFileName = fileName ; |
1541 | mConnectCount = 30;mConnectMax = 30; | 1541 | mConnectCount = 30;mConnectMax = 30; |
1542 | mTimerSocket->start( 1000, true ); | 1542 | mTimerSocket->start( 1000, true ); |
1543 | mSocket->connectToHost( mHost, mPort ); | 1543 | mSocket->connectToHost( mHost, mPort ); |
1544 | } | 1544 | } |
1545 | void KCommandSocket::writeFileToSocket() | 1545 | void KCommandSocket::writeFileToSocket() |
1546 | { | 1546 | { |
1547 | mTimerSocket->stop(); | 1547 | mTimerSocket->stop(); |
1548 | QFile file2( mFileName ); | 1548 | QFile file2( mFileName ); |
1549 | if (!file2.open( IO_ReadOnly ) ) { | 1549 | if (!file2.open( IO_ReadOnly ) ) { |
1550 | mConnectProgress.hide(); | 1550 | mConnectProgress.hide(); |
1551 | mConnectCount = -1; | 1551 | mConnectCount = -1; |
1552 | mRetVal= errorW; | 1552 | mRetVal= errorW; |
1553 | mSocket->close(); | 1553 | mSocket->close(); |
1554 | if ( mSocket->state() == QSocket::Idle ) | 1554 | if ( mSocket->state() == QSocket::Idle ) |
1555 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1555 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1556 | return ; | 1556 | return ; |
1557 | } | 1557 | } |
1558 | mConnectProgress.setTotalSteps ( file2.size() ); | 1558 | mConnectProgress.setTotalSteps ( file2.size() ); |
1559 | mConnectProgress.show(); | 1559 | mConnectProgress.show(); |
1560 | int count = 0; | 1560 | int count = 0; |
1561 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); | 1561 | mConnectProgress.setLabelText( i18n("Sending back synced file...") ); |
1562 | mConnectProgress.setProgress( count ); | 1562 | mConnectProgress.setProgress( count ); |
1563 | mConnectProgress.blockSignals( true ); | 1563 | mConnectProgress.blockSignals( true ); |
1564 | QTextStream ts2( &file2 ); | 1564 | QTextStream ts2( &file2 ); |
1565 | ts2.setEncoding( QTextStream::Latin1 ); | 1565 | ts2.setEncoding( QTextStream::Latin1 ); |
1566 | QTextStream os2( mSocket ); | 1566 | QTextStream os2( mSocket ); |
1567 | os2.setEncoding( QTextStream::Latin1 ); | 1567 | os2.setEncoding( QTextStream::Latin1 ); |
1568 | os2 << "PUT " << mPassWord << "\r\n\r\n";; | 1568 | os2 << "PUT " << mPassWord << "\r\n\r\n";; |
1569 | int byteCount = 0; | ||
1570 | int byteMax = file2.size()/53; | ||
1569 | while ( ! ts2.atEnd() ) { | 1571 | while ( ! ts2.atEnd() ) { |
1570 | qApp->processEvents(); | 1572 | qApp->processEvents(); |
1571 | mConnectProgress.setProgress( count ); | 1573 | if ( byteCount > byteMax ) { |
1574 | byteCount = 0; | ||
1575 | mConnectProgress.setProgress( count ); | ||
1576 | } | ||
1572 | QString temp = ts2.readLine(); | 1577 | QString temp = ts2.readLine(); |
1573 | count += temp.length(); | 1578 | count += temp.length(); |
1579 | byteCount += temp.length(); | ||
1574 | os2 << temp << "\r\n"; | 1580 | os2 << temp << "\r\n"; |
1575 | } | 1581 | } |
1576 | file2.close(); | 1582 | file2.close(); |
1577 | mConnectProgress.hide(); | 1583 | mConnectProgress.hide(); |
1578 | mConnectCount = -1; | 1584 | mConnectCount = -1; |
1579 | os2 << "\r\n"; | 1585 | os2 << "\r\n"; |
1580 | mRetVal= successW; | 1586 | mRetVal= successW; |
1581 | mSocket->close(); | 1587 | mSocket->close(); |
1582 | if ( mSocket->state() == QSocket::Idle ) | 1588 | if ( mSocket->state() == QSocket::Idle ) |
1583 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1589 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1584 | mConnectProgress.blockSignals( false ); | 1590 | mConnectProgress.blockSignals( false ); |
1585 | } | 1591 | } |
1586 | void KCommandSocket::sendStop() | 1592 | void KCommandSocket::sendStop() |
1587 | { | 1593 | { |
1588 | if ( !mSocket ) { | 1594 | if ( !mSocket ) { |
1589 | mSocket = new QSocket( this ); | 1595 | mSocket = new QSocket( this ); |
1590 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1596 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1591 | } | 1597 | } |
1592 | mSocket->connectToHost( mHost, mPort ); | 1598 | mSocket->connectToHost( mHost, mPort ); |
1593 | QTextStream os2( mSocket ); | 1599 | QTextStream os2( mSocket ); |
1594 | os2.setEncoding( QTextStream::Latin1 ); | 1600 | os2.setEncoding( QTextStream::Latin1 ); |
1595 | os2 << "STOP\r\n\r\n"; | 1601 | os2 << "STOP\r\n\r\n"; |
1596 | mSocket->close(); | 1602 | mSocket->close(); |
1597 | if ( mSocket->state() == QSocket::Idle ) | 1603 | if ( mSocket->state() == QSocket::Idle ) |
1598 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1604 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1599 | } | 1605 | } |
1600 | 1606 | ||
1601 | void KCommandSocket::startReadFileFromSocket() | 1607 | void KCommandSocket::startReadFileFromSocket() |
1602 | { | 1608 | { |
1603 | if ( ! mFirst ) | 1609 | if ( ! mFirst ) |
1604 | return; | 1610 | return; |
1605 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); | 1611 | mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); |
1606 | mFirst = false; | 1612 | mFirst = false; |
1607 | mFileString = ""; | 1613 | mFileString = ""; |
1608 | mTime.start(); | 1614 | mTime.start(); |
1609 | mFirstLine = true; | 1615 | mFirstLine = true; |
1610 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1616 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1611 | 1617 | ||
1612 | } | 1618 | } |
1613 | void KCommandSocket::readFileFromSocket() | 1619 | void KCommandSocket::readFileFromSocket() |
1614 | { | 1620 | { |
1615 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1621 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1616 | while ( mSocket->canReadLine () ) { | 1622 | while ( mSocket->canReadLine () ) { |
1617 | mTime.restart(); | 1623 | mTime.restart(); |
1618 | QString line = mSocket->readLine (); | 1624 | QString line = mSocket->readLine (); |
1619 | if ( mFirstLine ) { | 1625 | if ( mFirstLine ) { |
1620 | mFirstLine = false; | 1626 | mFirstLine = false; |
1621 | if ( line.left( 6 ) == "ERROR_" ) { | 1627 | if ( line.left( 6 ) == "ERROR_" ) { |
1622 | mTimerSocket->stop(); | 1628 | mTimerSocket->stop(); |
1623 | mConnectCount = -1; | 1629 | mConnectCount = -1; |
1624 | if ( line.left( 8 ) == "ERROR_PW" ) { | 1630 | if ( line.left( 8 ) == "ERROR_PW" ) { |
1625 | mRetVal = errorPW; | 1631 | mRetVal = errorPW; |
1626 | deleteSocket(); | 1632 | deleteSocket(); |
1627 | return ; | 1633 | return ; |
1628 | } | 1634 | } |
1629 | if ( line.left( 8 ) == "ERROR_CA" ) { | 1635 | if ( line.left( 8 ) == "ERROR_CA" ) { |
1630 | mRetVal = errorCA; | 1636 | mRetVal = errorCA; |
1631 | deleteSocket(); | 1637 | deleteSocket(); |
1632 | return ; | 1638 | return ; |
1633 | } | 1639 | } |
1634 | if ( line.left( 8 ) == "ERROR_FI" ) { | 1640 | if ( line.left( 8 ) == "ERROR_FI" ) { |
1635 | mRetVal = errorFI; | 1641 | mRetVal = errorFI; |
1636 | deleteSocket(); | 1642 | deleteSocket(); |
1637 | return ; | 1643 | return ; |
1638 | } | 1644 | } |
1639 | if ( line.left( 8 ) == "ERROR_ED" ) { | 1645 | if ( line.left( 8 ) == "ERROR_ED" ) { |
1640 | mRetVal = errorED; | 1646 | mRetVal = errorED; |
1641 | deleteSocket(); | 1647 | deleteSocket(); |
1642 | return ; | 1648 | return ; |
1643 | } | 1649 | } |
1644 | mRetVal = errorUN; | 1650 | mRetVal = errorUN; |
1645 | deleteSocket(); | 1651 | deleteSocket(); |
1646 | return ; | 1652 | return ; |
1647 | } | 1653 | } |
1648 | } | 1654 | } |
1649 | mFileString += line; | 1655 | mFileString += line; |
1650 | //qDebug("readline: %s ", line.latin1()); | 1656 | //qDebug("readline: %s ", line.latin1()); |
1651 | } | 1657 | } |
1652 | if ( mTime.elapsed () < 3000 ) { | 1658 | if ( mTime.elapsed () < 3000 ) { |
1653 | // wait for more | 1659 | // wait for more |
1654 | //qDebug("waitformore "); | 1660 | //qDebug("waitformore "); |
1655 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1661 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1656 | return; | 1662 | return; |
1657 | } | 1663 | } |
1658 | mTimerSocket->stop(); | 1664 | mTimerSocket->stop(); |
1659 | mConnectCount = -1; | 1665 | mConnectCount = -1; |
1660 | mConnectProgress.hide(); | 1666 | mConnectProgress.hide(); |
1661 | QString fileName = mFileName; | 1667 | QString fileName = mFileName; |
1662 | QFile file ( fileName ); | 1668 | QFile file ( fileName ); |
1663 | if (!file.open( IO_WriteOnly ) ) { | 1669 | if (!file.open( IO_WriteOnly ) ) { |
1664 | mFileString = ""; | 1670 | mFileString = ""; |
1665 | mRetVal = errorR; | 1671 | mRetVal = errorR; |
1666 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1672 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1667 | deleteSocket(); | 1673 | deleteSocket(); |
1668 | return ; | 1674 | return ; |
1669 | 1675 | ||
1670 | } | 1676 | } |
1671 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1677 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1672 | QTextStream ts ( &file ); | 1678 | QTextStream ts ( &file ); |
1673 | ts.setEncoding( QTextStream::Latin1 ); | 1679 | ts.setEncoding( QTextStream::Latin1 ); |
1674 | ts << mFileString; | 1680 | ts << mFileString; |
1675 | file.close(); | 1681 | file.close(); |
1676 | mFileString = ""; | 1682 | mFileString = ""; |
1677 | mRetVal = successR; | 1683 | mRetVal = successR; |
1678 | mSocket->close(); | 1684 | mSocket->close(); |
1679 | // if state is not idle, deleteSocket(); is called via | 1685 | // if state is not idle, deleteSocket(); is called via |
1680 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1686 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1681 | if ( mSocket->state() == QSocket::Idle ) | 1687 | if ( mSocket->state() == QSocket::Idle ) |
1682 | deleteSocket(); | 1688 | deleteSocket(); |
1683 | } | 1689 | } |
1684 | 1690 | ||
1685 | void KCommandSocket::deleteSocket() | 1691 | void KCommandSocket::deleteSocket() |
1686 | { | 1692 | { |
1687 | //qDebug("KCommandSocket::deleteSocket() "); | 1693 | //qDebug("KCommandSocket::deleteSocket() "); |
1688 | mConnectProgress.hide(); | 1694 | mConnectProgress.hide(); |
1689 | 1695 | ||
1690 | if ( mConnectCount >= 0 ) { | 1696 | if ( mConnectCount >= 0 ) { |
1691 | mTimerSocket->stop(); | 1697 | mTimerSocket->stop(); |
1692 | mRetVal = errorTO; | 1698 | mRetVal = errorTO; |
1693 | qDebug("KCS::Connection to remote host timed out"); | 1699 | qDebug("KCS::Connection to remote host timed out"); |
1694 | if ( mSocket ) { | 1700 | if ( mSocket ) { |
1695 | mSocket->close(); | 1701 | mSocket->close(); |
1696 | //if ( mSocket->state() == QSocket::Idle ) | 1702 | //if ( mSocket->state() == QSocket::Idle ) |
1697 | // deleteSocket(); | 1703 | // deleteSocket(); |
1698 | delete mSocket; | 1704 | delete mSocket; |
1699 | mSocket = 0; | 1705 | mSocket = 0; |
1700 | } | 1706 | } |
1701 | if ( mConnectCount == 0 ) | 1707 | if ( mConnectCount == 0 ) |
1702 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); | 1708 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); |
1703 | else if ( tlw ) | 1709 | else if ( tlw ) |
1704 | tlw->setCaption( i18n("Connection to remote host cancelled!") ); | 1710 | tlw->setCaption( i18n("Connection to remote host cancelled!") ); |
1705 | emit commandFinished( this, mRetVal ); | 1711 | emit commandFinished( this, mRetVal ); |
1706 | return; | 1712 | return; |
1707 | } | 1713 | } |
1708 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1714 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1709 | if ( mSocket) | 1715 | if ( mSocket) |
1710 | delete mSocket; | 1716 | delete mSocket; |
1711 | mSocket = 0; | 1717 | mSocket = 0; |
1712 | qDebug("commandFinished "); | 1718 | qDebug("commandFinished "); |
1713 | emit commandFinished( this, mRetVal ); | 1719 | emit commandFinished( this, mRetVal ); |
1714 | } | 1720 | } |