summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/kopiWhatsNew.txt8
-rw-r--r--kabc/addressbook.cpp16
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp17
-rw-r--r--kabc/addressee.h1
-rw-r--r--kaddressbook/kabcore.cpp22
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--kaddressbook/kaddressbookmain.cpp12
-rw-r--r--kaddressbook/kaddressbookmain.h2
-rw-r--r--kaddressbook/mainembedded.cpp8
-rw-r--r--korganizer/mainwindow.cpp15
-rw-r--r--libkdepim/ksyncmanager.cpp6
12 files changed, 79 insertions, 31 deletions
diff --git a/bin/kdepim/korganizer/kopiWhatsNew.txt b/bin/kdepim/korganizer/kopiWhatsNew.txt
index eea860c..3f95dcf 100644
--- a/bin/kdepim/korganizer/kopiWhatsNew.txt
+++ b/bin/kdepim/korganizer/kopiWhatsNew.txt
@@ -1,277 +1,283 @@
1Info about the changes in new versions of KO/Pi 1Info about the changes in new versions of KO/Pi
2and KDE-Pim/Pi 2and KDE-Pim/Pi
3 3
4********** VERSION 1.9.7 ************ 4********** VERSION 1.9.7 ************
5 5
6KO/Pi - KA/Pi on Windows: 6KO/Pi - KA/Pi on Windows:
7Now a directory can be defined by the user, where the 7Now a directory can be defined by the user, where the
8application/config data should be saved. 8application/config data should be saved.
9 Define your desired path in the evironment variable 9 Define your desired path in the evironment variable
10 MICROKDEHOME 10 MICROKDEHOME
11 before starting KO/Pi or KA/Pi. 11 before starting KO/Pi or KA/Pi.
12 12
13An easy Kx/Pi to Kx/Pi syncing is now possible 13An easy Kx/Pi to Kx/Pi syncing is now possible
14(it is called Pi-Sync) via network. 14(it is called Pi-Sync) via network.
15Please look at the Sync Howto. 15Please look at the Sync Howto.
16 16
17Exporting of data to mobile phones is now possible. 17Exporting of calendar data and contacts to mobile phones is now possible.
18The SyncHowto is updated with information howto 18The SyncHowto is updated with information howto
19access/sync mobile phones. 19access/sync mobile phones.
20Please look at the Sync Howto. 20Please look at the Sync Howto.
21 21
22Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly.
23Please disable Fastload for the original contact/calendar applications
24and close them.
25KO/Pi and KA/Pi must be running in order to receive the data.
26(KO/Pi and KA/Pi are always running if Fastload for them is enabled!)
27
22 28
23********** VERSION 1.9.6 ************ 29********** VERSION 1.9.6 ************
24 30
25Changes in the external application communication on the Zaurus 31Changes in the external application communication on the Zaurus
26in order to use less RAM when the apps are running. 32in order to use less RAM when the apps are running.
27First syncing of addressbooks (KA/Pi) is possible. 33First syncing of addressbooks (KA/Pi) is possible.
28 34
29 35
30********** VERSION 1.9.5a ************ 36********** VERSION 1.9.5a ************
31 37
32Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. 38Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5.
33Fixed some small bugs. 39Fixed some small bugs.
34KA/Pi shows now the birthday in summary view. 40KA/Pi shows now the birthday in summary view.
35Now OM/Pi and KA/Pi are using the date format defined in KO/Pi 41Now OM/Pi and KA/Pi are using the date format defined in KO/Pi
36for displaying dates. 42for displaying dates.
37 43
38 44
39********** VERSION 1.9.5 ************ 45********** VERSION 1.9.5 ************
40 46
41There is still no Addressbook syncing! 47There is still no Addressbook syncing!
42 48
43New in 1.9.5: 49New in 1.9.5:
44 50
45Many bugfixes. 51Many bugfixes.
46Better searching in KA/Pi. 52Better searching in KA/Pi.
47You can configure in KA/Pi if you want to search only after 53You can configure in KA/Pi if you want to search only after
48<return> key pressed. 54<return> key pressed.
49 55
50Better mail downloading in OM/Pi. 56Better mail downloading in OM/Pi.
51 57
52First experimental alpha version of sync of KO/Pi with mobile phones. 58First experimental alpha version of sync of KO/Pi with mobile phones.
53See gammu documentation for supported phones. 59See gammu documentation for supported phones.
54You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. 60You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp.
55Quick hint how to use: 61Quick hint how to use:
56NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! 62NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL!
57Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. 63Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp.
58Create syncprofile - mobile device 64Create syncprofile - mobile device
59Remove entry for model. (Leave empty ). 65Remove entry for model. (Leave empty ).
60Enable infrared on Zaurus and your Phone. 66Enable infrared on Zaurus and your Phone.
61Sync. 67Sync.
62To get a more detailed log, start kopi from konsole. 68To get a more detailed log, start kopi from konsole.
63 69
64********** VERSION 1.9.4 ************ 70********** VERSION 1.9.4 ************
65 71
66This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. 72This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus.
67 73
68WARNING: 74WARNING:
69PLEASE BACKUP ALL YOUR DATA! 75PLEASE BACKUP ALL YOUR DATA!
70We have changed a lot and maybe there are some unknown problems. 76We have changed a lot and maybe there are some unknown problems.
71 77
72SYNC HANDLING HAS CHANGED! 78SYNC HANDLING HAS CHANGED!
73Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. 79Such that, if you sync now with an already synded device, you will duplicated entries after the first sync.
74(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). 80(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks).
75 81
76You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. 82You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs.
77If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. 83If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well.
78 84
79As programs are available: 85As programs are available:
80KO/Pi (korganizer ipk) - a calendar program. 86KO/Pi (korganizer ipk) - a calendar program.
81KA/Pi (kaddressbook ipk ) - an addressbook 87KA/Pi (kaddressbook ipk ) - an addressbook
82OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. 88OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support.
83 89
84An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. 90An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode.
85(If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) 91(If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia)
86 92
87All the applications are installed in a "Pim" TAB. 93All the applications are installed in a "Pim" TAB.
88If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk 94If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk
89 95
90All the application are integrated. 96All the application are integrated.
91Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. 97Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail.
92 98
93HINT: 99HINT:
94If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. 100If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number.
95 101
96What's new? 102What's new?
97 103
98SYNC HANDLING HAS CHANGED! 104SYNC HANDLING HAS CHANGED!
99Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. 105Such that, if you sync now with an already synded device, you will duplicated entries after the first sync.
100(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). 106(This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks).
101 107
102New in OM/Pi: 108New in OM/Pi:
103When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. 109When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails.
104 110
105New in KO/Pi: 111New in KO/Pi:
106French is now available for KO/Pi. 112French is now available for KO/Pi.
107Choose menu:Actions - Configure:TAB locale 113Choose menu:Actions - Configure:TAB locale
108Syncing has changed. 114Syncing has changed.
109Phone sync available soon. 115Phone sync available soon.
110Not much changes, I cannot remember them ... 116Not much changes, I cannot remember them ...
111 117
112New in KA/Pi: 118New in KA/Pi:
113Beaming possible. 119Beaming possible.
114Sharp DTM readonly access possible( create a new DTM resource ); 120Sharp DTM readonly access possible( create a new DTM resource );
115Better searching possible. 121Better searching possible.
116Search is performed only after pressing the return key. 122Search is performed only after pressing the return key.
117Use wildcard * to specify parts of a name. 123Use wildcard * to specify parts of a name.
118 124
119Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . 125Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * .
120 126
121A big improvement is the new management of the contact access. 127A big improvement is the new management of the contact access.
122In version 1.9.3, every application was using their own addressbook access data. 128In version 1.9.3, every application was using their own addressbook access data.
123That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. 129That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi.
124That was wasting of memory, if you had several hundreds of contacts. 130That was wasting of memory, if you had several hundreds of contacts.
125 131
126Now only KA/Pi accesses the addressbook. 132Now only KA/Pi accesses the addressbook.
127If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. 133If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them.
128If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. 134If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly.
129That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. 135That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first.
130 136
131New in the KO/Pi alarm applet: 137New in the KO/Pi alarm applet:
132Configure your own timer popup menu! 138Configure your own timer popup menu!
133(Text and minutes for timer countdown) 139(Text and minutes for timer countdown)
134Just edit the file 140Just edit the file
135(yourhomedir)/.kopialarmtimerrc 141(yourhomedir)/.kopialarmtimerrc
136and start/stop a timer to get a new menu with the data of this file. 142and start/stop a timer to get a new menu with the data of this file.
137 143
138********** VERSION 1.9.3 ************ 144********** VERSION 1.9.3 ************
1391) 1451)
140Now KO/Pi on Windows imports directly the calendar data of 146Now KO/Pi on Windows imports directly the calendar data of
141an installed Outlook. Should work with OL version >= 2000. 147an installed Outlook. Should work with OL version >= 2000.
142 148
143********** VERSION 1.9.2 ************ 149********** VERSION 1.9.2 ************
1441) 1501)
145KDE-Pim/Pi has got a new member: 151KDE-Pim/Pi has got a new member:
146KmicroMail (KM/Pi) is a mail program, 152KmicroMail (KM/Pi) is a mail program,
147which can handle IMAP and POP mail access. 153which can handle IMAP and POP mail access.
148It is based on Opie-Mail v3. 154It is based on Opie-Mail v3.
149All dependencies to the Opie libraries ar removed, 155All dependencies to the Opie libraries ar removed,
150such that no additional Opie lib is needed. 156such that no additional Opie lib is needed.
151It is already integrated in KO/Pi and KA/Pi. 157It is already integrated in KO/Pi and KA/Pi.
152It it now available for the Zaurus,probably it 158It it now available for the Zaurus,probably it
153will be available for other platforms later. 159will be available for other platforms later.
154Hint: 160Hint:
155Create your own contact (name + email) 161Create your own contact (name + email)
156in KA/Pi, select this contact and choose menu: 162in KA/Pi, select this contact and choose menu:
157Settings - Set Who Am I. 163Settings - Set Who Am I.
158Now the settings of this contact are used as 164Now the settings of this contact are used as
159the sender data in KM/Pi. 165the sender data in KM/Pi.
1602) 1662)
161KDE-Pim/Pi is split up in five different 167KDE-Pim/Pi is split up in five different
162packages now precompiled for Sharp Zaurus: 168packages now precompiled for Sharp Zaurus:
163--kmicrokdelibs_1.9.2_arm.ipk 169--kmicrokdelibs_1.9.2_arm.ipk
164The libs are needed for any 170The libs are needed for any
165of the following programs: 171of the following programs:
166--kaddressbook_1.9.2_arm.ipk 172--kaddressbook_1.9.2_arm.ipk
167--kmicromail_1.9.2_arm.ipk 173--kmicromail_1.9.2_arm.ipk
168--korganizer_1.9.2_arm.ipk 174--korganizer_1.9.2_arm.ipk
169Independ from that, there is the alarm applet 175Independ from that, there is the alarm applet
170available for KO/Pi, which also offers 176available for KO/Pi, which also offers
171quick access for a new mail or 177quick access for a new mail or
172showing the addressbook.: 178showing the addressbook.:
173--korganizer-alarm_1.9.2_arm.ipk 179--korganizer-alarm_1.9.2_arm.ipk
174Independend means, that the alarm applet 180Independend means, that the alarm applet
175does not need any of the libs or programs above to run. 181does not need any of the libs or programs above to run.
176But it would be quite useless without these programs. 182But it would be quite useless without these programs.
177NOTE: 183NOTE:
178If you get a 184If you get a
179"This application depends on other programs" 185"This application depends on other programs"
180during installation of 186during installation of
181--kmicrokdelibs_1.9.2_arm.ipk 187--kmicrokdelibs_1.9.2_arm.ipk
182you probably do not have to care about that. 188you probably do not have to care about that.
183kmicrokdelibs_1.9.2 will come with some 189kmicrokdelibs_1.9.2 will come with some
184resource plugins, which needs additional libraries. 190resource plugins, which needs additional libraries.
185(E.g. libopie1, if you want to use the 191(E.g. libopie1, if you want to use the
186opie resource connector in KA/Pi). 192opie resource connector in KA/Pi).
187If you do not have this libraries installed, 193If you do not have this libraries installed,
188you simply cannot use the resource. 194you simply cannot use the resource.
189To make it clear: 195To make it clear:
190If the libraries are missing, the applications 196If the libraries are missing, the applications
191using kmicrokdelibs will start, 197using kmicrokdelibs will start,
192because the resources are plugins. 198because the resources are plugins.
1933) 1993)
194KO/Pi and friends are now installable on SD-Card! 200KO/Pi and friends are now installable on SD-Card!
195It is recommended to install all libs and apps 201It is recommended to install all libs and apps
196on the SD card or all in the internal storage. 202on the SD card or all in the internal storage.
197There may be problems, if this is mixed. 203There may be problems, if this is mixed.
1984) 2044)
199Fixed two bugs in the alarm notification on Windows. 205Fixed two bugs in the alarm notification on Windows.
2005) 2065)
201Great improvement! 207Great improvement!
202KO/Pi uses now the latest version of libical. 208KO/Pi uses now the latest version of libical.
203Libical is the library which actually reads 209Libical is the library which actually reads
204the calendar files and extract the data from it. 210the calendar files and extract the data from it.
205With the old version, there were problems 211With the old version, there were problems
206(crashes or program hangs) when licical did read 212(crashes or program hangs) when licical did read
207files, which were not stored from KO/Pi. 213files, which were not stored from KO/Pi.
208I do not know, if the new libical works perfect, 214I do not know, if the new libical works perfect,
209but actually it works much better than 215but actually it works much better than
210the old version. 216the old version.
211There are no problems with compatibility with 217There are no problems with compatibility with
212old calendar files of KO/Pi, of course! 218old calendar files of KO/Pi, of course!
2136) 2196)
214New in KA/Pi: 220New in KA/Pi:
215Opie addressbook resource connector available! 221Opie addressbook resource connector available!
216You will need libopie1 and the opie addressbook, 222You will need libopie1 and the opie addressbook,
217of course. 223of course.
218With the Opie addressbook resource connector, 224With the Opie addressbook resource connector,
219you can access the Opie addressbook readonly in KA/Pi. 225you can access the Opie addressbook readonly in KA/Pi.
220If you want to edit or import the data into KA/Pi, 226If you want to edit or import the data into KA/Pi,
221do this: 227do this:
222a) Create an Opie resource. 228a) Create an Opie resource.
223 (Menu: Settings-Configure Resources). 229 (Menu: Settings-Configure Resources).
224After configuration and restarting KA/Pi you should see 230After configuration and restarting KA/Pi you should see
225the Opie contacts in KA/Pi. 231the Opie contacts in KA/Pi.
226b) Select some or all Opie contacts. 232b) Select some or all Opie contacts.
227(NOTE: +++++ 233(NOTE: +++++
228To know exactly, what contacts are Opie contacts, 234To know exactly, what contacts are Opie contacts,
229do this: Choose menu: 235do this: Choose menu:
230View-Modify View - TAB Fields. 236View-Modify View - TAB Fields.
231Select in the above list "Resource" and click 237Select in the above list "Resource" and click
232down arrow to add it to the "Selected fields". 238down arrow to add it to the "Selected fields".
233Click OK. 239Click OK.
234Now you have a new column "Resource" in your list, 240Now you have a new column "Resource" in your list,
235where you can see, what an Opie resource is. 241where you can see, what an Opie resource is.
236++++ NOTE end.) 242++++ NOTE end.)
237Ok, we do have now some Opie contacts seleted. 243Ok, we do have now some Opie contacts seleted.
238(Use SHIFT or CTRL key in order to multiple select). 244(Use SHIFT or CTRL key in order to multiple select).
239c) Choose menu: Edit-Copy. 245c) Choose menu: Edit-Copy.
240d) Choose menu: Edit-Paste. 246d) Choose menu: Edit-Paste.
241e) Select the resource, you want to add the contacts to. 247e) Select the resource, you want to add the contacts to.
242Congrats! Now you have read/write access to the copied 248Congrats! Now you have read/write access to the copied
243opie contacts as "real" KA/Pi contacts. 249opie contacts as "real" KA/Pi contacts.
244 250
245 251
246********** VERSION 1.9.1 ************ 252********** VERSION 1.9.1 ************
2471) 2531)
248 +++ IMPORTANT 1 +++ 254 +++ IMPORTANT 1 +++
249 255
250The storing place of the default calendar 256The storing place of the default calendar
251file has changed! 257file has changed!
252The default calendar file was 258The default calendar file was
253Applications/korganizer/mycalendar.ics 259Applications/korganizer/mycalendar.ics
254on Zaurus and 260on Zaurus and
255(yourHomeDir)/korganizer/mycalendar.ics 261(yourHomeDir)/korganizer/mycalendar.ics
256on Windows/Linux desktop. Now it is 262on Windows/Linux desktop. Now it is
257(yourHomeDir)/kdepim/korganizer/mycalendar.ics 263(yourHomeDir)/kdepim/korganizer/mycalendar.ics
258on Zaurus, Windows and Linux. 264on Zaurus, Windows and Linux.
259To load the old file, choose menu 265To load the old file, choose menu
260File-Load calendar backup. 266File-Load calendar backup.
261(It should be loaded automatically 267(It should be loaded automatically
262at startup with a warning message displayed). 268at startup with a warning message displayed).
263The place of the configuration file has changed too. 269The place of the configuration file has changed too.
264If you want to use your old KO/Pi config, 270If you want to use your old KO/Pi config,
265copy it to 271copy it to
266(yourHomeDir)/kdepim/config/korganizerrc 272(yourHomeDir)/kdepim/config/korganizerrc
267Please read VERSION 1.9.0 - topic 3) as well! 273Please read VERSION 1.9.0 - topic 3) as well!
268 274
269 +++ IMPORTANT 2 +++ 275 +++ IMPORTANT 2 +++
270 276
271Because of the new paths, you will need 277Because of the new paths, you will need
272a new version of the KO/Pi alarm applet 278a new version of the KO/Pi alarm applet
273for Zaurus. 279for Zaurus.
274Use version >= 1.9.1 280Use version >= 1.9.1
275 281
2762) 2822)
277Now the QWhat'sThis Icon works for items 283Now the QWhat'sThis Icon works for items
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index dc3cda1..bf6d053 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -149,528 +149,536 @@ bool AddressBook::Iterator::operator!=( const Iterator &it )
149 return ( d->mIt != it.d->mIt ); 149 return ( d->mIt != it.d->mIt );
150} 150}
151 151
152 152
153AddressBook::ConstIterator::ConstIterator() 153AddressBook::ConstIterator::ConstIterator()
154{ 154{
155 d = new ConstIteratorData; 155 d = new ConstIteratorData;
156} 156}
157 157
158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
159{ 159{
160 d = new ConstIteratorData; 160 d = new ConstIteratorData;
161 d->mIt = i.d->mIt; 161 d->mIt = i.d->mIt;
162} 162}
163 163
164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
165{ 165{
166 if( this == &i ) return *this; // guard for self assignment 166 if( this == &i ) return *this; // guard for self assignment
167 delete d; // delete the old data because the Iterator was really constructed before 167 delete d; // delete the old data because the Iterator was really constructed before
168 d = new ConstIteratorData; 168 d = new ConstIteratorData;
169 d->mIt = i.d->mIt; 169 d->mIt = i.d->mIt;
170 return *this; 170 return *this;
171} 171}
172 172
173AddressBook::ConstIterator::~ConstIterator() 173AddressBook::ConstIterator::~ConstIterator()
174{ 174{
175 delete d; 175 delete d;
176} 176}
177 177
178const Addressee &AddressBook::ConstIterator::operator*() const 178const Addressee &AddressBook::ConstIterator::operator*() const
179{ 179{
180 return *(d->mIt); 180 return *(d->mIt);
181} 181}
182 182
183const Addressee* AddressBook::ConstIterator::operator->() const 183const Addressee* AddressBook::ConstIterator::operator->() const
184{ 184{
185 return &(*(d->mIt)); 185 return &(*(d->mIt));
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
195{ 195{
196 (d->mIt)++; 196 (d->mIt)++;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
207{ 207{
208 (d->mIt)--; 208 (d->mIt)--;
209 return *this; 209 return *this;
210} 210}
211 211
212bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
213{ 213{
214 return ( d->mIt == it.d->mIt ); 214 return ( d->mIt == it.d->mIt );
215} 215}
216 216
217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
218{ 218{
219 return ( d->mIt != it.d->mIt ); 219 return ( d->mIt != it.d->mIt );
220} 220}
221 221
222 222
223AddressBook::AddressBook() 223AddressBook::AddressBook()
224{ 224{
225 init(0, "contact"); 225 init(0, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
229{ 229{
230 init(config, "contact"); 230 init(config, "contact");
231} 231}
232 232
233AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::AddressBook( const QString &config, const QString &family )
234{ 234{
235 init(config, family); 235 init(config, family);
236 236
237} 237}
238 238
239// the default family is "contact" 239// the default family is "contact"
240void AddressBook::init(const QString &config, const QString &family ) 240void AddressBook::init(const QString &config, const QString &family )
241{ 241{
242 blockLSEchange = false; 242 blockLSEchange = false;
243 d = new AddressBookData; 243 d = new AddressBookData;
244 QString fami = family; 244 QString fami = family;
245 if (config != 0) { 245 if (config != 0) {
246 if ( family == "syncContact" ) { 246 if ( family == "syncContact" ) {
247 qDebug("creating sync config "); 247 qDebug("creating sync config ");
248 fami = "contact"; 248 fami = "contact";
249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
250 con->setGroup( "General" ); 250 con->setGroup( "General" );
251 con->writeEntry( "ResourceKeys", QString("sync") ); 251 con->writeEntry( "ResourceKeys", QString("sync") );
252 con->writeEntry( "Standard", QString("sync") ); 252 con->writeEntry( "Standard", QString("sync") );
253 con->setGroup( "Resource_sync" ); 253 con->setGroup( "Resource_sync" );
254 con->writeEntry( "FileName", config ); 254 con->writeEntry( "FileName", config );
255 con->writeEntry( "FileFormat", QString("vcard") ); 255 con->writeEntry( "FileFormat", QString("vcard") );
256 con->writeEntry( "ResourceIdentifier", QString("sync") ); 256 con->writeEntry( "ResourceIdentifier", QString("sync") );
257 con->writeEntry( "ResourceName", QString("sync_res") ); 257 con->writeEntry( "ResourceName", QString("sync_res") );
258 if ( config.right(4) == ".xml" ) 258 if ( config.right(4) == ".xml" )
259 con->writeEntry( "ResourceType", QString("qtopia") ); 259 con->writeEntry( "ResourceType", QString("qtopia") );
260 else if ( config == "sharp" ) { 260 else if ( config == "sharp" ) {
261 con->writeEntry( "ResourceType", QString("sharp") ); 261 con->writeEntry( "ResourceType", QString("sharp") );
262 } else { 262 } else {
263 con->writeEntry( "ResourceType", QString("file") ); 263 con->writeEntry( "ResourceType", QString("file") );
264 } 264 }
265 //con->sync(); 265 //con->sync();
266 d->mConfig = con; 266 d->mConfig = con;
267 } 267 }
268 else 268 else
269 d->mConfig = new KConfig( locateLocal("config", config) ); 269 d->mConfig = new KConfig( locateLocal("config", config) );
270// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 270// qDebug("AddressBook::init 1 config=%s",config.latin1() );
271 } 271 }
272 else { 272 else {
273 d->mConfig = 0; 273 d->mConfig = 0;
274// qDebug("AddressBook::init 1 config=0"); 274// qDebug("AddressBook::init 1 config=0");
275 } 275 }
276 276
277//US d->mErrorHandler = 0; 277//US d->mErrorHandler = 0;
278 d->mManager = new KRES::Manager<Resource>( fami, false ); 278 d->mManager = new KRES::Manager<Resource>( fami, false );
279 d->mManager->readConfig( d->mConfig ); 279 d->mManager->readConfig( d->mConfig );
280 if ( family == "syncContact" ) { 280 if ( family == "syncContact" ) {
281 KRES::Manager<Resource> *manager = d->mManager; 281 KRES::Manager<Resource> *manager = d->mManager;
282 KRES::Manager<Resource>::ActiveIterator it; 282 KRES::Manager<Resource>::ActiveIterator it;
283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
284 (*it)->setAddressBook( this ); 284 (*it)->setAddressBook( this );
285 if ( !(*it)->open() ) 285 if ( !(*it)->open() )
286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
287 } 287 }
288 Resource *res = standardResource(); 288 Resource *res = standardResource();
289 if ( !res ) { 289 if ( !res ) {
290 qDebug("ERROR: no standard resource"); 290 qDebug("ERROR: no standard resource");
291 res = manager->createResource( "file" ); 291 res = manager->createResource( "file" );
292 if ( res ) 292 if ( res )
293 { 293 {
294 addResource( res ); 294 addResource( res );
295 } 295 }
296 else 296 else
297 qDebug(" No resource available!!!"); 297 qDebug(" No resource available!!!");
298 } 298 }
299 setStandardResource( res ); 299 setStandardResource( res );
300 manager->writeConfig(); 300 manager->writeConfig();
301 } 301 }
302 addCustomField( i18n( "Department" ), KABC::Field::Organization, 302 addCustomField( i18n( "Department" ), KABC::Field::Organization,
303 "X-Department", "KADDRESSBOOK" ); 303 "X-Department", "KADDRESSBOOK" );
304 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 304 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
305 "X-Profession", "KADDRESSBOOK" ); 305 "X-Profession", "KADDRESSBOOK" );
306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
307 "X-AssistantsName", "KADDRESSBOOK" ); 307 "X-AssistantsName", "KADDRESSBOOK" );
308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
309 "X-ManagersName", "KADDRESSBOOK" ); 309 "X-ManagersName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
311 "X-SpousesName", "KADDRESSBOOK" ); 311 "X-SpousesName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Office" ), KABC::Field::Personal, 312 addCustomField( i18n( "Office" ), KABC::Field::Personal,
313 "X-Office", "KADDRESSBOOK" ); 313 "X-Office", "KADDRESSBOOK" );
314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
315 "X-IMAddress", "KADDRESSBOOK" ); 315 "X-IMAddress", "KADDRESSBOOK" );
316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
317 "X-Anniversary", "KADDRESSBOOK" ); 317 "X-Anniversary", "KADDRESSBOOK" );
318 318
319 //US added this field to become compatible with Opie/qtopia addressbook 319 //US added this field to become compatible with Opie/qtopia addressbook
320 // values can be "female" or "male" or "". An empty field represents undefined. 320 // values can be "female" or "male" or "". An empty field represents undefined.
321 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 321 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
322 "X-Gender", "KADDRESSBOOK" ); 322 "X-Gender", "KADDRESSBOOK" );
323 addCustomField( i18n( "Children" ), KABC::Field::Personal, 323 addCustomField( i18n( "Children" ), KABC::Field::Personal,
324 "X-Children", "KADDRESSBOOK" ); 324 "X-Children", "KADDRESSBOOK" );
325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
326 "X-FreeBusyUrl", "KADDRESSBOOK" ); 326 "X-FreeBusyUrl", "KADDRESSBOOK" );
327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
328 "X-ExternalID", "KADDRESSBOOK" ); 328 "X-ExternalID", "KADDRESSBOOK" );
329} 329}
330 330
331AddressBook::~AddressBook() 331AddressBook::~AddressBook()
332{ 332{
333 delete d->mConfig; d->mConfig = 0; 333 delete d->mConfig; d->mConfig = 0;
334 delete d->mManager; d->mManager = 0; 334 delete d->mManager; d->mManager = 0;
335//US delete d->mErrorHandler; d->mErrorHandler = 0; 335//US delete d->mErrorHandler; d->mErrorHandler = 0;
336 delete d; d = 0; 336 delete d; d = 0;
337} 337}
338 338
339bool AddressBook::load() 339bool AddressBook::load()
340{ 340{
341 341
342 342
343 clear(); 343 clear();
344 344
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } 351 }
352 352
353 // mark all addressees as unchanged 353 // mark all addressees as unchanged
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
368{ 368{
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 t << "\r\n\r\n"; 402 t << "\r\n\r\n";
403 outFile.close(); 403 outFile.close();
404} 404}
405void AddressBook::importFromFile( QString fileName ) 405void AddressBook::importFromFile( QString fileName, bool replaceLabel )
406{ 406{
407 407
408 KABC::Addressee::List list; 408 KABC::Addressee::List list;
409 QFile file( fileName ); 409 QFile file( fileName );
410 410
411 file.open( IO_ReadOnly ); 411 file.open( IO_ReadOnly );
412 QByteArray rawData = file.readAll(); 412 QByteArray rawData = file.readAll();
413 file.close(); 413 file.close();
414 414 qDebug("AddressBook::importFromFile ");
415 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 415 QString data;
416 if ( replaceLabel ) {
417 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
418 data.replace ( QRegExp("LABEL") , "ADR" );
419 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
420 } else
421 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
416 KABC::VCardTool tool; 422 KABC::VCardTool tool;
417 list = tool.parseVCards( data ); 423 list = tool.parseVCards( data );
418 KABC::Addressee::List::Iterator it; 424 KABC::Addressee::List::Iterator it;
419 for ( it = list.begin(); it != list.end(); ++it ) { 425 for ( it = list.begin(); it != list.end(); ++it ) {
420 (*it).setResource( 0 ); 426 (*it).setResource( 0 );
427 if ( replaceLabel )
428 (*it).removeVoice();
421 insertAddressee( (*it), false, true ); 429 insertAddressee( (*it), false, true );
422 } 430 }
423 431
424} 432}
425 433
426bool AddressBook::saveAB() 434bool AddressBook::saveAB()
427{ 435{
428 bool ok = true; 436 bool ok = true;
429 437
430 deleteRemovedAddressees(); 438 deleteRemovedAddressees();
431 Iterator ait; 439 Iterator ait;
432 for ( ait = begin(); ait != end(); ++ait ) { 440 for ( ait = begin(); ait != end(); ++ait ) {
433 if ( !(*ait).IDStr().isEmpty() ) { 441 if ( !(*ait).IDStr().isEmpty() ) {
434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 442 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
435 } 443 }
436 } 444 }
437 KRES::Manager<Resource>::ActiveIterator it; 445 KRES::Manager<Resource>::ActiveIterator it;
438 KRES::Manager<Resource> *manager = d->mManager; 446 KRES::Manager<Resource> *manager = d->mManager;
439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 447 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
440 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 448 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
441 Ticket *ticket = requestSaveTicket( *it ); 449 Ticket *ticket = requestSaveTicket( *it );
442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 450// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
443 if ( !ticket ) { 451 if ( !ticket ) {
444 error( i18n( "Unable to save to resource '%1'. It is locked." ) 452 error( i18n( "Unable to save to resource '%1'. It is locked." )
445 .arg( (*it)->resourceName() ) ); 453 .arg( (*it)->resourceName() ) );
446 return false; 454 return false;
447 } 455 }
448 456
449 //if ( !save( ticket ) ) 457 //if ( !save( ticket ) )
450 if ( ticket->resource() ) { 458 if ( ticket->resource() ) {
451 if ( ! ticket->resource()->save( ticket ) ) 459 if ( ! ticket->resource()->save( ticket ) )
452 ok = false; 460 ok = false;
453 } else 461 } else
454 ok = false; 462 ok = false;
455 463
456 } 464 }
457 } 465 }
458 return ok; 466 return ok;
459} 467}
460 468
461AddressBook::Iterator AddressBook::begin() 469AddressBook::Iterator AddressBook::begin()
462{ 470{
463 Iterator it = Iterator(); 471 Iterator it = Iterator();
464 it.d->mIt = d->mAddressees.begin(); 472 it.d->mIt = d->mAddressees.begin();
465 return it; 473 return it;
466} 474}
467 475
468AddressBook::ConstIterator AddressBook::begin() const 476AddressBook::ConstIterator AddressBook::begin() const
469{ 477{
470 ConstIterator it = ConstIterator(); 478 ConstIterator it = ConstIterator();
471 it.d->mIt = d->mAddressees.begin(); 479 it.d->mIt = d->mAddressees.begin();
472 return it; 480 return it;
473} 481}
474 482
475AddressBook::Iterator AddressBook::end() 483AddressBook::Iterator AddressBook::end()
476{ 484{
477 Iterator it = Iterator(); 485 Iterator it = Iterator();
478 it.d->mIt = d->mAddressees.end(); 486 it.d->mIt = d->mAddressees.end();
479 return it; 487 return it;
480} 488}
481 489
482AddressBook::ConstIterator AddressBook::end() const 490AddressBook::ConstIterator AddressBook::end() const
483{ 491{
484 ConstIterator it = ConstIterator(); 492 ConstIterator it = ConstIterator();
485 it.d->mIt = d->mAddressees.end(); 493 it.d->mIt = d->mAddressees.end();
486 return it; 494 return it;
487} 495}
488 496
489void AddressBook::clear() 497void AddressBook::clear()
490{ 498{
491 d->mAddressees.clear(); 499 d->mAddressees.clear();
492} 500}
493 501
494Ticket *AddressBook::requestSaveTicket( Resource *resource ) 502Ticket *AddressBook::requestSaveTicket( Resource *resource )
495{ 503{
496 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 504 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
497 505
498 if ( !resource ) 506 if ( !resource )
499 { 507 {
500 qDebug("AddressBook::requestSaveTicket no resource" ); 508 qDebug("AddressBook::requestSaveTicket no resource" );
501 resource = standardResource(); 509 resource = standardResource();
502 } 510 }
503 511
504 KRES::Manager<Resource>::ActiveIterator it; 512 KRES::Manager<Resource>::ActiveIterator it;
505 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 513 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
506 if ( (*it) == resource ) { 514 if ( (*it) == resource ) {
507 if ( (*it)->readOnly() || !(*it)->isOpen() ) 515 if ( (*it)->readOnly() || !(*it)->isOpen() )
508 return 0; 516 return 0;
509 else 517 else
510 return (*it)->requestSaveTicket(); 518 return (*it)->requestSaveTicket();
511 } 519 }
512 } 520 }
513 521
514 return 0; 522 return 0;
515} 523}
516 524
517void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 525void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
518{ 526{
519 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 527 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
520 //qDebug("block insert "); 528 //qDebug("block insert ");
521 return; 529 return;
522 } 530 }
523 //qDebug("inserting.... %s ",a.uid().latin1() ); 531 //qDebug("inserting.... %s ",a.uid().latin1() );
524 bool found = false; 532 bool found = false;
525 Addressee::List::Iterator it; 533 Addressee::List::Iterator it;
526 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 534 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
527 if ( a.uid() == (*it).uid() ) { 535 if ( a.uid() == (*it).uid() ) {
528 536
529 bool changed = false; 537 bool changed = false;
530 Addressee addr = a; 538 Addressee addr = a;
531 if ( addr != (*it) ) 539 if ( addr != (*it) )
532 changed = true; 540 changed = true;
533 541
534 if ( takeResource ) { 542 if ( takeResource ) {
535 Resource * res = (*it).resource(); 543 Resource * res = (*it).resource();
536 (*it) = a; 544 (*it) = a;
537 (*it).setResource( res ); 545 (*it).setResource( res );
538 } else { 546 } else {
539 (*it) = a; 547 (*it) = a;
540 if ( (*it).resource() == 0 ) 548 if ( (*it).resource() == 0 )
541 (*it).setResource( standardResource() ); 549 (*it).setResource( standardResource() );
542 } 550 }
543 if ( changed ) { 551 if ( changed ) {
544 if ( setRev ) { 552 if ( setRev ) {
545 553
546 // get rid of micro seconds 554 // get rid of micro seconds
547 QDateTime dt = QDateTime::currentDateTime(); 555 QDateTime dt = QDateTime::currentDateTime();
548 QTime t = dt.time(); 556 QTime t = dt.time();
549 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 557 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
550 (*it).setRevision( dt ); 558 (*it).setRevision( dt );
551 } 559 }
552 (*it).setChanged( true ); 560 (*it).setChanged( true );
553 } 561 }
554 562
555 found = true; 563 found = true;
556 } else { 564 } else {
557 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 565 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
558 QString name = (*it).uid().mid( 19 ); 566 QString name = (*it).uid().mid( 19 );
559 Addressee b = a; 567 Addressee b = a;
560 QString id = b.getID( name ); 568 QString id = b.getID( name );
561 if ( ! id.isEmpty() ) { 569 if ( ! id.isEmpty() ) {
562 QString des = (*it).note(); 570 QString des = (*it).note();
563 int startN; 571 int startN;
564 if( (startN = des.find( id ) ) >= 0 ) { 572 if( (startN = des.find( id ) ) >= 0 ) {
565 int endN = des.find( ",", startN+1 ); 573 int endN = des.find( ",", startN+1 );
566 des = des.left( startN ) + des.mid( endN+1 ); 574 des = des.left( startN ) + des.mid( endN+1 );
567 (*it).setNote( des ); 575 (*it).setNote( des );
568 } 576 }
569 } 577 }
570 } 578 }
571 } 579 }
572 } 580 }
573 if ( found ) 581 if ( found )
574 return; 582 return;
575 d->mAddressees.append( a ); 583 d->mAddressees.append( a );
576 Addressee& addr = d->mAddressees.last(); 584 Addressee& addr = d->mAddressees.last();
577 if ( addr.resource() == 0 ) 585 if ( addr.resource() == 0 )
578 addr.setResource( standardResource() ); 586 addr.setResource( standardResource() );
579 587
580 addr.setChanged( true ); 588 addr.setChanged( true );
581} 589}
582 590
583void AddressBook::removeAddressee( const Addressee &a ) 591void AddressBook::removeAddressee( const Addressee &a )
584{ 592{
585 Iterator it; 593 Iterator it;
586 Iterator it2; 594 Iterator it2;
587 bool found = false; 595 bool found = false;
588 for ( it = begin(); it != end(); ++it ) { 596 for ( it = begin(); it != end(); ++it ) {
589 if ( a.uid() == (*it).uid() ) { 597 if ( a.uid() == (*it).uid() ) {
590 found = true; 598 found = true;
591 it2 = it; 599 it2 = it;
592 } else { 600 } else {
593 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 601 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
594 QString name = (*it).uid().mid( 19 ); 602 QString name = (*it).uid().mid( 19 );
595 Addressee b = a; 603 Addressee b = a;
596 QString id = b.getID( name ); 604 QString id = b.getID( name );
597 if ( ! id.isEmpty() ) { 605 if ( ! id.isEmpty() ) {
598 QString des = (*it).note(); 606 QString des = (*it).note();
599 if( des.find( id ) < 0 ) { 607 if( des.find( id ) < 0 ) {
600 des += id + ","; 608 des += id + ",";
601 (*it).setNote( des ); 609 (*it).setNote( des );
602 } 610 }
603 } 611 }
604 } 612 }
605 613
606 } 614 }
607 } 615 }
608 616
609 if ( found ) 617 if ( found )
610 removeAddressee( it2 ); 618 removeAddressee( it2 );
611 619
612} 620}
613 621
614void AddressBook::removeSyncAddressees( bool removeDeleted ) 622void AddressBook::removeSyncAddressees( bool removeDeleted )
615{ 623{
616 Iterator it = begin(); 624 Iterator it = begin();
617 Iterator it2 ; 625 Iterator it2 ;
618 QDateTime dt ( QDate( 2004,1,1) ); 626 QDateTime dt ( QDate( 2004,1,1) );
619 while ( it != end() ) { 627 while ( it != end() ) {
620 (*it).setRevision( dt ); 628 (*it).setRevision( dt );
621 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 629 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
622 (*it).setIDStr(""); 630 (*it).setIDStr("");
623 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 631 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
624 it2 = it; 632 it2 = it;
625 //qDebug("removing %s ",(*it).uid().latin1() ); 633 //qDebug("removing %s ",(*it).uid().latin1() );
626 ++it; 634 ++it;
627 removeAddressee( it2 ); 635 removeAddressee( it2 );
628 } else { 636 } else {
629 //qDebug("skipping %s ",(*it).uid().latin1() ); 637 //qDebug("skipping %s ",(*it).uid().latin1() );
630 ++it; 638 ++it;
631 } 639 }
632 } 640 }
633 deleteRemovedAddressees(); 641 deleteRemovedAddressees();
634} 642}
635 643
636void AddressBook::removeAddressee( const Iterator &it ) 644void AddressBook::removeAddressee( const Iterator &it )
637{ 645{
638 d->mRemovedAddressees.append( (*it) ); 646 d->mRemovedAddressees.append( (*it) );
639 d->mAddressees.remove( it.d->mIt ); 647 d->mAddressees.remove( it.d->mIt );
640} 648}
641 649
642AddressBook::Iterator AddressBook::find( const Addressee &a ) 650AddressBook::Iterator AddressBook::find( const Addressee &a )
643{ 651{
644 Iterator it; 652 Iterator it;
645 for ( it = begin(); it != end(); ++it ) { 653 for ( it = begin(); it != end(); ++it ) {
646 if ( a.uid() == (*it).uid() ) { 654 if ( a.uid() == (*it).uid() ) {
647 return it; 655 return it;
648 } 656 }
649 } 657 }
650 return end(); 658 return end();
651} 659}
652 660
653Addressee AddressBook::findByUid( const QString &uid ) 661Addressee AddressBook::findByUid( const QString &uid )
654{ 662{
655 Iterator it; 663 Iterator it;
656 for ( it = begin(); it != end(); ++it ) { 664 for ( it = begin(); it != end(); ++it ) {
657 if ( uid == (*it).uid() ) { 665 if ( uid == (*it).uid() ) {
658 return *it; 666 return *it;
659 } 667 }
660 } 668 }
661 return Addressee(); 669 return Addressee();
662} 670}
663void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 671void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
664{ 672{
665 //qDebug("AddressBook::preExternSync "); 673 //qDebug("AddressBook::preExternSync ");
666 AddressBook::Iterator it; 674 AddressBook::Iterator it;
667 for ( it = begin(); it != end(); ++it ) { 675 for ( it = begin(); it != end(); ++it ) {
668 (*it).setID( csd, (*it).externalUID() ); 676 (*it).setID( csd, (*it).externalUID() );
669 (*it).computeCsum( csd ); 677 (*it).computeCsum( csd );
670 } 678 }
671 mergeAB( aBook ,csd ); 679 mergeAB( aBook ,csd );
672} 680}
673void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 681void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
674{ 682{
675 //qDebug("AddressBook::postExternSync "); 683 //qDebug("AddressBook::postExternSync ");
676 AddressBook::Iterator it; 684 AddressBook::Iterator it;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 3603ec1..cea1b03 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,341 +1,341 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESSBOOK_H 28#ifndef KABC_ADDRESSBOOK_H
29#define KABC_ADDRESSBOOK_H 29#define KABC_ADDRESSBOOK_H
30 30
31#include <qobject.h> 31#include <qobject.h>
32 32
33#include <kresources/manager.h> 33#include <kresources/manager.h>
34#include <qptrlist.h> 34#include <qptrlist.h>
35 35
36#include "addressee.h" 36#include "addressee.h"
37#include "field.h" 37#include "field.h"
38 38
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 void export2File( QString fileName ); 145 void export2File( QString fileName );
146 void importFromFile( QString fileName ); 146 void importFromFile( QString fileName, bool replaceLabel = false );
147 /** 147 /**
148 Returns a iterator for first entry of address book. 148 Returns a iterator for first entry of address book.
149 */ 149 */
150 Iterator begin(); 150 Iterator begin();
151 151
152 /** 152 /**
153 Returns a const iterator for first entry of address book. 153 Returns a const iterator for first entry of address book.
154 */ 154 */
155 ConstIterator begin() const; 155 ConstIterator begin() const;
156 156
157 /** 157 /**
158 Returns a iterator for first entry of address book. 158 Returns a iterator for first entry of address book.
159 */ 159 */
160 Iterator end(); 160 Iterator end();
161 161
162 /** 162 /**
163 Returns a const iterator for first entry of address book. 163 Returns a const iterator for first entry of address book.
164 */ 164 */
165 ConstIterator end() const; 165 ConstIterator end() const;
166 166
167 /** 167 /**
168 Removes all entries from address book. 168 Removes all entries from address book.
169 */ 169 */
170 void clear(); 170 void clear();
171 171
172 /** 172 /**
173 Insert an Addressee object into address book. If an object with the same 173 Insert an Addressee object into address book. If an object with the same
174 unique id already exists in the address book it it replaced by the new 174 unique id already exists in the address book it it replaced by the new
175 one. If not the new object is appended to the address book. 175 one. If not the new object is appended to the address book.
176 */ 176 */
177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
178 178
179 /** 179 /**
180 Removes entry from the address book. 180 Removes entry from the address book.
181 */ 181 */
182 void removeAddressee( const Addressee & ); 182 void removeAddressee( const Addressee & );
183 183
184 /** 184 /**
185 This is like @ref removeAddressee() just above, with the difference that 185 This is like @ref removeAddressee() just above, with the difference that
186 the first element is a iterator, returned by @ref begin(). 186 the first element is a iterator, returned by @ref begin().
187 */ 187 */
188 void removeAddressee( const Iterator & ); 188 void removeAddressee( const Iterator & );
189 189
190 /** 190 /**
191 Find the specified entry in address book. Returns end(), if the entry 191 Find the specified entry in address book. Returns end(), if the entry
192 couldn't be found. 192 couldn't be found.
193 */ 193 */
194 Iterator find( const Addressee & ); 194 Iterator find( const Addressee & );
195 195
196 /** 196 /**
197 Find the entry specified by an unique id. Returns an empty Addressee 197 Find the entry specified by an unique id. Returns an empty Addressee
198 object, if the address book does not contain an entry with this id. 198 object, if the address book does not contain an entry with this id.
199 */ 199 */
200 Addressee findByUid( const QString & ); 200 Addressee findByUid( const QString & );
201 201
202 202
203 /** 203 /**
204 Returns a list of all addressees in the address book. This list can 204 Returns a list of all addressees in the address book. This list can
205 be sorted with @ref KABC::AddresseeList for example. 205 be sorted with @ref KABC::AddresseeList for example.
206 */ 206 */
207 Addressee::List allAddressees(); 207 Addressee::List allAddressees();
208 208
209 /** 209 /**
210 Find all entries with the specified name in the address book. Returns 210 Find all entries with the specified name in the address book. Returns
211 an empty list, if no entries could be found. 211 an empty list, if no entries could be found.
212 */ 212 */
213 Addressee::List findByName( const QString & ); 213 Addressee::List findByName( const QString & );
214 214
215 /** 215 /**
216 Find all entries with the specified email address in the address book. 216 Find all entries with the specified email address in the address book.
217 Returns an empty list, if no entries could be found. 217 Returns an empty list, if no entries could be found.
218 */ 218 */
219 Addressee::List findByEmail( const QString & ); 219 Addressee::List findByEmail( const QString & );
220 220
221 /** 221 /**
222 Find all entries wich have the specified category in the address book. 222 Find all entries wich have the specified category in the address book.
223 Returns an empty list, if no entries could be found. 223 Returns an empty list, if no entries could be found.
224 */ 224 */
225 Addressee::List findByCategory( const QString & ); 225 Addressee::List findByCategory( const QString & );
226 226
227 /** 227 /**
228 Return a string identifying this addressbook. 228 Return a string identifying this addressbook.
229 */ 229 */
230 virtual QString identifier(); 230 virtual QString identifier();
231 231
232 /** 232 /**
233 Used for debug output. 233 Used for debug output.
234 */ 234 */
235 void dump() const; 235 void dump() const;
236 236
237 void emitAddressBookLocked() { emit addressBookLocked( this ); } 237 void emitAddressBookLocked() { emit addressBookLocked( this ); }
238 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 238 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
239 void emitAddressBookChanged() { emit addressBookChanged( this ); } 239 void emitAddressBookChanged() { emit addressBookChanged( this ); }
240 240
241 /** 241 /**
242 Return list of all Fields known to the address book which are associated 242 Return list of all Fields known to the address book which are associated
243 with the given field category. 243 with the given field category.
244 */ 244 */
245 Field::List fields( int category = Field::All ); 245 Field::List fields( int category = Field::All );
246 246
247 /** 247 /**
248 Add custom field to address book. 248 Add custom field to address book.
249 249
250 @param label User visible label of the field. 250 @param label User visible label of the field.
251 @param category Ored list of field categories. 251 @param category Ored list of field categories.
252 @param key Identifier used as key for reading and writing the field. 252 @param key Identifier used as key for reading and writing the field.
253 @param app String used as application key for reading and writing 253 @param app String used as application key for reading and writing
254 the field. 254 the field.
255 */ 255 */
256 bool addCustomField( const QString &label, int category = Field::All, 256 bool addCustomField( const QString &label, int category = Field::All,
257 const QString &key = QString::null, 257 const QString &key = QString::null,
258 const QString &app = QString::null ); 258 const QString &app = QString::null );
259 259
260 260
261 /** 261 /**
262 Add address book resource. 262 Add address book resource.
263 */ 263 */
264 bool addResource( Resource * ); 264 bool addResource( Resource * );
265 265
266 /** 266 /**
267 Remove address book resource. 267 Remove address book resource.
268 */ 268 */
269 bool removeResource( Resource * ); 269 bool removeResource( Resource * );
270 270
271 /** 271 /**
272 Return pointer list of all resources. 272 Return pointer list of all resources.
273 */ 273 */
274 QPtrList<Resource> resources(); 274 QPtrList<Resource> resources();
275 275
276 /** 276 /**
277 Set the @p ErrorHandler, that is used by @ref error() to 277 Set the @p ErrorHandler, that is used by @ref error() to
278 provide gui-independend error messages. 278 provide gui-independend error messages.
279 */ 279 */
280 void setErrorHandler( ErrorHandler * ); 280 void setErrorHandler( ErrorHandler * );
281 281
282 /** 282 /**
283 Shows gui independend error messages. 283 Shows gui independend error messages.
284 */ 284 */
285 void error( const QString& ); 285 void error( const QString& );
286 286
287 /** 287 /**
288 Query all resources to clean up their lock files 288 Query all resources to clean up their lock files
289 */ 289 */
290 void cleanUp(); 290 void cleanUp();
291 291
292 // sync stuff 292 // sync stuff
293 //Addressee::List getExternLastSyncAddressees(); 293 //Addressee::List getExternLastSyncAddressees();
294 void resetTempSyncStat(); 294 void resetTempSyncStat();
295 QStringList uidList(); 295 QStringList uidList();
296 void removeSyncAddressees( bool removeDeleted = false ); 296 void removeSyncAddressees( bool removeDeleted = false );
297 void mergeAB( AddressBook *aBook, const QString& profile ); 297 void mergeAB( AddressBook *aBook, const QString& profile );
298 Addressee findByExternUid( const QString& uid , const QString& profile ); 298 Addressee findByExternUid( const QString& uid , const QString& profile );
299 bool containsExternalUid( const QString& uid ); 299 bool containsExternalUid( const QString& uid );
300 300
301 void preExternSync( AddressBook* aBook, const QString& csd ); 301 void preExternSync( AddressBook* aBook, const QString& csd );
302 void postExternSync( AddressBook* aBook, const QString& csd ); 302 void postExternSync( AddressBook* aBook, const QString& csd );
303 signals: 303 signals:
304 /** 304 /**
305 Emitted, when the address book has changed on disk. 305 Emitted, when the address book has changed on disk.
306 */ 306 */
307 void addressBookChanged( AddressBook * ); 307 void addressBookChanged( AddressBook * );
308 308
309 /** 309 /**
310 Emitted, when the address book has been locked for writing. 310 Emitted, when the address book has been locked for writing.
311 */ 311 */
312 void addressBookLocked( AddressBook * ); 312 void addressBookLocked( AddressBook * );
313 313
314 /** 314 /**
315 Emitted, when the address book has been unlocked. 315 Emitted, when the address book has been unlocked.
316 */ 316 */
317 void addressBookUnlocked( AddressBook * ); 317 void addressBookUnlocked( AddressBook * );
318 318
319 protected: 319 protected:
320 void deleteRemovedAddressees(); 320 void deleteRemovedAddressees();
321 void setStandardResource( Resource * ); 321 void setStandardResource( Resource * );
322 Resource *standardResource(); 322 Resource *standardResource();
323 KRES::Manager<Resource> *resourceManager(); 323 KRES::Manager<Resource> *resourceManager();
324 324
325 void init(const QString &config, const QString &family); 325 void init(const QString &config, const QString &family);
326 326
327 private: 327 private:
328//US QPtrList<Resource> mDummy; // Remove in KDE 4 328//US QPtrList<Resource> mDummy; // Remove in KDE 4
329 329
330 330
331 struct AddressBookData; 331 struct AddressBookData;
332 AddressBookData *d; 332 AddressBookData *d;
333 bool blockLSEchange; 333 bool blockLSEchange;
334}; 334};
335 335
336QDataStream &operator<<( QDataStream &, const AddressBook & ); 336QDataStream &operator<<( QDataStream &, const AddressBook & );
337QDataStream &operator>>( QDataStream &, AddressBook & ); 337QDataStream &operator>>( QDataStream &, AddressBook & );
338 338
339} 339}
340 340
341#endif 341#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 19a1845..3f3d5c0 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -62,512 +62,529 @@ struct Addressee::AddresseeData : public KShared
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91}; 91};
92 92
93Addressee::Addressee() 93Addressee::Addressee()
94{ 94{
95 mData = new AddresseeData; 95 mData = new AddresseeData;
96 mData->empty = true; 96 mData->empty = true;
97 mData->changed = false; 97 mData->changed = false;
98 mData->resource = 0; 98 mData->resource = 0;
99 mData->mExternalId = ":"; 99 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 100 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 102}
103 103
104Addressee::~Addressee() 104Addressee::~Addressee()
105{ 105{
106} 106}
107 107
108Addressee::Addressee( const Addressee &a ) 108Addressee::Addressee( const Addressee &a )
109{ 109{
110 mData = a.mData; 110 mData = a.mData;
111} 111}
112 112
113Addressee &Addressee::operator=( const Addressee &a ) 113Addressee &Addressee::operator=( const Addressee &a )
114{ 114{
115 mData = a.mData; 115 mData = a.mData;
116 return (*this); 116 return (*this);
117} 117}
118 118
119Addressee Addressee::copy() 119Addressee Addressee::copy()
120{ 120{
121 Addressee a; 121 Addressee a;
122 *(a.mData) = *mData; 122 *(a.mData) = *mData;
123 return a; 123 return a;
124} 124}
125 125
126void Addressee::detach() 126void Addressee::detach()
127{ 127{
128 if ( mData.count() == 1 ) return; 128 if ( mData.count() == 1 ) return;
129 *this = copy(); 129 *this = copy();
130} 130}
131 131
132bool Addressee::operator==( const Addressee &a ) const 132bool Addressee::operator==( const Addressee &a ) const
133{ 133{
134 if ( uid() != a.uid() ) return false; 134 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 135 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 136 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 137 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 138 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 139 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 140 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 141 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 142 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 143 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 144 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 145 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 146 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 147 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 148 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 149 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 150 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 151 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 152 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 153 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 154 if ( mData->secrecy != a.mData->secrecy ) return false;
155 if ( mData->logo != a.mData->logo ) return false; 155 if ( mData->logo != a.mData->logo ) return false;
156 if ( mData->photo != a.mData->photo ) return false; 156 if ( mData->photo != a.mData->photo ) return false;
157 if ( mData->sound != a.mData->sound ) return false; 157 if ( mData->sound != a.mData->sound ) return false;
158 if ( mData->agent != a.mData->agent ) return false; 158 if ( mData->agent != a.mData->agent ) return false;
159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
160 ( mData->url != a.mData->url ) ) return false; 160 ( mData->url != a.mData->url ) ) return false;
161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
162 if ( mData->addresses != a.mData->addresses ) return false; 162 if ( mData->addresses != a.mData->addresses ) return false;
163 if ( mData->keys != a.mData->keys ) return false; 163 if ( mData->keys != a.mData->keys ) return false;
164 if ( mData->emails != a.mData->emails ) return false; 164 if ( mData->emails != a.mData->emails ) return false;
165 if ( mData->categories != a.mData->categories ) return false; 165 if ( mData->categories != a.mData->categories ) return false;
166 if ( mData->custom != a.mData->custom ) return false; 166 if ( mData->custom != a.mData->custom ) return false;
167 167
168 return true; 168 return true;
169} 169}
170 170
171bool Addressee::operator!=( const Addressee &a ) const 171bool Addressee::operator!=( const Addressee &a ) const
172{ 172{
173 return !( a == *this ); 173 return !( a == *this );
174} 174}
175 175
176bool Addressee::isEmpty() const 176bool Addressee::isEmpty() const
177{ 177{
178 return mData->empty; 178 return mData->empty;
179} 179}
180ulong Addressee::getCsum4List( const QStringList & attList) 180ulong Addressee::getCsum4List( const QStringList & attList)
181{ 181{
182 int max = attList.count(); 182 int max = attList.count();
183 ulong cSum = 0; 183 ulong cSum = 0;
184 int j,k,i; 184 int j,k,i;
185 int add; 185 int add;
186 for ( i = 0; i < max ; ++i ) { 186 for ( i = 0; i < max ; ++i ) {
187 QString s = attList[i]; 187 QString s = attList[i];
188 if ( ! s.isEmpty() ){ 188 if ( ! s.isEmpty() ){
189 j = s.length(); 189 j = s.length();
190 for ( k = 0; k < j; ++k ) { 190 for ( k = 0; k < j; ++k ) {
191 int mul = k +1; 191 int mul = k +1;
192 add = s[k].unicode (); 192 add = s[k].unicode ();
193 if ( k < 16 ) 193 if ( k < 16 )
194 mul = mul * mul; 194 mul = mul * mul;
195 int ii = i+1; 195 int ii = i+1;
196 add = add * mul *ii*ii*ii; 196 add = add * mul *ii*ii*ii;
197 cSum += add; 197 cSum += add;
198 } 198 }
199 } 199 }
200 200
201 } 201 }
202 //QString dump = attList.join(","); 202 //QString dump = attList.join(",");
203 //qDebug("csum: %d %s", cSum,dump.latin1()); 203 //qDebug("csum: %d %s", cSum,dump.latin1());
204 204
205 return cSum; 205 return cSum;
206 206
207} 207}
208void Addressee::computeCsum(const QString &dev) 208void Addressee::computeCsum(const QString &dev)
209{ 209{
210 QStringList l; 210 QStringList l;
211 if ( !mData->name.isEmpty() ) l.append(mData->name); 211 if ( !mData->name.isEmpty() ) l.append(mData->name);
212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
215 if ( !mData->additionalName ) l.append( mData->additionalName ); 215 if ( !mData->additionalName ) l.append( mData->additionalName );
216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
223 if ( !mData->title .isEmpty() ) l.append( mData->title ); 223 if ( !mData->title .isEmpty() ) l.append( mData->title );
224 if ( !mData->role.isEmpty() ) l.append( mData->role ); 224 if ( !mData->role.isEmpty() ) l.append( mData->role );
225 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 225 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
226 if ( !mData->note.isEmpty() ) l.append( mData->note ); 226 if ( !mData->note.isEmpty() ) l.append( mData->note );
227 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 227 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
230 // if ( !mData->logo.isEmpty() ) l.append( ); 230 // if ( !mData->logo.isEmpty() ) l.append( );
231 //if ( !mData->photo.isEmpty() ) l.append( ); 231 //if ( !mData->photo.isEmpty() ) l.append( );
232 //if ( !mData->sound.isEmpty() ) l.append( ); 232 //if ( !mData->sound.isEmpty() ) l.append( );
233 //if ( !mData->agent.isEmpty() ) l.append( ); 233 //if ( !mData->agent.isEmpty() ) l.append( );
234 //if ( mData->url.isValid() ) l.append( ); 234 //if ( mData->url.isValid() ) l.append( );
235#if 0 235#if 0
236 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 236 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
237 if ( !mData->addresses.isEmpty() ) l.append( ); 237 if ( !mData->addresses.isEmpty() ) l.append( );
238 //if ( !mData->keys.isEmpty() ) l.append( ); 238 //if ( !mData->keys.isEmpty() ) l.append( );
239 if ( !mData->emails.isEmpty() ) l.append( ); 239 if ( !mData->emails.isEmpty() ) l.append( );
240 if ( !mData->categories .isEmpty() ) l.append( ); 240 if ( !mData->categories .isEmpty() ) l.append( );
241 if ( !mData->custom.isEmpty() ) l.append( ); 241 if ( !mData->custom.isEmpty() ) l.append( );
242#endif 242#endif
243 KABC::PhoneNumber::List phoneNumbers; 243 KABC::PhoneNumber::List phoneNumbers;
244 KABC::PhoneNumber::List::Iterator phoneIter; 244 KABC::PhoneNumber::List::Iterator phoneIter;
245 245
246 QStringList t; 246 QStringList t;
247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
248 ++phoneIter ) 248 ++phoneIter )
249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
250 t.sort(); 250 t.sort();
251 uint iii; 251 uint iii;
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->emails; 254 t = mData->emails;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->categories; 258 t = mData->categories;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 t = mData->custom; 262 t = mData->custom;
263 t.sort(); 263 t.sort();
264 for ( iii = 0; iii < t.count(); ++iii) 264 for ( iii = 0; iii < t.count(); ++iii)
265 l.append( t[iii] ); 265 l.append( t[iii] );
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318bool Addressee::removeVoice()
319{
320 PhoneNumber::List phoneN = phoneNumbers();
321 PhoneNumber::List::Iterator phoneIt;
322 bool found = false;
323 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
324 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
325 if ((*phoneIt).type() - PhoneNumber::Voice ) {
326 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
327 insertPhoneNumber( (*phoneIt) );
328 found = true;
329 }
330 }
331
332 }
333 return found;
334}
318void Addressee::simplifyAddresses() 335void Addressee::simplifyAddresses()
319{ 336{
320 if ( mData->addresses.count() < 3 ) return ; 337 if ( mData->addresses.count() < 3 ) return ;
321 int count = 0; 338 int count = 0;
322 Address::List list; 339 Address::List list;
323 Address::List::Iterator it; 340 Address::List::Iterator it;
324 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 341 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
325 if ( count > 1 ) 342 if ( count > 1 )
326 list.append( *it ); 343 list.append( *it );
327 ++count; 344 ++count;
328 } 345 }
329 for( it = list.begin(); it != list.end(); ++it ) { 346 for( it = list.begin(); it != list.end(); ++it ) {
330 removeAddress( (*it) ); 347 removeAddress( (*it) );
331 } 348 }
332} 349}
333 350
334// removes all emails but the first 351// removes all emails but the first
335// needed by phone sync 352// needed by phone sync
336void Addressee::simplifyEmails() 353void Addressee::simplifyEmails()
337{ 354{
338 if ( mData->emails.count() == 0 ) return ; 355 if ( mData->emails.count() == 0 ) return ;
339 QString email = mData->emails.first(); 356 QString email = mData->emails.first();
340 detach(); 357 detach();
341 mData->emails.clear(); 358 mData->emails.clear();
342 mData->emails.append( email ); 359 mData->emails.append( email );
343} 360}
344 361
345void Addressee::simplifyPhoneNumbers() 362void Addressee::simplifyPhoneNumbers()
346{ 363{
347 KABC::PhoneNumber::List removeNumbers; 364 KABC::PhoneNumber::List removeNumbers;
348 KABC::PhoneNumber::List::Iterator phoneIter; 365 KABC::PhoneNumber::List::Iterator phoneIter;
349 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 366 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
350 ++phoneIter ) { 367 ++phoneIter ) {
351 if ( ! ( *phoneIter ).simplifyNumber() ) 368 if ( ! ( *phoneIter ).simplifyNumber() )
352 removeNumbers.append( ( *phoneIter ) ); 369 removeNumbers.append( ( *phoneIter ) );
353 } 370 }
354 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 371 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
355 ++phoneIter ) { 372 ++phoneIter ) {
356 removePhoneNumber(( *phoneIter )); 373 removePhoneNumber(( *phoneIter ));
357 } 374 }
358} 375}
359void Addressee::simplifyPhoneNumberTypes() 376void Addressee::simplifyPhoneNumberTypes()
360{ 377{
361 KABC::PhoneNumber::List::Iterator phoneIter; 378 KABC::PhoneNumber::List::Iterator phoneIter;
362 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 379 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
363 ++phoneIter ) 380 ++phoneIter )
364 ( *phoneIter ).simplifyType(); 381 ( *phoneIter ).simplifyType();
365} 382}
366void Addressee::removeID(const QString &prof) 383void Addressee::removeID(const QString &prof)
367{ 384{
368 detach(); 385 detach();
369 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 386 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
370 387
371} 388}
372void Addressee::setID( const QString & prof , const QString & id ) 389void Addressee::setID( const QString & prof , const QString & id )
373{ 390{
374 detach(); 391 detach();
375 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 392 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
376 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 393 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
377} 394}
378void Addressee::setTempSyncStat( int id ) 395void Addressee::setTempSyncStat( int id )
379{ 396{
380 if ( mData->mTempSyncStat == id ) return; 397 if ( mData->mTempSyncStat == id ) return;
381 detach(); 398 detach();
382 mData->mTempSyncStat = id; 399 mData->mTempSyncStat = id;
383} 400}
384int Addressee::tempSyncStat() const 401int Addressee::tempSyncStat() const
385{ 402{
386 return mData->mTempSyncStat; 403 return mData->mTempSyncStat;
387} 404}
388 405
389QString Addressee::getID( const QString & prof) 406QString Addressee::getID( const QString & prof)
390{ 407{
391 return KIdManager::getId ( mData->mExternalId, prof ); 408 return KIdManager::getId ( mData->mExternalId, prof );
392} 409}
393 410
394void Addressee::setCsum( const QString & prof , const QString & id ) 411void Addressee::setCsum( const QString & prof , const QString & id )
395{ 412{
396 detach(); 413 detach();
397 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 414 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
398 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 415 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
399 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 416 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
400} 417}
401 418
402QString Addressee::getCsum( const QString & prof) 419QString Addressee::getCsum( const QString & prof)
403{ 420{
404 return KIdManager::getCsum ( mData->mExternalId, prof ); 421 return KIdManager::getCsum ( mData->mExternalId, prof );
405} 422}
406 423
407void Addressee::setIDStr( const QString & s ) 424void Addressee::setIDStr( const QString & s )
408{ 425{
409 detach(); 426 detach();
410 mData->mExternalId = s; 427 mData->mExternalId = s;
411} 428}
412 429
413QString Addressee::IDStr() const 430QString Addressee::IDStr() const
414{ 431{
415 return mData->mExternalId; 432 return mData->mExternalId;
416} 433}
417 434
418void Addressee::setExternalUID( const QString &id ) 435void Addressee::setExternalUID( const QString &id )
419{ 436{
420 if ( id == mData->externalUID ) return; 437 if ( id == mData->externalUID ) return;
421 detach(); 438 detach();
422 mData->empty = false; 439 mData->empty = false;
423 mData->externalUID = id; 440 mData->externalUID = id;
424} 441}
425 442
426QString Addressee::externalUID() const 443QString Addressee::externalUID() const
427{ 444{
428 return mData->externalUID; 445 return mData->externalUID;
429} 446}
430void Addressee::setOriginalExternalUID( const QString &id ) 447void Addressee::setOriginalExternalUID( const QString &id )
431{ 448{
432 if ( id == mData->originalExternalUID ) return; 449 if ( id == mData->originalExternalUID ) return;
433 detach(); 450 detach();
434 mData->empty = false; 451 mData->empty = false;
435 //qDebug("*******Set orig uid %s ", id.latin1()); 452 //qDebug("*******Set orig uid %s ", id.latin1());
436 mData->originalExternalUID = id; 453 mData->originalExternalUID = id;
437} 454}
438 455
439QString Addressee::originalExternalUID() const 456QString Addressee::originalExternalUID() const
440{ 457{
441 return mData->originalExternalUID; 458 return mData->originalExternalUID;
442} 459}
443 460
444void Addressee::setUid( const QString &id ) 461void Addressee::setUid( const QString &id )
445{ 462{
446 if ( id == mData->uid ) return; 463 if ( id == mData->uid ) return;
447 detach(); 464 detach();
448 //qDebug("****setuid %s ", id.latin1()); 465 //qDebug("****setuid %s ", id.latin1());
449 mData->empty = false; 466 mData->empty = false;
450 mData->uid = id; 467 mData->uid = id;
451} 468}
452 469
453QString Addressee::uid() const 470QString Addressee::uid() const
454{ 471{
455 if ( mData->uid.isEmpty() ) 472 if ( mData->uid.isEmpty() )
456 mData->uid = KApplication::randomString( 10 ); 473 mData->uid = KApplication::randomString( 10 );
457 474
458 return mData->uid; 475 return mData->uid;
459} 476}
460 477
461QString Addressee::uidLabel() 478QString Addressee::uidLabel()
462{ 479{
463 return i18n("Unique Identifier"); 480 return i18n("Unique Identifier");
464} 481}
465 482
466void Addressee::setName( const QString &name ) 483void Addressee::setName( const QString &name )
467{ 484{
468 if ( name == mData->name ) return; 485 if ( name == mData->name ) return;
469 detach(); 486 detach();
470 mData->empty = false; 487 mData->empty = false;
471 mData->name = name; 488 mData->name = name;
472} 489}
473 490
474QString Addressee::name() const 491QString Addressee::name() const
475{ 492{
476 return mData->name; 493 return mData->name;
477} 494}
478 495
479QString Addressee::nameLabel() 496QString Addressee::nameLabel()
480{ 497{
481 return i18n("Name"); 498 return i18n("Name");
482} 499}
483 500
484 501
485void Addressee::setFormattedName( const QString &formattedName ) 502void Addressee::setFormattedName( const QString &formattedName )
486{ 503{
487 if ( formattedName == mData->formattedName ) return; 504 if ( formattedName == mData->formattedName ) return;
488 detach(); 505 detach();
489 mData->empty = false; 506 mData->empty = false;
490 mData->formattedName = formattedName; 507 mData->formattedName = formattedName;
491} 508}
492 509
493QString Addressee::formattedName() const 510QString Addressee::formattedName() const
494{ 511{
495 return mData->formattedName; 512 return mData->formattedName;
496} 513}
497 514
498QString Addressee::formattedNameLabel() 515QString Addressee::formattedNameLabel()
499{ 516{
500 return i18n("Formatted Name"); 517 return i18n("Formatted Name");
501} 518}
502 519
503 520
504void Addressee::setFamilyName( const QString &familyName ) 521void Addressee::setFamilyName( const QString &familyName )
505{ 522{
506 if ( familyName == mData->familyName ) return; 523 if ( familyName == mData->familyName ) return;
507 detach(); 524 detach();
508 mData->empty = false; 525 mData->empty = false;
509 mData->familyName = familyName; 526 mData->familyName = familyName;
510} 527}
511 528
512QString Addressee::familyName() const 529QString Addressee::familyName() const
513{ 530{
514 return mData->familyName; 531 return mData->familyName;
515} 532}
516 533
517QString Addressee::familyNameLabel() 534QString Addressee::familyNameLabel()
518{ 535{
519 return i18n("Family Name"); 536 return i18n("Family Name");
520} 537}
521 538
522 539
523void Addressee::setGivenName( const QString &givenName ) 540void Addressee::setGivenName( const QString &givenName )
524{ 541{
525 if ( givenName == mData->givenName ) return; 542 if ( givenName == mData->givenName ) return;
526 detach(); 543 detach();
527 mData->empty = false; 544 mData->empty = false;
528 mData->givenName = givenName; 545 mData->givenName = givenName;
529} 546}
530 547
531QString Addressee::givenName() const 548QString Addressee::givenName() const
532{ 549{
533 return mData->givenName; 550 return mData->givenName;
534} 551}
535 552
536QString Addressee::givenNameLabel() 553QString Addressee::givenNameLabel()
537{ 554{
538 return i18n("Given Name"); 555 return i18n("Given Name");
539} 556}
540 557
541 558
542void Addressee::setAdditionalName( const QString &additionalName ) 559void Addressee::setAdditionalName( const QString &additionalName )
543{ 560{
544 if ( additionalName == mData->additionalName ) return; 561 if ( additionalName == mData->additionalName ) return;
545 detach(); 562 detach();
546 mData->empty = false; 563 mData->empty = false;
547 mData->additionalName = additionalName; 564 mData->additionalName = additionalName;
548} 565}
549 566
550QString Addressee::additionalName() const 567QString Addressee::additionalName() const
551{ 568{
552 return mData->additionalName; 569 return mData->additionalName;
553} 570}
554 571
555QString Addressee::additionalNameLabel() 572QString Addressee::additionalNameLabel()
556{ 573{
557 return i18n("Additional Names"); 574 return i18n("Additional Names");
558} 575}
559 576
560 577
561void Addressee::setPrefix( const QString &prefix ) 578void Addressee::setPrefix( const QString &prefix )
562{ 579{
563 if ( prefix == mData->prefix ) return; 580 if ( prefix == mData->prefix ) return;
564 detach(); 581 detach();
565 mData->empty = false; 582 mData->empty = false;
566 mData->prefix = prefix; 583 mData->prefix = prefix;
567} 584}
568 585
569QString Addressee::prefix() const 586QString Addressee::prefix() const
570{ 587{
571 return mData->prefix; 588 return mData->prefix;
572} 589}
573 590
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 44f0629..9336edc 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,379 +1,380 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice();
124 125
125 /** 126 /**
126 Set unique identifier. 127 Set unique identifier.
127 */ 128 */
128 void setUid( const QString &uid ); 129 void setUid( const QString &uid );
129 /** 130 /**
130 Return unique identifier. 131 Return unique identifier.
131 */ 132 */
132 QString uid() const; 133 QString uid() const;
133 /** 134 /**
134 Return translated label for uid field. 135 Return translated label for uid field.
135 */ 136 */
136 static QString uidLabel(); 137 static QString uidLabel();
137 138
138 /** 139 /**
139 Set name. 140 Set name.
140 */ 141 */
141 void setName( const QString &name ); 142 void setName( const QString &name );
142 /** 143 /**
143 Return name. 144 Return name.
144 */ 145 */
145 QString name() const; 146 QString name() const;
146 /** 147 /**
147 Return translated label for name field. 148 Return translated label for name field.
148 */ 149 */
149 static QString nameLabel(); 150 static QString nameLabel();
150 151
151 /** 152 /**
152 Set formatted name. 153 Set formatted name.
153 */ 154 */
154 void setFormattedName( const QString &formattedName ); 155 void setFormattedName( const QString &formattedName );
155 /** 156 /**
156 Return formatted name. 157 Return formatted name.
157 */ 158 */
158 QString formattedName() const; 159 QString formattedName() const;
159 /** 160 /**
160 Return translated label for formattedName field. 161 Return translated label for formattedName field.
161 */ 162 */
162 static QString formattedNameLabel(); 163 static QString formattedNameLabel();
163 164
164 /** 165 /**
165 Set family name. 166 Set family name.
166 */ 167 */
167 void setFamilyName( const QString &familyName ); 168 void setFamilyName( const QString &familyName );
168 /** 169 /**
169 Return family name. 170 Return family name.
170 */ 171 */
171 QString familyName() const; 172 QString familyName() const;
172 /** 173 /**
173 Return translated label for familyName field. 174 Return translated label for familyName field.
174 */ 175 */
175 static QString familyNameLabel(); 176 static QString familyNameLabel();
176 177
177 /** 178 /**
178 Set given name. 179 Set given name.
179 */ 180 */
180 void setGivenName( const QString &givenName ); 181 void setGivenName( const QString &givenName );
181 /** 182 /**
182 Return given name. 183 Return given name.
183 */ 184 */
184 QString givenName() const; 185 QString givenName() const;
185 /** 186 /**
186 Return translated label for givenName field. 187 Return translated label for givenName field.
187 */ 188 */
188 static QString givenNameLabel(); 189 static QString givenNameLabel();
189 190
190 /** 191 /**
191 Set additional names. 192 Set additional names.
192 */ 193 */
193 void setAdditionalName( const QString &additionalName ); 194 void setAdditionalName( const QString &additionalName );
194 /** 195 /**
195 Return additional names. 196 Return additional names.
196 */ 197 */
197 QString additionalName() const; 198 QString additionalName() const;
198 /** 199 /**
199 Return translated label for additionalName field. 200 Return translated label for additionalName field.
200 */ 201 */
201 static QString additionalNameLabel(); 202 static QString additionalNameLabel();
202 203
203 /** 204 /**
204 Set honorific prefixes. 205 Set honorific prefixes.
205 */ 206 */
206 void setPrefix( const QString &prefix ); 207 void setPrefix( const QString &prefix );
207 /** 208 /**
208 Return honorific prefixes. 209 Return honorific prefixes.
209 */ 210 */
210 QString prefix() const; 211 QString prefix() const;
211 /** 212 /**
212 Return translated label for prefix field. 213 Return translated label for prefix field.
213 */ 214 */
214 static QString prefixLabel(); 215 static QString prefixLabel();
215 216
216 /** 217 /**
217 Set honorific suffixes. 218 Set honorific suffixes.
218 */ 219 */
219 void setSuffix( const QString &suffix ); 220 void setSuffix( const QString &suffix );
220 /** 221 /**
221 Return honorific suffixes. 222 Return honorific suffixes.
222 */ 223 */
223 QString suffix() const; 224 QString suffix() const;
224 /** 225 /**
225 Return translated label for suffix field. 226 Return translated label for suffix field.
226 */ 227 */
227 static QString suffixLabel(); 228 static QString suffixLabel();
228 229
229 /** 230 /**
230 Set nick name. 231 Set nick name.
231 */ 232 */
232 void setNickName( const QString &nickName ); 233 void setNickName( const QString &nickName );
233 /** 234 /**
234 Return nick name. 235 Return nick name.
235 */ 236 */
236 QString nickName() const; 237 QString nickName() const;
237 /** 238 /**
238 Return translated label for nickName field. 239 Return translated label for nickName field.
239 */ 240 */
240 static QString nickNameLabel(); 241 static QString nickNameLabel();
241 242
242 /** 243 /**
243 Set birthday. 244 Set birthday.
244 */ 245 */
245 void setBirthday( const QDateTime &birthday ); 246 void setBirthday( const QDateTime &birthday );
246 /** 247 /**
247 Return birthday. 248 Return birthday.
248 */ 249 */
249 QDateTime birthday() const; 250 QDateTime birthday() const;
250 /** 251 /**
251 Return translated label for birthday field. 252 Return translated label for birthday field.
252 */ 253 */
253 static QString birthdayLabel(); 254 static QString birthdayLabel();
254 255
255 /** 256 /**
256 Return translated label for homeAddressStreet field. 257 Return translated label for homeAddressStreet field.
257 */ 258 */
258 static QString homeAddressStreetLabel(); 259 static QString homeAddressStreetLabel();
259 260
260 /** 261 /**
261 Return translated label for homeAddressLocality field. 262 Return translated label for homeAddressLocality field.
262 */ 263 */
263 static QString homeAddressLocalityLabel(); 264 static QString homeAddressLocalityLabel();
264 265
265 /** 266 /**
266 Return translated label for homeAddressRegion field. 267 Return translated label for homeAddressRegion field.
267 */ 268 */
268 static QString homeAddressRegionLabel(); 269 static QString homeAddressRegionLabel();
269 270
270 /** 271 /**
271 Return translated label for homeAddressPostalCode field. 272 Return translated label for homeAddressPostalCode field.
272 */ 273 */
273 static QString homeAddressPostalCodeLabel(); 274 static QString homeAddressPostalCodeLabel();
274 275
275 /** 276 /**
276 Return translated label for homeAddressCountry field. 277 Return translated label for homeAddressCountry field.
277 */ 278 */
278 static QString homeAddressCountryLabel(); 279 static QString homeAddressCountryLabel();
279 280
280 /** 281 /**
281 Return translated label for homeAddressLabel field. 282 Return translated label for homeAddressLabel field.
282 */ 283 */
283 static QString homeAddressLabelLabel(); 284 static QString homeAddressLabelLabel();
284 285
285 /** 286 /**
286 Return translated label for businessAddressStreet field. 287 Return translated label for businessAddressStreet field.
287 */ 288 */
288 static QString businessAddressStreetLabel(); 289 static QString businessAddressStreetLabel();
289 290
290 /** 291 /**
291 Return translated label for businessAddressLocality field. 292 Return translated label for businessAddressLocality field.
292 */ 293 */
293 static QString businessAddressLocalityLabel(); 294 static QString businessAddressLocalityLabel();
294 295
295 /** 296 /**
296 Return translated label for businessAddressRegion field. 297 Return translated label for businessAddressRegion field.
297 */ 298 */
298 static QString businessAddressRegionLabel(); 299 static QString businessAddressRegionLabel();
299 300
300 /** 301 /**
301 Return translated label for businessAddressPostalCode field. 302 Return translated label for businessAddressPostalCode field.
302 */ 303 */
303 static QString businessAddressPostalCodeLabel(); 304 static QString businessAddressPostalCodeLabel();
304 305
305 /** 306 /**
306 Return translated label for businessAddressCountry field. 307 Return translated label for businessAddressCountry field.
307 */ 308 */
308 static QString businessAddressCountryLabel(); 309 static QString businessAddressCountryLabel();
309 310
310 /** 311 /**
311 Return translated label for businessAddressLabel field. 312 Return translated label for businessAddressLabel field.
312 */ 313 */
313 static QString businessAddressLabelLabel(); 314 static QString businessAddressLabelLabel();
314 315
315 /** 316 /**
316 Return translated label for homePhone field. 317 Return translated label for homePhone field.
317 */ 318 */
318 static QString homePhoneLabel(); 319 static QString homePhoneLabel();
319 320
320 /** 321 /**
321 Return translated label for businessPhone field. 322 Return translated label for businessPhone field.
322 */ 323 */
323 static QString businessPhoneLabel(); 324 static QString businessPhoneLabel();
324 325
325 /** 326 /**
326 Return translated label for mobilePhone field. 327 Return translated label for mobilePhone field.
327 */ 328 */
328 static QString mobilePhoneLabel(); 329 static QString mobilePhoneLabel();
329 330
330 /** 331 /**
331 Return translated label for homeFax field. 332 Return translated label for homeFax field.
332 */ 333 */
333 static QString homeFaxLabel(); 334 static QString homeFaxLabel();
334 335
335 /** 336 /**
336 Return translated label for businessFax field. 337 Return translated label for businessFax field.
337 */ 338 */
338 static QString businessFaxLabel(); 339 static QString businessFaxLabel();
339 340
340 /** 341 /**
341 Return translated label for carPhone field. 342 Return translated label for carPhone field.
342 */ 343 */
343 static QString carPhoneLabel(); 344 static QString carPhoneLabel();
344 345
345 /** 346 /**
346 Return translated label for isdn field. 347 Return translated label for isdn field.
347 */ 348 */
348 static QString isdnLabel(); 349 static QString isdnLabel();
349 350
350 /** 351 /**
351 Return translated label for pager field. 352 Return translated label for pager field.
352 */ 353 */
353 static QString pagerLabel(); 354 static QString pagerLabel();
354 355
355 /** 356 /**
356 Return translated label for sip field. 357 Return translated label for sip field.
357 */ 358 */
358 static QString sipLabel(); 359 static QString sipLabel();
359 360
360 /** 361 /**
361 Return translated label for email field. 362 Return translated label for email field.
362 */ 363 */
363 static QString emailLabel(); 364 static QString emailLabel();
364 365
365 /** 366 /**
366 Set mail client. 367 Set mail client.
367 */ 368 */
368 void setMailer( const QString &mailer ); 369 void setMailer( const QString &mailer );
369 /** 370 /**
370 Return mail client. 371 Return mail client.
371 */ 372 */
372 QString mailer() const; 373 QString mailer() const;
373 /** 374 /**
374 Return translated label for mailer field. 375 Return translated label for mailer field.
375 */ 376 */
376 static QString mailerLabel(); 377 static QString mailerLabel();
377 378
378 /** 379 /**
379 Set time zone. 380 Set time zone.
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9b059d3..3a542ba 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -72,512 +72,518 @@ $Id$
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 lay->addWidget( mWriteToSim ); 189 lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325 325
326} 326}
327 327
328void KABCore::recieve( QString fn )
329{
330 qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true );
332 topLevelWidget()->raise();
333}
328void KABCore::restoreSettings() 334void KABCore::restoreSettings()
329{ 335{
330 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 336 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
331 337
332 bool state; 338 bool state;
333 339
334 if (mMultipleViewsAtOnce) 340 if (mMultipleViewsAtOnce)
335 state = KABPrefs::instance()->mDetailsPageVisible; 341 state = KABPrefs::instance()->mDetailsPageVisible;
336 else 342 else
337 state = false; 343 state = false;
338 344
339 mActionDetails->setChecked( state ); 345 mActionDetails->setChecked( state );
340 setDetailsVisible( state ); 346 setDetailsVisible( state );
341 347
342 state = KABPrefs::instance()->mJumpButtonBarVisible; 348 state = KABPrefs::instance()->mJumpButtonBarVisible;
343 349
344 mActionJumpBar->setChecked( state ); 350 mActionJumpBar->setChecked( state );
345 setJumpButtonBarVisible( state ); 351 setJumpButtonBarVisible( state );
346/*US 352/*US
347 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 353 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
348 if ( splitterSize.count() == 0 ) { 354 if ( splitterSize.count() == 0 ) {
349 splitterSize.append( width() / 2 ); 355 splitterSize.append( width() / 2 );
350 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
351 } 357 }
352 mMiniSplitter->setSizes( splitterSize ); 358 mMiniSplitter->setSizes( splitterSize );
353 if ( mExtensionBarSplitter ) { 359 if ( mExtensionBarSplitter ) {
354 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 360 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
355 if ( splitterSize.count() == 0 ) { 361 if ( splitterSize.count() == 0 ) {
356 splitterSize.append( width() / 2 ); 362 splitterSize.append( width() / 2 );
357 splitterSize.append( width() / 2 ); 363 splitterSize.append( width() / 2 );
358 } 364 }
359 mExtensionBarSplitter->setSizes( splitterSize ); 365 mExtensionBarSplitter->setSizes( splitterSize );
360 366
361 } 367 }
362*/ 368*/
363 mViewManager->restoreSettings(); 369 mViewManager->restoreSettings();
364 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 370 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
365 mExtensionManager->restoreSettings(); 371 mExtensionManager->restoreSettings();
366#ifdef DESKTOP_VERSION 372#ifdef DESKTOP_VERSION
367 int wid = width(); 373 int wid = width();
368 if ( wid < 10 ) 374 if ( wid < 10 )
369 wid = 400; 375 wid = 400;
370#else 376#else
371 int wid = QApplication::desktop()->width(); 377 int wid = QApplication::desktop()->width();
372 if ( wid < 640 ) 378 if ( wid < 640 )
373 wid = QApplication::desktop()->height(); 379 wid = QApplication::desktop()->height();
374#endif 380#endif
375 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 381 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
376 if ( true /*splitterSize.count() == 0*/ ) { 382 if ( true /*splitterSize.count() == 0*/ ) {
377 splitterSize.append( wid / 2 ); 383 splitterSize.append( wid / 2 );
378 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
379 } 385 }
380 mMiniSplitter->setSizes( splitterSize ); 386 mMiniSplitter->setSizes( splitterSize );
381 if ( mExtensionBarSplitter ) { 387 if ( mExtensionBarSplitter ) {
382 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 388 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
383 if ( true /*splitterSize.count() == 0*/ ) { 389 if ( true /*splitterSize.count() == 0*/ ) {
384 splitterSize.append( wid / 2 ); 390 splitterSize.append( wid / 2 );
385 splitterSize.append( wid / 2 ); 391 splitterSize.append( wid / 2 );
386 } 392 }
387 mExtensionBarSplitter->setSizes( splitterSize ); 393 mExtensionBarSplitter->setSizes( splitterSize );
388 394
389 } 395 }
390 396
391 397
392} 398}
393 399
394void KABCore::saveSettings() 400void KABCore::saveSettings()
395{ 401{
396 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 402 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
397 if ( mExtensionBarSplitter ) 403 if ( mExtensionBarSplitter )
398 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 404 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
399 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 405 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
400 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 406 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
401#ifndef KAB_EMBEDDED 407#ifndef KAB_EMBEDDED
402 408
403 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 409 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
404 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 410 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
405#endif //KAB_EMBEDDED 411#endif //KAB_EMBEDDED
406 mExtensionManager->saveSettings(); 412 mExtensionManager->saveSettings();
407 mViewManager->saveSettings(); 413 mViewManager->saveSettings();
408 414
409 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 415 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
410} 416}
411 417
412KABC::AddressBook *KABCore::addressBook() const 418KABC::AddressBook *KABCore::addressBook() const
413{ 419{
414 return mAddressBook; 420 return mAddressBook;
415} 421}
416 422
417KConfig *KABCore::config() 423KConfig *KABCore::config()
418{ 424{
419#ifndef KAB_EMBEDDED 425#ifndef KAB_EMBEDDED
420 return KABPrefs::instance()->config(); 426 return KABPrefs::instance()->config();
421#else //KAB_EMBEDDED 427#else //KAB_EMBEDDED
422 return KABPrefs::instance()->getConfig(); 428 return KABPrefs::instance()->getConfig();
423#endif //KAB_EMBEDDED 429#endif //KAB_EMBEDDED
424} 430}
425 431
426KActionCollection *KABCore::actionCollection() const 432KActionCollection *KABCore::actionCollection() const
427{ 433{
428 return mGUIClient->actionCollection(); 434 return mGUIClient->actionCollection();
429} 435}
430 436
431KABC::Field *KABCore::currentSearchField() const 437KABC::Field *KABCore::currentSearchField() const
432{ 438{
433 if (mIncSearchWidget) 439 if (mIncSearchWidget)
434 return mIncSearchWidget->currentField(); 440 return mIncSearchWidget->currentField();
435 else 441 else
436 return 0; 442 return 0;
437} 443}
438 444
439QStringList KABCore::selectedUIDs() const 445QStringList KABCore::selectedUIDs() const
440{ 446{
441 return mViewManager->selectedUids(); 447 return mViewManager->selectedUids();
442} 448}
443 449
444KABC::Resource *KABCore::requestResource( QWidget *parent ) 450KABC::Resource *KABCore::requestResource( QWidget *parent )
445{ 451{
446 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 452 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
447 453
448 QPtrList<KRES::Resource> kresResources; 454 QPtrList<KRES::Resource> kresResources;
449 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 455 QPtrListIterator<KABC::Resource> resIt( kabcResources );
450 KABC::Resource *resource; 456 KABC::Resource *resource;
451 while ( ( resource = resIt.current() ) != 0 ) { 457 while ( ( resource = resIt.current() ) != 0 ) {
452 ++resIt; 458 ++resIt;
453 if ( !resource->readOnly() ) { 459 if ( !resource->readOnly() ) {
454 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 460 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
455 if ( res ) 461 if ( res )
456 kresResources.append( res ); 462 kresResources.append( res );
457 } 463 }
458 } 464 }
459 465
460 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 466 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
461 return static_cast<KABC::Resource*>( res ); 467 return static_cast<KABC::Resource*>( res );
462} 468}
463 469
464#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
465KAboutData *KABCore::createAboutData() 471KAboutData *KABCore::createAboutData()
466#else //KAB_EMBEDDED 472#else //KAB_EMBEDDED
467void KABCore::createAboutData() 473void KABCore::createAboutData()
468#endif //KAB_EMBEDDED 474#endif //KAB_EMBEDDED
469{ 475{
470#ifndef KAB_EMBEDDED 476#ifndef KAB_EMBEDDED
471 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 477 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
472 "3.1", I18N_NOOP( "The KDE Address Book" ), 478 "3.1", I18N_NOOP( "The KDE Address Book" ),
473 KAboutData::License_GPL_V2, 479 KAboutData::License_GPL_V2,
474 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 480 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
475 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 481 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
476 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 482 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
477 about->addAuthor( "Cornelius Schumacher", 483 about->addAuthor( "Cornelius Schumacher",
478 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 484 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
479 "schumacher@kde.org" ); 485 "schumacher@kde.org" );
480 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 486 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
481 "mpilone@slac.com" ); 487 "mpilone@slac.com" );
482 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 488 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
483 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 489 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
484 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 490 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
485 "michel@klaralvdalens-datakonsult.se" ); 491 "michel@klaralvdalens-datakonsult.se" );
486 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 492 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
487 "hansen@kde.org" ); 493 "hansen@kde.org" );
488 494
489 return about; 495 return about;
490#endif //KAB_EMBEDDED 496#endif //KAB_EMBEDDED
491 497
492 QString version; 498 QString version;
493#include <../version> 499#include <../version>
494 QMessageBox::about( this, "About KAddressbook/Pi", 500 QMessageBox::about( this, "About KAddressbook/Pi",
495 "KAddressbook/Platform-independent\n" 501 "KAddressbook/Platform-independent\n"
496 "(KA/Pi) " +version + " - " + 502 "(KA/Pi) " +version + " - " +
497#ifdef DESKTOP_VERSION 503#ifdef DESKTOP_VERSION
498 "Desktop Edition\n" 504 "Desktop Edition\n"
499#else 505#else
500 "PDA-Edition\n" 506 "PDA-Edition\n"
501 "for: Zaurus 5500 / 7x0 / 8x0\n" 507 "for: Zaurus 5500 / 7x0 / 8x0\n"
502#endif 508#endif
503 509
504 "(c) 2004 Ulf Schenk\n" 510 "(c) 2004 Ulf Schenk\n"
505 "(c) 2004 Lutz Rogowski\n" 511 "(c) 2004 Lutz Rogowski\n"
506 "(c) 1997-2003, The KDE PIM Team\n" 512 "(c) 1997-2003, The KDE PIM Team\n"
507 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 513 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
508 "Don Sanders Original author\n" 514 "Don Sanders Original author\n"
509 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 515 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
510 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 516 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
511 "Greg Stern DCOP interface\n" 517 "Greg Stern DCOP interface\n"
512 "Mark Westcot Contact pinning\n" 518 "Mark Westcot Contact pinning\n"
513 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 519 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
514 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 520 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
515#ifdef _WIN32_ 521#ifdef _WIN32_
516 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 522 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
517#endif 523#endif
518 ); 524 );
519} 525}
520 526
521void KABCore::setContactSelected( const QString &uid ) 527void KABCore::setContactSelected( const QString &uid )
522{ 528{
523 KABC::Addressee addr = mAddressBook->findByUid( uid ); 529 KABC::Addressee addr = mAddressBook->findByUid( uid );
524 if ( !mDetails->isHidden() ) 530 if ( !mDetails->isHidden() )
525 mDetails->setAddressee( addr ); 531 mDetails->setAddressee( addr );
526 532
527 if ( !addr.isEmpty() ) { 533 if ( !addr.isEmpty() ) {
528 emit contactSelected( addr.formattedName() ); 534 emit contactSelected( addr.formattedName() );
529 KABC::Picture pic = addr.photo(); 535 KABC::Picture pic = addr.photo();
530 if ( pic.isIntern() ) { 536 if ( pic.isIntern() ) {
531//US emit contactSelected( pic.data() ); 537//US emit contactSelected( pic.data() );
532//US instead use: 538//US instead use:
533 QPixmap px; 539 QPixmap px;
534 if (pic.data().isNull() != true) 540 if (pic.data().isNull() != true)
535 { 541 {
536 px.convertFromImage(pic.data()); 542 px.convertFromImage(pic.data());
537 } 543 }
538 544
539 emit contactSelected( px ); 545 emit contactSelected( px );
540 } 546 }
541 } 547 }
542 548
543 549
544 mExtensionManager->setSelectionChanged(); 550 mExtensionManager->setSelectionChanged();
545 551
546 // update the actions 552 // update the actions
547 bool selected = !uid.isEmpty(); 553 bool selected = !uid.isEmpty();
548 554
549 if ( mReadWrite ) { 555 if ( mReadWrite ) {
550 mActionCut->setEnabled( selected ); 556 mActionCut->setEnabled( selected );
551 mActionPaste->setEnabled( selected ); 557 mActionPaste->setEnabled( selected );
552 } 558 }
553 559
554 mActionCopy->setEnabled( selected ); 560 mActionCopy->setEnabled( selected );
555 mActionDelete->setEnabled( selected ); 561 mActionDelete->setEnabled( selected );
556 mActionEditAddressee->setEnabled( selected ); 562 mActionEditAddressee->setEnabled( selected );
557 mActionMail->setEnabled( selected ); 563 mActionMail->setEnabled( selected );
558 mActionMailVCard->setEnabled( selected ); 564 mActionMailVCard->setEnabled( selected );
559 //if (mActionBeam) 565 //if (mActionBeam)
560 //mActionBeam->setEnabled( selected ); 566 //mActionBeam->setEnabled( selected );
561 567
562 if (mActionBeamVCard) 568 if (mActionBeamVCard)
563 mActionBeamVCard->setEnabled( selected ); 569 mActionBeamVCard->setEnabled( selected );
564 570
565 mActionExport2phone->setEnabled( selected ); 571 mActionExport2phone->setEnabled( selected );
566 mActionWhoAmI->setEnabled( selected ); 572 mActionWhoAmI->setEnabled( selected );
567 mActionCategories->setEnabled( selected ); 573 mActionCategories->setEnabled( selected );
568} 574}
569 575
570void KABCore::sendMail() 576void KABCore::sendMail()
571{ 577{
572 sendMail( mViewManager->selectedEmails().join( ", " ) ); 578 sendMail( mViewManager->selectedEmails().join( ", " ) );
573} 579}
574 580
575void KABCore::sendMail( const QString& emaillist ) 581void KABCore::sendMail( const QString& emaillist )
576{ 582{
577 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 583 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
578 if (emaillist.contains(",") > 0) 584 if (emaillist.contains(",") > 0)
579 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 585 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
580 else 586 else
581 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 587 ExternalAppHandler::instance()->mailToOneContact( emaillist );
582} 588}
583 589
@@ -1833,526 +1839,514 @@ void KABCore::initActions()
1833 mActionRedo->setEnabled( false ); 1839 mActionRedo->setEnabled( false );
1834 1840
1835 // settings menu 1841 // settings menu
1836#ifdef KAB_EMBEDDED 1842#ifdef KAB_EMBEDDED
1837//US special menuentry to configure the addressbook resources. On KDE 1843//US special menuentry to configure the addressbook resources. On KDE
1838// you do that through the control center !!! 1844// you do that through the control center !!!
1839 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1845 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1840 SLOT( configureResources() ), actionCollection(), 1846 SLOT( configureResources() ), actionCollection(),
1841 "kaddressbook_configure_resources" ); 1847 "kaddressbook_configure_resources" );
1842#endif //KAB_EMBEDDED 1848#endif //KAB_EMBEDDED
1843 1849
1844 if ( mIsPart ) { 1850 if ( mIsPart ) {
1845 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1851 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1846 SLOT( openConfigDialog() ), actionCollection(), 1852 SLOT( openConfigDialog() ), actionCollection(),
1847 "kaddressbook_configure" ); 1853 "kaddressbook_configure" );
1848 1854
1849 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1855 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1850 this, SLOT( configureKeyBindings() ), actionCollection(), 1856 this, SLOT( configureKeyBindings() ), actionCollection(),
1851 "kaddressbook_configure_shortcuts" ); 1857 "kaddressbook_configure_shortcuts" );
1852#ifdef KAB_EMBEDDED 1858#ifdef KAB_EMBEDDED
1853 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1859 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1854 mActionConfigureToolbars->setEnabled( false ); 1860 mActionConfigureToolbars->setEnabled( false );
1855#endif //KAB_EMBEDDED 1861#endif //KAB_EMBEDDED
1856 1862
1857 } else { 1863 } else {
1858 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1864 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1859 1865
1860 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1866 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1861 } 1867 }
1862 1868
1863 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1869 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1864 actionCollection(), "options_show_jump_bar" ); 1870 actionCollection(), "options_show_jump_bar" );
1865 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1871 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1866 1872
1867 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1873 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1868 actionCollection(), "options_show_details" ); 1874 actionCollection(), "options_show_details" );
1869 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1875 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1870 1876
1871 // misc 1877 // misc
1872 // only enable LDAP lookup if we can handle the protocol 1878 // only enable LDAP lookup if we can handle the protocol
1873#ifndef KAB_EMBEDDED 1879#ifndef KAB_EMBEDDED
1874 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1880 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1875 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1881 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1876 this, SLOT( openLDAPDialog() ), actionCollection(), 1882 this, SLOT( openLDAPDialog() ), actionCollection(),
1877 "ldap_lookup" ); 1883 "ldap_lookup" );
1878 } 1884 }
1879#else //KAB_EMBEDDED 1885#else //KAB_EMBEDDED
1880 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1886 //qDebug("KABCore::initActions() LDAP has to be implemented");
1881#endif //KAB_EMBEDDED 1887#endif //KAB_EMBEDDED
1882 1888
1883 1889
1884 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1890 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1885 SLOT( setWhoAmI() ), actionCollection(), 1891 SLOT( setWhoAmI() ), actionCollection(),
1886 "set_personal" ); 1892 "set_personal" );
1887 1893
1888 1894
1889 1895
1890 1896
1891 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1897 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1892 SLOT( setCategories() ), actionCollection(), 1898 SLOT( setCategories() ), actionCollection(),
1893 "edit_set_categories" ); 1899 "edit_set_categories" );
1894 1900
1895 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1901 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1896 SLOT( removeVoice() ), actionCollection(), 1902 SLOT( removeVoice() ), actionCollection(),
1897 "remove_voice" ); 1903 "remove_voice" );
1898 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1904 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1899 SLOT( importFromOL() ), actionCollection(), 1905 SLOT( importFromOL() ), actionCollection(),
1900 "import_OL" ); 1906 "import_OL" );
1901#ifdef KAB_EMBEDDED 1907#ifdef KAB_EMBEDDED
1902 mActionLicence = new KAction( i18n( "Licence" ), 0, 1908 mActionLicence = new KAction( i18n( "Licence" ), 0,
1903 this, SLOT( showLicence() ), actionCollection(), 1909 this, SLOT( showLicence() ), actionCollection(),
1904 "licence_about_data" ); 1910 "licence_about_data" );
1905 mActionFaq = new KAction( i18n( "Faq" ), 0, 1911 mActionFaq = new KAction( i18n( "Faq" ), 0,
1906 this, SLOT( faq() ), actionCollection(), 1912 this, SLOT( faq() ), actionCollection(),
1907 "faq_about_data" ); 1913 "faq_about_data" );
1908 1914
1909 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1915 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1910 this, SLOT( createAboutData() ), actionCollection(), 1916 this, SLOT( createAboutData() ), actionCollection(),
1911 "kaddressbook_about_data" ); 1917 "kaddressbook_about_data" );
1912#endif //KAB_EMBEDDED 1918#endif //KAB_EMBEDDED
1913 1919
1914 clipboardDataChanged(); 1920 clipboardDataChanged();
1915 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1921 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1916 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1922 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1917} 1923}
1918 1924
1919//US we need this function, to plug all actions into the correct menues. 1925//US we need this function, to plug all actions into the correct menues.
1920// KDE uses a XML format to plug the actions, but we work her without this overhead. 1926// KDE uses a XML format to plug the actions, but we work her without this overhead.
1921void KABCore::addActionsManually() 1927void KABCore::addActionsManually()
1922{ 1928{
1923//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1929//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1924 1930
1925#ifdef KAB_EMBEDDED 1931#ifdef KAB_EMBEDDED
1926 QPopupMenu *fileMenu = new QPopupMenu( this ); 1932 QPopupMenu *fileMenu = new QPopupMenu( this );
1927 QPopupMenu *editMenu = new QPopupMenu( this ); 1933 QPopupMenu *editMenu = new QPopupMenu( this );
1928 QPopupMenu *helpMenu = new QPopupMenu( this ); 1934 QPopupMenu *helpMenu = new QPopupMenu( this );
1929 1935
1930 KToolBar* tb = mMainWindow->toolBar(); 1936 KToolBar* tb = mMainWindow->toolBar();
1931 1937
1932#ifdef DESKTOP_VERSION 1938#ifdef DESKTOP_VERSION
1933 QMenuBar* mb = mMainWindow->menuBar(); 1939 QMenuBar* mb = mMainWindow->menuBar();
1934 1940
1935 //US setup menubar. 1941 //US setup menubar.
1936 //Disable the following block if you do not want to have a menubar. 1942 //Disable the following block if you do not want to have a menubar.
1937 mb->insertItem( "&File", fileMenu ); 1943 mb->insertItem( "&File", fileMenu );
1938 mb->insertItem( "&Edit", editMenu ); 1944 mb->insertItem( "&Edit", editMenu );
1939 mb->insertItem( "&View", viewMenu ); 1945 mb->insertItem( "&View", viewMenu );
1940 mb->insertItem( "&Settings", settingsMenu ); 1946 mb->insertItem( "&Settings", settingsMenu );
1941 mb->insertItem( i18n("Synchronize"), syncMenu ); 1947 mb->insertItem( i18n("Synchronize"), syncMenu );
1942 mb->insertItem( "&Change selected", changeMenu ); 1948 mb->insertItem( "&Change selected", changeMenu );
1943 mb->insertItem( "&Help", helpMenu ); 1949 mb->insertItem( "&Help", helpMenu );
1944 mIncSearchWidget = new IncSearchWidget( tb ); 1950 mIncSearchWidget = new IncSearchWidget( tb );
1945 // tb->insertWidget(-1, 0, mIncSearchWidget); 1951 // tb->insertWidget(-1, 0, mIncSearchWidget);
1946 1952
1947#else 1953#else
1948 //US setup toolbar 1954 //US setup toolbar
1949 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1955 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1950 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1956 QPopupMenu *popupBarTB = new QPopupMenu( this );
1951 menuBarTB->insertItem( "ME", popupBarTB); 1957 menuBarTB->insertItem( "ME", popupBarTB);
1952 tb->insertWidget(-1, 0, menuBarTB); 1958 tb->insertWidget(-1, 0, menuBarTB);
1953 mIncSearchWidget = new IncSearchWidget( tb ); 1959 mIncSearchWidget = new IncSearchWidget( tb );
1954 1960
1955 tb->enableMoving(false); 1961 tb->enableMoving(false);
1956 popupBarTB->insertItem( "&File", fileMenu ); 1962 popupBarTB->insertItem( "&File", fileMenu );
1957 popupBarTB->insertItem( "&Edit", editMenu ); 1963 popupBarTB->insertItem( "&Edit", editMenu );
1958 popupBarTB->insertItem( "&View", viewMenu ); 1964 popupBarTB->insertItem( "&View", viewMenu );
1959 popupBarTB->insertItem( "&Settings", settingsMenu ); 1965 popupBarTB->insertItem( "&Settings", settingsMenu );
1960 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1966 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1961 mViewManager->getFilterAction()->plug ( popupBarTB); 1967 mViewManager->getFilterAction()->plug ( popupBarTB);
1962 popupBarTB->insertItem( "&Change selected", changeMenu ); 1968 popupBarTB->insertItem( "&Change selected", changeMenu );
1963 popupBarTB->insertItem( "&Help", helpMenu ); 1969 popupBarTB->insertItem( "&Help", helpMenu );
1964 if (QApplication::desktop()->width() > 320 ) { 1970 if (QApplication::desktop()->width() > 320 ) {
1965 // mViewManager->getFilterAction()->plug ( tb); 1971 // mViewManager->getFilterAction()->plug ( tb);
1966 } 1972 }
1967#endif 1973#endif
1968 // mActionQuit->plug ( mMainWindow->toolBar()); 1974 // mActionQuit->plug ( mMainWindow->toolBar());
1969 1975
1970 1976
1971 1977
1972 //US Now connect the actions with the menue entries. 1978 //US Now connect the actions with the menue entries.
1973 mActionPrint->plug( fileMenu ); 1979 mActionPrint->plug( fileMenu );
1974 mActionMail->plug( fileMenu ); 1980 mActionMail->plug( fileMenu );
1975 fileMenu->insertSeparator(); 1981 fileMenu->insertSeparator();
1976 1982
1977 mActionNewContact->plug( fileMenu ); 1983 mActionNewContact->plug( fileMenu );
1978 mActionNewContact->plug( tb ); 1984 mActionNewContact->plug( tb );
1979 1985
1980 mActionEditAddressee->plug( fileMenu ); 1986 mActionEditAddressee->plug( fileMenu );
1981 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1987 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1982 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1988 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1983 mActionEditAddressee->plug( tb ); 1989 mActionEditAddressee->plug( tb );
1984 1990
1985 fileMenu->insertSeparator(); 1991 fileMenu->insertSeparator();
1986 mActionSave->plug( fileMenu ); 1992 mActionSave->plug( fileMenu );
1987 fileMenu->insertItem( "&Import", ImportMenu ); 1993 fileMenu->insertItem( "&Import", ImportMenu );
1988 fileMenu->insertItem( "&Export", ExportMenu ); 1994 fileMenu->insertItem( "&Export", ExportMenu );
1989 fileMenu->insertSeparator(); 1995 fileMenu->insertSeparator();
1990 mActionMailVCard->plug( fileMenu ); 1996 mActionMailVCard->plug( fileMenu );
1991#ifndef DESKTOP_VERSION 1997#ifndef DESKTOP_VERSION
1992 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1998 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1993 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1999 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1994#endif 2000#endif
1995 fileMenu->insertSeparator(); 2001 fileMenu->insertSeparator();
1996 mActionQuit->plug( fileMenu ); 2002 mActionQuit->plug( fileMenu );
1997#ifdef _WIN32_ 2003#ifdef _WIN32_
1998 mActionImportOL->plug( ImportMenu ); 2004 mActionImportOL->plug( ImportMenu );
1999#endif 2005#endif
2000 // edit menu 2006 // edit menu
2001 mActionUndo->plug( editMenu ); 2007 mActionUndo->plug( editMenu );
2002 mActionRedo->plug( editMenu ); 2008 mActionRedo->plug( editMenu );
2003 editMenu->insertSeparator(); 2009 editMenu->insertSeparator();
2004 mActionCut->plug( editMenu ); 2010 mActionCut->plug( editMenu );
2005 mActionCopy->plug( editMenu ); 2011 mActionCopy->plug( editMenu );
2006 mActionPaste->plug( editMenu ); 2012 mActionPaste->plug( editMenu );
2007 mActionDelete->plug( editMenu ); 2013 mActionDelete->plug( editMenu );
2008 editMenu->insertSeparator(); 2014 editMenu->insertSeparator();
2009 mActionSelectAll->plug( editMenu ); 2015 mActionSelectAll->plug( editMenu );
2010 2016
2011 mActionRemoveVoice->plug( changeMenu ); 2017 mActionRemoveVoice->plug( changeMenu );
2012 // settings menu 2018 // settings menu
2013//US special menuentry to configure the addressbook resources. On KDE 2019//US special menuentry to configure the addressbook resources. On KDE
2014// you do that through the control center !!! 2020// you do that through the control center !!!
2015 mActionConfigResources->plug( settingsMenu ); 2021 mActionConfigResources->plug( settingsMenu );
2016 settingsMenu->insertSeparator(); 2022 settingsMenu->insertSeparator();
2017 2023
2018 mActionConfigKAddressbook->plug( settingsMenu ); 2024 mActionConfigKAddressbook->plug( settingsMenu );
2019 2025
2020 if ( mIsPart ) { 2026 if ( mIsPart ) {
2021 mActionConfigShortcuts->plug( settingsMenu ); 2027 mActionConfigShortcuts->plug( settingsMenu );
2022 mActionConfigureToolbars->plug( settingsMenu ); 2028 mActionConfigureToolbars->plug( settingsMenu );
2023 2029
2024 } else { 2030 } else {
2025 mActionKeyBindings->plug( settingsMenu ); 2031 mActionKeyBindings->plug( settingsMenu );
2026 } 2032 }
2027 2033
2028 settingsMenu->insertSeparator(); 2034 settingsMenu->insertSeparator();
2029 2035
2030 mActionJumpBar->plug( settingsMenu ); 2036 mActionJumpBar->plug( settingsMenu );
2031 mActionDetails->plug( settingsMenu ); 2037 mActionDetails->plug( settingsMenu );
2032 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2038 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2033 mActionDetails->plug( tb ); 2039 mActionDetails->plug( tb );
2034 settingsMenu->insertSeparator(); 2040 settingsMenu->insertSeparator();
2035 2041
2036 mActionWhoAmI->plug( settingsMenu ); 2042 mActionWhoAmI->plug( settingsMenu );
2037 mActionCategories->plug( settingsMenu ); 2043 mActionCategories->plug( settingsMenu );
2038 2044
2039 mActionLicence->plug( helpMenu ); 2045 mActionLicence->plug( helpMenu );
2040 mActionFaq->plug( helpMenu ); 2046 mActionFaq->plug( helpMenu );
2041 mActionAboutKAddressbook->plug( helpMenu ); 2047 mActionAboutKAddressbook->plug( helpMenu );
2042 2048
2043 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2049 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2044 2050
2045 mActionSave->plug( tb ); 2051 mActionSave->plug( tb );
2046 mViewManager->getFilterAction()->plug ( tb); 2052 mViewManager->getFilterAction()->plug ( tb);
2047 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2053 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2048 mActionUndo->plug( tb ); 2054 mActionUndo->plug( tb );
2049 mActionDelete->plug( tb ); 2055 mActionDelete->plug( tb );
2050 mActionRedo->plug( tb ); 2056 mActionRedo->plug( tb );
2051 } 2057 }
2052 } 2058 }
2053 //mActionQuit->plug ( tb ); 2059 //mActionQuit->plug ( tb );
2054 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2060 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2055 2061
2056 //US link the searchwidget first to this. 2062 //US link the searchwidget first to this.
2057 // The real linkage to the toolbar happens later. 2063 // The real linkage to the toolbar happens later.
2058//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2064//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2059//US tb->insertItem( mIncSearchWidget ); 2065//US tb->insertItem( mIncSearchWidget );
2060/*US 2066/*US
2061 mIncSearchWidget = new IncSearchWidget( tb ); 2067 mIncSearchWidget = new IncSearchWidget( tb );
2062 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2068 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2063 SLOT( incrementalSearch( const QString& ) ) ); 2069 SLOT( incrementalSearch( const QString& ) ) );
2064 2070
2065 mJumpButtonBar = new JumpButtonBar( this, this ); 2071 mJumpButtonBar = new JumpButtonBar( this, this );
2066 2072
2067//US topLayout->addWidget( mJumpButtonBar ); 2073//US topLayout->addWidget( mJumpButtonBar );
2068 this->layout()->add( mJumpButtonBar ); 2074 this->layout()->add( mJumpButtonBar );
2069*/ 2075*/
2070 2076
2071#endif //KAB_EMBEDDED 2077#endif //KAB_EMBEDDED
2072 2078
2073 mActionExport2phone->plug( ExportMenu ); 2079 mActionExport2phone->plug( ExportMenu );
2074 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2080 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2075 syncManager->fillSyncMenu(); 2081 syncManager->fillSyncMenu();
2076 2082
2077} 2083}
2078void KABCore::showLicence() 2084void KABCore::showLicence()
2079{ 2085{
2080 KApplication::showLicence(); 2086 KApplication::showLicence();
2081} 2087}
2082void KABCore::removeVoice() 2088void KABCore::removeVoice()
2083{ 2089{
2084 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2090 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2085 return; 2091 return;
2086 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2092 KABC::Addressee::List list = mViewManager->selectedAddressees();
2087 KABC::Addressee::List::Iterator it; 2093 KABC::Addressee::List::Iterator it;
2088 for ( it = list.begin(); it != list.end(); ++it ) { 2094 for ( it = list.begin(); it != list.end(); ++it ) {
2089 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 2095
2090 PhoneNumber::List::Iterator phoneIt; 2096 if ( (*it).removeVoice() )
2091 bool found = false;
2092 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
2093 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
2094 if ((*phoneIt).type() - PhoneNumber::Voice ) {
2095 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
2096 (*it).insertPhoneNumber( (*phoneIt) );
2097 found = true;
2098 }
2099 }
2100
2101 }
2102 if ( found )
2103 contactModified((*it) ); 2097 contactModified((*it) );
2104 } 2098 }
2105} 2099}
2106 2100
2107 2101
2108 2102
2109void KABCore::clipboardDataChanged() 2103void KABCore::clipboardDataChanged()
2110{ 2104{
2111 2105
2112 if ( mReadWrite ) 2106 if ( mReadWrite )
2113 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2107 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2114 2108
2115} 2109}
2116 2110
2117void KABCore::updateActionMenu() 2111void KABCore::updateActionMenu()
2118{ 2112{
2119 UndoStack *undo = UndoStack::instance(); 2113 UndoStack *undo = UndoStack::instance();
2120 RedoStack *redo = RedoStack::instance(); 2114 RedoStack *redo = RedoStack::instance();
2121 2115
2122 if ( undo->isEmpty() ) 2116 if ( undo->isEmpty() )
2123 mActionUndo->setText( i18n( "Undo" ) ); 2117 mActionUndo->setText( i18n( "Undo" ) );
2124 else 2118 else
2125 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2119 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2126 2120
2127 mActionUndo->setEnabled( !undo->isEmpty() ); 2121 mActionUndo->setEnabled( !undo->isEmpty() );
2128 2122
2129 if ( !redo->top() ) 2123 if ( !redo->top() )
2130 mActionRedo->setText( i18n( "Redo" ) ); 2124 mActionRedo->setText( i18n( "Redo" ) );
2131 else 2125 else
2132 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2126 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2133 2127
2134 mActionRedo->setEnabled( !redo->isEmpty() ); 2128 mActionRedo->setEnabled( !redo->isEmpty() );
2135} 2129}
2136 2130
2137void KABCore::configureKeyBindings() 2131void KABCore::configureKeyBindings()
2138{ 2132{
2139#ifndef KAB_EMBEDDED 2133#ifndef KAB_EMBEDDED
2140 KKeyDialog::configure( actionCollection(), true ); 2134 KKeyDialog::configure( actionCollection(), true );
2141#else //KAB_EMBEDDED 2135#else //KAB_EMBEDDED
2142 qDebug("KABCore::configureKeyBindings() not implemented"); 2136 qDebug("KABCore::configureKeyBindings() not implemented");
2143#endif //KAB_EMBEDDED 2137#endif //KAB_EMBEDDED
2144} 2138}
2145 2139
2146#ifdef KAB_EMBEDDED 2140#ifdef KAB_EMBEDDED
2147void KABCore::configureResources() 2141void KABCore::configureResources()
2148{ 2142{
2149 KRES::KCMKResources dlg( this, "" , 0 ); 2143 KRES::KCMKResources dlg( this, "" , 0 );
2150 2144
2151 if ( !dlg.exec() ) 2145 if ( !dlg.exec() )
2152 return; 2146 return;
2153 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2147 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2154} 2148}
2155#endif //KAB_EMBEDDED 2149#endif //KAB_EMBEDDED
2156 2150
2157 2151
2158/* this method will be called through the QCop interface from Ko/Pi to select addresses 2152/* this method will be called through the QCop interface from Ko/Pi to select addresses
2159 * for the attendees list of an event. 2153 * for the attendees list of an event.
2160 */ 2154 */
2161void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2155void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2162{ 2156{
2163 QStringList nameList; 2157 QStringList nameList;
2164 QStringList emailList; 2158 QStringList emailList;
2165 QStringList uidList; 2159 QStringList uidList;
2166 2160
2167 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2161 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2168 uint i=0; 2162 uint i=0;
2169 for (i=0; i < list.count(); i++) 2163 for (i=0; i < list.count(); i++)
2170 { 2164 {
2171 nameList.append(list[i].realName()); 2165 nameList.append(list[i].realName());
2172 emailList.append(list[i].preferredEmail()); 2166 emailList.append(list[i].preferredEmail());
2173 uidList.append(list[i].uid()); 2167 uidList.append(list[i].uid());
2174 } 2168 }
2175 2169
2176 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2170 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2177 2171
2178} 2172}
2179 2173
2180/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2174/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2181 * to put them into the calendar. 2175 * to put them into the calendar.
2182 */ 2176 */
2183void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2177void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2184{ 2178{
2185 // qDebug("KABCore::requestForBirthdayList"); 2179 // qDebug("KABCore::requestForBirthdayList");
2186 QStringList birthdayList; 2180 QStringList birthdayList;
2187 QStringList anniversaryList; 2181 QStringList anniversaryList;
2188 QStringList realNameList; 2182 QStringList realNameList;
2189 QStringList preferredEmailList; 2183 QStringList preferredEmailList;
2190 QStringList assembledNameList; 2184 QStringList assembledNameList;
2191 QStringList uidList; 2185 QStringList uidList;
2192 2186
2193 KABC::AddressBook::Iterator it; 2187 KABC::AddressBook::Iterator it;
2194 2188
2195 int count = 0; 2189 int count = 0;
2196 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2190 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2197 ++count; 2191 ++count;
2198 } 2192 }
2199 QProgressBar bar(count,0 ); 2193 QProgressBar bar(count,0 );
2200 int w = 300; 2194 int w = 300;
2201 if ( QApplication::desktop()->width() < 320 ) 2195 if ( QApplication::desktop()->width() < 320 )
2202 w = 220; 2196 w = 220;
2203 int h = bar.sizeHint().height() ; 2197 int h = bar.sizeHint().height() ;
2204 int dw = QApplication::desktop()->width(); 2198 int dw = QApplication::desktop()->width();
2205 int dh = QApplication::desktop()->height(); 2199 int dh = QApplication::desktop()->height();
2206 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2200 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2207 bar.show(); 2201 bar.show();
2208 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2202 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2209 qApp->processEvents(); 2203 qApp->processEvents();
2210 2204
2211 QDate bday; 2205 QDate bday;
2212 QString anni; 2206 QString anni;
2213 QString formattedbday; 2207 QString formattedbday;
2214 2208
2215 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2209 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2216 { 2210 {
2217 if ( ! bar.isVisible() ) 2211 if ( ! bar.isVisible() )
2218 return; 2212 return;
2219 bar.setProgress( count++ ); 2213 bar.setProgress( count++ );
2220 qApp->processEvents(); 2214 qApp->processEvents();
2221 bday = (*it).birthday().date(); 2215 bday = (*it).birthday().date();
2222 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2216 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2223 2217
2224 if ( bday.isValid() || !anni.isEmpty()) 2218 if ( bday.isValid() || !anni.isEmpty())
2225 { 2219 {
2226 if (bday.isValid()) 2220 if (bday.isValid())
2227 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2221 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2228 else 2222 else
2229 formattedbday = "NOTVALID"; 2223 formattedbday = "NOTVALID";
2230 if (anni.isEmpty()) 2224 if (anni.isEmpty())
2231 anni = "INVALID"; 2225 anni = "INVALID";
2232 2226
2233 birthdayList.append(formattedbday); 2227 birthdayList.append(formattedbday);
2234 anniversaryList.append(anni); //should be ISODate 2228 anniversaryList.append(anni); //should be ISODate
2235 realNameList.append((*it).realName()); 2229 realNameList.append((*it).realName());
2236 preferredEmailList.append((*it).preferredEmail()); 2230 preferredEmailList.append((*it).preferredEmail());
2237 assembledNameList.append((*it).assembledName()); 2231 assembledNameList.append((*it).assembledName());
2238 uidList.append((*it).uid()); 2232 uidList.append((*it).uid());
2239 2233
2240 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2234 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2241 } 2235 }
2242 } 2236 }
2243 2237
2244 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2238 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2245 2239
2246} 2240}
2247 2241
2248/* this method will be called through the QCop interface from other apps to show details of a contact. 2242/* this method will be called through the QCop interface from other apps to show details of a contact.
2249 */ 2243 */
2250void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2244void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2251{ 2245{
2252 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2246 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2253 2247
2254 QString foundUid = QString::null; 2248 QString foundUid = QString::null;
2255 if ( ! uid.isEmpty() ) { 2249 if ( ! uid.isEmpty() ) {
2256 Addressee adrr = mAddressBook->findByUid( uid ); 2250 Addressee adrr = mAddressBook->findByUid( uid );
2257 if ( !adrr.isEmpty() ) { 2251 if ( !adrr.isEmpty() ) {
2258 foundUid = uid; 2252 foundUid = uid;
2259 } 2253 }
2260 if ( email == "sendbacklist" ) { 2254 if ( email == "sendbacklist" ) {
2261 //qDebug("ssssssssssssssssssssssend "); 2255 //qDebug("ssssssssssssssssssssssend ");
2262 QStringList nameList; 2256 QStringList nameList;
2263 QStringList emailList; 2257 QStringList emailList;
2264 QStringList uidList; 2258 QStringList uidList;
2265 nameList.append(adrr.realName()); 2259 nameList.append(adrr.realName());
2266 emailList = adrr.emails(); 2260 emailList = adrr.emails();
2267 uidList.append( adrr.preferredEmail()); 2261 uidList.append( adrr.preferredEmail());
2268 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2262 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2269 return; 2263 return;
2270 } 2264 }
2271 2265
2272 } 2266 }
2273 2267
2274 if ( email == "sendbacklist" ) 2268 if ( email == "sendbacklist" )
2275 return; 2269 return;
2276 if (foundUid.isEmpty()) 2270 if (foundUid.isEmpty())
2277 { 2271 {
2278 //find the uid of the person first 2272 //find the uid of the person first
2279 Addressee::List namelist; 2273 Addressee::List namelist;
2280 Addressee::List emaillist; 2274 Addressee::List emaillist;
2281 2275
2282 if (!name.isEmpty()) 2276 if (!name.isEmpty())
2283 namelist = mAddressBook->findByName( name ); 2277 namelist = mAddressBook->findByName( name );
2284 2278
2285 if (!email.isEmpty()) 2279 if (!email.isEmpty())
2286 emaillist = mAddressBook->findByEmail( email ); 2280 emaillist = mAddressBook->findByEmail( email );
2287 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2281 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2288 //check if we have a match in Namelist and Emaillist 2282 //check if we have a match in Namelist and Emaillist
2289 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2283 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2290 foundUid = emaillist[0].uid(); 2284 foundUid = emaillist[0].uid();
2291 } 2285 }
2292 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2286 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2293 foundUid = namelist[0].uid(); 2287 foundUid = namelist[0].uid();
2294 else 2288 else
2295 { 2289 {
2296 for (int i = 0; i < namelist.count(); i++) 2290 for (int i = 0; i < namelist.count(); i++)
2297 { 2291 {
2298 for (int j = 0; j < emaillist.count(); j++) 2292 for (int j = 0; j < emaillist.count(); j++)
2299 { 2293 {
2300 if (namelist[i] == emaillist[j]) 2294 if (namelist[i] == emaillist[j])
2301 { 2295 {
2302 foundUid = namelist[i].uid(); 2296 foundUid = namelist[i].uid();
2303 } 2297 }
2304 } 2298 }
2305 } 2299 }
2306 } 2300 }
2307 } 2301 }
2308 else 2302 else
2309 { 2303 {
2310 foundUid = uid; 2304 foundUid = uid;
2311 } 2305 }
2312 2306
2313 if (!foundUid.isEmpty()) 2307 if (!foundUid.isEmpty())
2314 { 2308 {
2315 2309
2316 // raise Ka/Pi if it is in the background 2310 // raise Ka/Pi if it is in the background
2317#ifndef DESKTOP_VERSION 2311#ifndef DESKTOP_VERSION
2318#ifndef KORG_NODCOP 2312#ifndef KORG_NODCOP
2319 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2313 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2320#endif 2314#endif
2321#endif 2315#endif
2322 2316
2323 mMainWindow->showMaximized(); 2317 mMainWindow->showMaximized();
2324 mMainWindow-> raise(); 2318 mMainWindow-> raise();
2325 2319
2326 mViewManager->setSelected( "", false); 2320 mViewManager->setSelected( "", false);
2327 mViewManager->refreshView( "" ); 2321 mViewManager->refreshView( "" );
2328 mViewManager->setSelected( foundUid, true ); 2322 mViewManager->setSelected( foundUid, true );
2329 mViewManager->refreshView( foundUid ); 2323 mViewManager->refreshView( foundUid );
2330 2324
2331 if ( !mMultipleViewsAtOnce ) 2325 if ( !mMultipleViewsAtOnce )
2332 { 2326 {
2333 setDetailsVisible( true ); 2327 setDetailsVisible( true );
2334 mActionDetails->setChecked(true); 2328 mActionDetails->setChecked(true);
2335 } 2329 }
2336 } 2330 }
2337} 2331}
2338 2332
2339 2333
2340void KABCore::faq() 2334void KABCore::faq()
2341{ 2335{
2342 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2336 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2343} 2337}
2344 2338
2345#include <libkcal/syncdefines.h> 2339#include <libkcal/syncdefines.h>
2346 2340
2347KABC::Addressee KABCore::getLastSyncAddressee() 2341KABC::Addressee KABCore::getLastSyncAddressee()
2348{ 2342{
2349 Addressee lse; 2343 Addressee lse;
2350 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2344 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2351 2345
2352 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2346 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2353 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2347 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2354 if (lse.isEmpty()) { 2348 if (lse.isEmpty()) {
2355 qDebug("Creating new last-syncAddressee "); 2349 qDebug("Creating new last-syncAddressee ");
2356 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2350 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2357 QString sum = ""; 2351 QString sum = "";
2358 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2352 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index c628399..43c5f99 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -89,394 +89,395 @@ class KABCore : public QWidget, public KSyncInterface
89 /** 89 /**
90 Restores the global settings. 90 Restores the global settings.
91 */ 91 */
92 void restoreSettings(); 92 void restoreSettings();
93 93
94 /** 94 /**
95 Saves the global settings. 95 Saves the global settings.
96 */ 96 */
97 void saveSettings(); 97 void saveSettings();
98 98
99 /** 99 /**
100 Returns a pointer to the StdAddressBook of the application. 100 Returns a pointer to the StdAddressBook of the application.
101 */ 101 */
102 KABC::AddressBook *addressBook() const; 102 KABC::AddressBook *addressBook() const;
103 103
104 /** 104 /**
105 Returns a pointer to the KConfig object of the application. 105 Returns a pointer to the KConfig object of the application.
106 */ 106 */
107 static KConfig *config(); 107 static KConfig *config();
108 108
109 /** 109 /**
110 Returns a pointer to the global KActionCollection object. So 110 Returns a pointer to the global KActionCollection object. So
111 other classes can register their actions easily. 111 other classes can register their actions easily.
112 */ 112 */
113 KActionCollection *actionCollection() const; 113 KActionCollection *actionCollection() const;
114 114
115 /** 115 /**
116 Returns the current search field of the Incremental Search Widget. 116 Returns the current search field of the Incremental Search Widget.
117 */ 117 */
118 KABC::Field *currentSearchField() const; 118 KABC::Field *currentSearchField() const;
119 119
120 /** 120 /**
121 Returns the uid list of the currently selected contacts. 121 Returns the uid list of the currently selected contacts.
122 */ 122 */
123 QStringList selectedUIDs() const; 123 QStringList selectedUIDs() const;
124 124
125 /** 125 /**
126 Displays the ResourceSelectDialog and returns the selected 126 Displays the ResourceSelectDialog and returns the selected
127 resource or a null pointer if no resource was selected by 127 resource or a null pointer if no resource was selected by
128 the user. 128 the user.
129 */ 129 */
130 KABC::Resource *requestResource( QWidget *parent ); 130 KABC::Resource *requestResource( QWidget *parent );
131 131
132#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
133 static KAboutData *createAboutData(); 133 static KAboutData *createAboutData();
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 135
136#ifdef KAB_EMBEDDED 136#ifdef KAB_EMBEDDED
137 inline QPopupMenu* getImportMenu() { return ImportMenu;} 137 inline QPopupMenu* getImportMenu() { return ImportMenu;}
138 inline QPopupMenu* getExportMenu() { return ExportMenu;} 138 inline QPopupMenu* getExportMenu() { return ExportMenu;}
139#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
140 140
141 public slots: 141 public slots:
142#ifdef KAB_EMBEDDED 142#ifdef KAB_EMBEDDED
143 void createAboutData(); 143 void createAboutData();
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 void statusMessage(QString, int time = 0 ); 146 void statusMessage(QString, int time = 0 );
147 void showLicence(); 147 void showLicence();
148 void faq(); 148 void faq();
149 149
150 /** 150 /**
151 Is called whenever a contact is selected in the view. 151 Is called whenever a contact is selected in the view.
152 */ 152 */
153 void setContactSelected( const QString &uid ); 153 void setContactSelected( const QString &uid );
154 154
155 /** 155 /**
156 Opens the preferred mail composer with all selected contacts as 156 Opens the preferred mail composer with all selected contacts as
157 arguments. 157 arguments.
158 */ 158 */
159 void sendMail(); 159 void sendMail();
160 160
161 /** 161 /**
162 Opens the preferred mail composer with the given contacts as 162 Opens the preferred mail composer with the given contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail( const QString& email ); 165 void sendMail( const QString& email );
166 166
167 167
168 void mailVCard(); 168 void mailVCard();
169 void mailVCard(const QStringList& uids); 169 void mailVCard(const QStringList& uids);
170 170
171 /** 171 /**
172 Beams the "WhoAmI contact. 172 Beams the "WhoAmI contact.
173 */ 173 */
174 void beamMySelf(); 174 void beamMySelf();
175 175
176 void beamVCard(); 176 void beamVCard();
177 void export2phone(); 177 void export2phone();
178 void beamVCard(const QStringList& uids); 178 void beamVCard(const QStringList& uids);
179 void beamDone( Ir *ir ); 179 void beamDone( Ir *ir );
180 180
181 181
182 /** 182 /**
183 Starts the preferred web browser with the given URL as argument. 183 Starts the preferred web browser with the given URL as argument.
184 */ 184 */
185 void browse( const QString& url ); 185 void browse( const QString& url );
186 186
187 /** 187 /**
188 Select all contacts in the view. 188 Select all contacts in the view.
189 */ 189 */
190 void selectAllContacts(); 190 void selectAllContacts();
191 191
192 /** 192 /**
193 Deletes all selected contacts from the address book. 193 Deletes all selected contacts from the address book.
194 */ 194 */
195 void deleteContacts(); 195 void deleteContacts();
196 196
197 /** 197 /**
198 Deletes given contacts from the address book. 198 Deletes given contacts from the address book.
199 199
200 @param uids The uids of the contacts, which shall be deleted. 200 @param uids The uids of the contacts, which shall be deleted.
201 */ 201 */
202 void deleteContacts( const QStringList &uids ); 202 void deleteContacts( const QStringList &uids );
203 203
204 /** 204 /**
205 Copys the selected contacts into clipboard for later pasting. 205 Copys the selected contacts into clipboard for later pasting.
206 */ 206 */
207 void copyContacts(); 207 void copyContacts();
208 208
209 /** 209 /**
210 Cuts the selected contacts and stores them for later pasting. 210 Cuts the selected contacts and stores them for later pasting.
211 */ 211 */
212 void cutContacts(); 212 void cutContacts();
213 213
214 /** 214 /**
215 Paste contacts from clipboard into the address book. 215 Paste contacts from clipboard into the address book.
216 */ 216 */
217 void pasteContacts(); 217 void pasteContacts();
218 218
219 /** 219 /**
220 Paste given contacts into the address book. 220 Paste given contacts into the address book.
221 221
222 @param list The list of addressee, which shall be pasted. 222 @param list The list of addressee, which shall be pasted.
223 */ 223 */
224 void pasteContacts( KABC::Addressee::List &list ); 224 void pasteContacts( KABC::Addressee::List &list );
225 225
226 /** 226 /**
227 Sets the whoAmI contact, that is used by many other programs to 227 Sets the whoAmI contact, that is used by many other programs to
228 get personal information about the current user. 228 get personal information about the current user.
229 */ 229 */
230 void setWhoAmI(); 230 void setWhoAmI();
231 231
232 /** 232 /**
233 Displays the category dialog and applies the result to all 233 Displays the category dialog and applies the result to all
234 selected contacts. 234 selected contacts.
235 */ 235 */
236 void setCategories(); 236 void setCategories();
237 237
238 /** 238 /**
239 Sets the field list of the Incremental Search Widget. 239 Sets the field list of the Incremental Search Widget.
240 */ 240 */
241 void setSearchFields( const KABC::Field::List &fields ); 241 void setSearchFields( const KABC::Field::List &fields );
242 242
243 /** 243 /**
244 Search with the current search field for a contact, that matches 244 Search with the current search field for a contact, that matches
245 the given text, and selects it in the view. 245 the given text, and selects it in the view.
246 */ 246 */
247 void incrementalSearch( const QString& text ); 247 void incrementalSearch( const QString& text );
248 248
249 /** 249 /**
250 Marks the address book as modified. 250 Marks the address book as modified.
251 */ 251 */
252 void setModified(); 252 void setModified();
253 /** 253 /**
254 Marks the address book as modified without refreshing the view. 254 Marks the address book as modified without refreshing the view.
255 */ 255 */
256 void setModifiedWOrefresh(); 256 void setModifiedWOrefresh();
257 257
258 /** 258 /**
259 Marks the address book as modified concerning the argument. 259 Marks the address book as modified concerning the argument.
260 */ 260 */
261 void setModified( bool modified ); 261 void setModified( bool modified );
262 262
263 /** 263 /**
264 Returns whether the address book is modified. 264 Returns whether the address book is modified.
265 */ 265 */
266 bool modified() const; 266 bool modified() const;
267 267
268 /** 268 /**
269 Called whenever an contact is modified in the contact editor 269 Called whenever an contact is modified in the contact editor
270 dialog or the quick edit. 270 dialog or the quick edit.
271 */ 271 */
272 void contactModified( const KABC::Addressee &addr ); 272 void contactModified( const KABC::Addressee &addr );
273 273
274 /** 274 /**
275 DCOP METHODS. 275 DCOP METHODS.
276 */ 276 */
277 void addEmail( QString addr ); 277 void addEmail( QString addr );
278 void importVCard( const KURL& url, bool showPreview ); 278 void importVCard( const KURL& url, bool showPreview );
279 void importVCard( const QString& vCard, bool showPreview ); 279 void importVCard( const QString& vCard, bool showPreview );
280 void newContact(); 280 void newContact();
281 QString getNameByPhone( const QString& phone ); 281 QString getNameByPhone( const QString& phone );
282 /** 282 /**
283 END DCOP METHODS 283 END DCOP METHODS
284 */ 284 */
285 285
286 /** 286 /**
287 Saves the contents of the AddressBook back to disk. 287 Saves the contents of the AddressBook back to disk.
288 */ 288 */
289 void save(); 289 void save();
290 290
291 /** 291 /**
292 Undos the last command using the undo stack. 292 Undos the last command using the undo stack.
293 */ 293 */
294 void undo(); 294 void undo();
295 295
296 /** 296 /**
297 Redos the last command that was undone, using the redo stack. 297 Redos the last command that was undone, using the redo stack.
298 */ 298 */
299 void redo(); 299 void redo();
300 300
301 /** 301 /**
302 Shows the edit dialog for the given uid. If the uid is QString::null, 302 Shows the edit dialog for the given uid. If the uid is QString::null,
303 the method will try to find a selected addressee in the view. 303 the method will try to find a selected addressee in the view.
304 */ 304 */
305 void editContact( const QString &uid /*US = QString::null*/ ); 305 void editContact( const QString &uid /*US = QString::null*/ );
306//US added a second method without defaultparameter 306//US added a second method without defaultparameter
307 void editContact2(); 307 void editContact2();
308 308
309 /** 309 /**
310 Shows or edits the detail view for the given uid. If the uid is QString::null, 310 Shows or edits the detail view for the given uid. If the uid is QString::null,
311 the method will try to find a selected addressee in the view. 311 the method will try to find a selected addressee in the view.
312 */ 312 */
313 void executeContact( const QString &uid /*US = QString::null*/ ); 313 void executeContact( const QString &uid /*US = QString::null*/ );
314 314
315 /** 315 /**
316 Launches the configuration dialog. 316 Launches the configuration dialog.
317 */ 317 */
318 void openConfigDialog(); 318 void openConfigDialog();
319 319
320 /** 320 /**
321 Launches the ldap search dialog. 321 Launches the ldap search dialog.
322 */ 322 */
323 void openLDAPDialog(); 323 void openLDAPDialog();
324 324
325 /** 325 /**
326 Creates a KAddressBookPrinter, which will display the print 326 Creates a KAddressBookPrinter, which will display the print
327 dialog and do the printing. 327 dialog and do the printing.
328 */ 328 */
329 void print(); 329 void print();
330 330
331 /** 331 /**
332 Registers a new GUI client, so plugins can register its actions. 332 Registers a new GUI client, so plugins can register its actions.
333 */ 333 */
334 void addGUIClient( KXMLGUIClient *client ); 334 void addGUIClient( KXMLGUIClient *client );
335 335
336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
339 339
340 340
341 signals: 341 signals:
342 void contactSelected( const QString &name ); 342 void contactSelected( const QString &name );
343 void contactSelected( const QPixmap &pixmap ); 343 void contactSelected( const QPixmap &pixmap );
344 public slots: 344 public slots:
345 void recieve(QString cmsg );
345 void getFile( bool success ); 346 void getFile( bool success );
346 void syncFileRequest(); 347 void syncFileRequest();
347 void setDetailsVisible( bool visible ); 348 void setDetailsVisible( bool visible );
348 void setDetailsToState(); 349 void setDetailsToState();
349 // void slotSyncMenu( int ); 350 // void slotSyncMenu( int );
350 private slots: 351 private slots:
351 void setJumpButtonBarVisible( bool visible ); 352 void setJumpButtonBarVisible( bool visible );
352 void setCaptionBack(); 353 void setCaptionBack();
353 void importFromOL(); 354 void importFromOL();
354 void extensionModified( const KABC::Addressee::List &list ); 355 void extensionModified( const KABC::Addressee::List &list );
355 void extensionChanged( int id ); 356 void extensionChanged( int id );
356 void clipboardDataChanged(); 357 void clipboardDataChanged();
357 void updateActionMenu(); 358 void updateActionMenu();
358 void configureKeyBindings(); 359 void configureKeyBindings();
359 void removeVoice(); 360 void removeVoice();
360#ifdef KAB_EMBEDDED 361#ifdef KAB_EMBEDDED
361 void configureResources(); 362 void configureResources();
362#endif //KAB_EMBEDDED 363#endif //KAB_EMBEDDED
363 364
364 void slotEditorDestroyed( const QString &uid ); 365 void slotEditorDestroyed( const QString &uid );
365 void configurationChanged(); 366 void configurationChanged();
366 void addressBookChanged(); 367 void addressBookChanged();
367 368
368 private: 369 private:
369 void initGUI(); 370 void initGUI();
370 void initActions(); 371 void initActions();
371 372
372 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 373 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
373 const char *name = 0 ); 374 const char *name = 0 );
374 375
375 KXMLGUIClient *mGUIClient; 376 KXMLGUIClient *mGUIClient;
376 377
377 KABC::AddressBook *mAddressBook; 378 KABC::AddressBook *mAddressBook;
378 379
379 ViewManager *mViewManager; 380 ViewManager *mViewManager;
380 // QSplitter *mDetailsSplitter; 381 // QSplitter *mDetailsSplitter;
381 KDGanttMinimizeSplitter *mExtensionBarSplitter; 382 KDGanttMinimizeSplitter *mExtensionBarSplitter;
382 ViewContainer *mDetails; 383 ViewContainer *mDetails;
383 KDGanttMinimizeSplitter* mMiniSplitter; 384 KDGanttMinimizeSplitter* mMiniSplitter;
384 XXPortManager *mXXPortManager; 385 XXPortManager *mXXPortManager;
385 JumpButtonBar *mJumpButtonBar; 386 JumpButtonBar *mJumpButtonBar;
386 IncSearchWidget *mIncSearchWidget; 387 IncSearchWidget *mIncSearchWidget;
387 ExtensionManager *mExtensionManager; 388 ExtensionManager *mExtensionManager;
388 389
389 KCMultiDialog *mConfigureDialog; 390 KCMultiDialog *mConfigureDialog;
390 391
391#ifndef KAB_EMBEDDED 392#ifndef KAB_EMBEDDED
392 LDAPSearchDialog *mLdapSearchDialog; 393 LDAPSearchDialog *mLdapSearchDialog;
393#endif //KAB_EMBEDDED 394#endif //KAB_EMBEDDED
394 // QDict<AddresseeEditorDialog> mEditorDict; 395 // QDict<AddresseeEditorDialog> mEditorDict;
395 AddresseeEditorDialog *mEditorDialog; 396 AddresseeEditorDialog *mEditorDialog;
396 bool mReadWrite; 397 bool mReadWrite;
397 bool mModified; 398 bool mModified;
398 bool mIsPart; 399 bool mIsPart;
399 bool mMultipleViewsAtOnce; 400 bool mMultipleViewsAtOnce;
400 401
401 402
402 //US file menu 403 //US file menu
403 KAction *mActionMail; 404 KAction *mActionMail;
404 KAction *mActionBeam; 405 KAction *mActionBeam;
405 KAction *mActionExport2phone; 406 KAction *mActionExport2phone;
406 KAction* mActionPrint; 407 KAction* mActionPrint;
407 KAction* mActionNewContact; 408 KAction* mActionNewContact;
408 KAction *mActionSave; 409 KAction *mActionSave;
409 KAction *mActionEditAddressee; 410 KAction *mActionEditAddressee;
410 KAction *mActionMailVCard; 411 KAction *mActionMailVCard;
411 KAction *mActionBeamVCard; 412 KAction *mActionBeamVCard;
412 413
413 KAction *mActionQuit; 414 KAction *mActionQuit;
414 415
415 //US edit menu 416 //US edit menu
416 KAction *mActionCopy; 417 KAction *mActionCopy;
417 KAction *mActionCut; 418 KAction *mActionCut;
418 KAction *mActionPaste; 419 KAction *mActionPaste;
419 KAction *mActionSelectAll; 420 KAction *mActionSelectAll;
420 KAction *mActionUndo; 421 KAction *mActionUndo;
421 KAction *mActionRedo; 422 KAction *mActionRedo;
422 KAction *mActionDelete; 423 KAction *mActionDelete;
423 424
424 //US settings menu 425 //US settings menu
425 KAction *mActionConfigResources; 426 KAction *mActionConfigResources;
426 KAction *mActionConfigKAddressbook; 427 KAction *mActionConfigKAddressbook;
427 KAction *mActionConfigShortcuts; 428 KAction *mActionConfigShortcuts;
428 KAction *mActionConfigureToolbars; 429 KAction *mActionConfigureToolbars;
429 KAction *mActionKeyBindings; 430 KAction *mActionKeyBindings;
430 KToggleAction *mActionJumpBar; 431 KToggleAction *mActionJumpBar;
431 KToggleAction *mActionDetails; 432 KToggleAction *mActionDetails;
432 KAction *mActionWhoAmI; 433 KAction *mActionWhoAmI;
433 KAction *mActionCategories; 434 KAction *mActionCategories;
434 KAction *mActionAboutKAddressbook; 435 KAction *mActionAboutKAddressbook;
435 KAction *mActionLicence; 436 KAction *mActionLicence;
436 KAction *mActionFaq; 437 KAction *mActionFaq;
437 438
438 KAction *mActionDeleteView; 439 KAction *mActionDeleteView;
439 440
440 QPopupMenu *viewMenu; 441 QPopupMenu *viewMenu;
441 QPopupMenu *filterMenu; 442 QPopupMenu *filterMenu;
442 QPopupMenu *settingsMenu; 443 QPopupMenu *settingsMenu;
443 QPopupMenu *changeMenu; 444 QPopupMenu *changeMenu;
444//US QAction *mActionSave; 445//US QAction *mActionSave;
445 QPopupMenu *ImportMenu; 446 QPopupMenu *ImportMenu;
446 QPopupMenu *ExportMenu; 447 QPopupMenu *ExportMenu;
447 //LR additional methods 448 //LR additional methods
448 KAction *mActionRemoveVoice; 449 KAction *mActionRemoveVoice;
449 KAction * mActionImportOL; 450 KAction * mActionImportOL;
450 451
451#ifndef KAB_EMBEDDED 452#ifndef KAB_EMBEDDED
452 KAddressBookService *mAddressBookService; 453 KAddressBookService *mAddressBookService;
453#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
454 455
455 class KABCorePrivate; 456 class KABCorePrivate;
456 KABCorePrivate *d; 457 KABCorePrivate *d;
457 //US bool mBlockSaveFlag; 458 //US bool mBlockSaveFlag;
458 459
459#ifdef KAB_EMBEDDED 460#ifdef KAB_EMBEDDED
460 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 461 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
461#endif //KAB_EMBEDDED 462#endif //KAB_EMBEDDED
462 463
463 //this are the overwritten callbackmethods from the syncinterface 464 //this are the overwritten callbackmethods from the syncinterface
464 virtual bool sync(KSyncManager* manager, QString filename, int mode); 465 virtual bool sync(KSyncManager* manager, QString filename, int mode);
465 virtual bool syncExternal(KSyncManager* manager, QString resource); 466 virtual bool syncExternal(KSyncManager* manager, QString resource);
466 467
467 468
468 // LR ******************************* 469 // LR *******************************
469 // sync stuff! 470 // sync stuff!
470 QString sentSyncFile(); 471 QString sentSyncFile();
471 QPopupMenu *syncMenu; 472 QPopupMenu *syncMenu;
472 KSyncManager* syncManager; 473 KSyncManager* syncManager;
473 int mGlobalSyncMode; 474 int mGlobalSyncMode;
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 475 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 KABC::Addressee getLastSyncAddressee(); 476 KABC::Addressee getLastSyncAddressee();
476 QDateTime mLastAddressbookSync; 477 QDateTime mLastAddressbookSync;
477 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 478 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
478 // ********************* 479 // *********************
479 480
480}; 481};
481 482
482#endif 483#endif
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index f48f214..8c4ca09 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,240 +1,250 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 31#include <kedittoolbar.h>
32#include <kkeydialog.h> 32#include <kkeydialog.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kstatusbar.h> 34#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kaddressbookmain.h" 39#include "kaddressbookmain.h"
40#include "kactioncollection.h" 40#include "kactioncollection.h"
41 41
42#ifdef KAB_EMBEDDED 42#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) 43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" )
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 45//MOC_SKIP_BEGIN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 47//MOC_SKIP_END
48#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
49{ 49{
50 50
51 setIcon(SmallIcon( "ka24" ) ); 51 setIcon(SmallIcon( "ka24" ) );
52#if 0 52#if 0
53 //US for embedded systems, create the toolbar before we initiate KABCore. 53 //US for embedded systems, create the toolbar before we initiate KABCore.
54 // KABCore will fill the toolbar with menues and icons 54 // KABCore will fill the toolbar with menues and icons
55 QMainWindow::ToolBarDock tbd; 55 QMainWindow::ToolBarDock tbd;
56 tbd = Top; 56 tbd = Top;
57 iconToolBar = new QToolBar( this ); 57 iconToolBar = new QToolBar( this );
58 addToolBar (iconToolBar , tbd ); 58 addToolBar (iconToolBar , tbd );
59 iconToolBar->setHorizontalStretchable(true); 59 iconToolBar->setHorizontalStretchable(true);
60//US iconToolBar->setWidth(300); 60//US iconToolBar->setWidth(300);
61#endif // 0 61#endif // 0
62 62
63 mCore = new KABCore( this, true, this ); 63 mCore = new KABCore( this, true, this );
64 64
65#ifdef KAB_EMBEDDED 65#ifdef KAB_EMBEDDED
66 setCaption( i18n( "KAddressbook/Pi" ) ); 66 setCaption( i18n( "KAddressbook/Pi" ) );
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 setCaption( i18n( "Address Book Browser" ) ); 68 setCaption( i18n( "Address Book Browser" ) );
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 //mCore->restoreSettings(); 71 //mCore->restoreSettings();
72 72
73 initActions(); 73 initActions();
74 74
75 setCentralWidget( mCore ); 75 setCentralWidget( mCore );
76 76
77//US statusBar()->show(); 77//US statusBar()->show();
78 78
79#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
80 setStandardToolBarMenuEnabled(true); 80 setStandardToolBarMenuEnabled(true);
81 81
82 createGUI( "kaddressbookui.rc", false ); 82 createGUI( "kaddressbookui.rc", false );
83 83
84 84
85#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
86 setAutoSaveSettings(); 86 setAutoSaveSettings();
87 qApp->processEvents(); 87 qApp->processEvents();
88 mCore->restoreSettings(); 88 mCore->restoreSettings();
89} 89}
90 90
91KAddressBookMain::~KAddressBookMain() 91KAddressBookMain::~KAddressBookMain()
92{ 92{
93 // mCore->saveSettings(); 93 // mCore->saveSettings();
94} 94}
95 95void KAddressBookMain::recieve( const QCString& cmsg, const QByteArray& data )
96{
97 qDebug("KA: QCOP message received: %s ", cmsg.data() );
98 if ( cmsg == "setDocument(QString)" ) {
99 QDataStream stream( data, IO_ReadOnly );
100 QString fileName;
101 stream >> fileName;
102 mCore->recieve( fileName );
103 return;
104 }
105}
96void KAddressBookMain::showMinimized () 106void KAddressBookMain::showMinimized ()
97{ 107{
98 QWidget::showMinimized () ; 108 QWidget::showMinimized () ;
99} 109}
100void KAddressBookMain::addEmail( QString addr ) 110void KAddressBookMain::addEmail( QString addr )
101{ 111{
102 mCore->addEmail( addr ); 112 mCore->addEmail( addr );
103} 113}
104 114
105#ifndef KAB_EMBEDDED 115#ifndef KAB_EMBEDDED
106ASYNC KAddressBookMain::showContactEditor( QString uid ) 116ASYNC KAddressBookMain::showContactEditor( QString uid )
107{ 117{
108 mCore->editContact( uid ); 118 mCore->editContact( uid );
109} 119}
110#endif //KAB_EMBEDDED 120#endif //KAB_EMBEDDED
111void KAddressBookMain::newContact() 121void KAddressBookMain::newContact()
112{ 122{
113 mCore->newContact(); 123 mCore->newContact();
114} 124}
115 125
116QString KAddressBookMain::getNameByPhone( QString phone ) 126QString KAddressBookMain::getNameByPhone( QString phone )
117{ 127{
118 return mCore->getNameByPhone( phone ); 128 return mCore->getNameByPhone( phone );
119} 129}
120 130
121void KAddressBookMain::save() 131void KAddressBookMain::save()
122{ 132{
123 mCore->save(); 133 mCore->save();
124} 134}
125 135
126void KAddressBookMain::exit() 136void KAddressBookMain::exit()
127{ 137{
128 close( ); 138 close( );
129} 139}
130 140
131void KAddressBookMain::saveProperties( KConfig* ) 141void KAddressBookMain::saveProperties( KConfig* )
132{ 142{
133} 143}
134 144
135void KAddressBookMain::readProperties( KConfig* ) 145void KAddressBookMain::readProperties( KConfig* )
136{ 146{
137} 147}
138 148
139void KAddressBookMain::initActions() 149void KAddressBookMain::initActions()
140{ 150{
141#ifndef KAB_EMBEDDED 151#ifndef KAB_EMBEDDED
142 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 152 KStdAction::quit( this, SLOT( close() ), actionCollection() );
143 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 153 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
144#else //KAB_EMBEDDED 154#else //KAB_EMBEDDED
145 //US: transfered the setup of the actions into KABCore 155 //US: transfered the setup of the actions into KABCore
146#endif //KAB_EMBEDDED 156#endif //KAB_EMBEDDED
147 157
148 158
149} 159}
150 160
151//US new method to setup menues and toolbars on embedded systems 161//US new method to setup menues and toolbars on embedded systems
152#ifdef KAB_EMBEDDED 162#ifdef KAB_EMBEDDED
153/* 163/*
154QToolBar * KAddressBookMain::getIconToolBar() 164QToolBar * KAddressBookMain::getIconToolBar()
155{ 165{
156 return iconToolBar; 166 return iconToolBar;
157} 167}
158*/ 168*/
159 169
160void KAddressBookMain::createGUI() 170void KAddressBookMain::createGUI()
161{ 171{
162 172
163 173
164 174
165} 175}
166#endif //KAB_EMBEDDED 176#endif //KAB_EMBEDDED
167 177
168void KAddressBookMain::configureToolbars() 178void KAddressBookMain::configureToolbars()
169{ 179{
170#ifndef KAB_EMBEDDED 180#ifndef KAB_EMBEDDED
171 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 181 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
172 182
173 KEditToolbar dlg( factory() ); 183 KEditToolbar dlg( factory() );
174 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 184 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
175 185
176 dlg.exec(); 186 dlg.exec();
177#else //KAB_EMBEDDED 187#else //KAB_EMBEDDED
178 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 188 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
179#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
180} 190}
181 191
182void KAddressBookMain::slotNewToolbarConfig() 192void KAddressBookMain::slotNewToolbarConfig()
183{ 193{
184#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
185 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 195 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
186#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
187 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 197 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
188#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
189} 199}
190 200
191void KAddressBookMain::configureKeys() 201void KAddressBookMain::configureKeys()
192{ 202{
193#ifndef KAB_EMBEDDED 203#ifndef KAB_EMBEDDED
194 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 204 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
195#else //KAB_EMBEDDED 205#else //KAB_EMBEDDED
196 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 206 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
197#endif //KAB_EMBEDDED 207#endif //KAB_EMBEDDED
198} 208}
199 209
200void KAddressBookMain::closeEvent( QCloseEvent* ce ) 210void KAddressBookMain::closeEvent( QCloseEvent* ce )
201{ 211{
202 bool mModified = mCore->modified(); 212 bool mModified = mCore->modified();
203 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 213 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
204 214
205 QString mess = i18n( "Close KA/Pi?"); 215 QString mess = i18n( "Close KA/Pi?");
206 if ( mModified == true ) 216 if ( mModified == true )
207 mess += i18n( "\nChanges will be saved!"); 217 mess += i18n( "\nChanges will be saved!");
208 else 218 else
209 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 219 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
210 220
211 bool mQuit = true; 221 bool mQuit = true;
212 222
213 223
214 if (mAskForQuit) 224 if (mAskForQuit)
215 { 225 {
216 226
217 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 227 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
218 if (res == 0) 228 if (res == 0)
219 mQuit = true; 229 mQuit = true;
220 else 230 else
221 mQuit = false; 231 mQuit = false;
222 } 232 }
223 233
224 if (mQuit == false) 234 if (mQuit == false)
225 return; 235 return;
226 236
227 if (mModified == true) 237 if (mModified == true)
228 { 238 {
229 save(); 239 save();
230 mCore->saveSettings(); 240 mCore->saveSettings();
231 KABPrefs::instance()->writeConfig(); 241 KABPrefs::instance()->writeConfig();
232 } 242 }
233 243
234 ce->accept(); 244 ce->accept();
235} 245}
236 246
237#ifndef KAB_EMBEDDED 247#ifndef KAB_EMBEDDED
238#include "kaddressbookmain.moc" 248#include "kaddressbookmain.moc"
239#endif //KAB_EMBEDDED 249#endif //KAB_EMBEDDED
240 250
diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h
index cf6f899..40d2bdd 100644
--- a/kaddressbook/kaddressbookmain.h
+++ b/kaddressbook/kaddressbookmain.h
@@ -1,122 +1,122 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KADDRESSBOOKMAIN_H 24#ifndef KADDRESSBOOKMAIN_H
25#define KADDRESSBOOKMAIN_H 25#define KADDRESSBOOKMAIN_H
26 26
27#include <qptrlist.h> 27#include <qptrlist.h>
28 28
29#ifdef KAB_EMBEDDED 29#ifdef KAB_EMBEDDED
30class QToolBar; 30class QToolBar;
31#include <qaction.h> 31#include <qaction.h>
32//#include <qmainwindow.h> 32//#include <qmainwindow.h>
33#include <kmainwindow.h> 33#include <kmainwindow.h>
34#else //KAB_EMBEDDED 34#else //KAB_EMBEDDED
35#include <kaction.h> 35#include <kaction.h>
36#include <kapplication.h> 36#include <kapplication.h>
37#include <kmainwindow.h> 37#include <kmainwindow.h>
38#include "kaddressbookiface.h" 38#include "kaddressbookiface.h"
39#endif //KAB_EMBEDDED 39#endif //KAB_EMBEDDED
40 40
41class KABCore; 41class KABCore;
42class KConfig; 42class KConfig;
43 43
44/** 44/**
45 This class serves as the main window for KAddressBook. It handles the 45 This class serves as the main window for KAddressBook. It handles the
46 menus, toolbars, and status bars. 46 menus, toolbars, and status bars.
47 47
48 @short Main window class 48 @short Main window class
49 @author Don Sanders <dsanders@kde.org> 49 @author Don Sanders <dsanders@kde.org>
50 @version 0.1 50 @version 0.1
51 */ 51 */
52#ifdef KAB_EMBEDDED 52#ifdef KAB_EMBEDDED
53class KAddressBookMain : public KMainWindow 53class KAddressBookMain : public KMainWindow
54#else //KAB_EMBEDDED 54#else //KAB_EMBEDDED
55//MOC_SKIP_BEGIN 55//MOC_SKIP_BEGIN
56class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface 56class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface
57//MOC_SKIP_END 57//MOC_SKIP_END
58#endif //KAB_EMBEDDED 58#endif //KAB_EMBEDDED
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 61
62 public: 62 public:
63 KAddressBookMain(); 63 KAddressBookMain();
64 virtual ~KAddressBookMain(); 64 virtual ~KAddressBookMain();
65 65
66#ifdef KAB_EMBEDDED 66#ifdef KAB_EMBEDDED
67// QPEToolBar * getIconToolBar(); 67// QPEToolBar * getIconToolBar();
68 // QToolBar * getIconToolBar(); 68 // QToolBar * getIconToolBar();
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 71
72 public slots: 72 public slots:
73 void showMinimized () ; 73 void showMinimized () ;
74 virtual void addEmail( QString addr ); 74 virtual void addEmail( QString addr );
75#ifndef KAB_EMBEDDED 75#ifndef KAB_EMBEDDED
76//MOC_SKIP_BEGIN 76//MOC_SKIP_BEGIN
77 virtual ASYNC showContactEditor( QString uid ); 77 virtual ASYNC showContactEditor( QString uid );
78//MOC_SKIP_END 78//MOC_SKIP_END
79#endif //KAB_EMBEDDED 79#endif //KAB_EMBEDDED
80 virtual void newContact(); 80 virtual void newContact();
81 virtual QString getNameByPhone( QString phone ); 81 virtual QString getNameByPhone( QString phone );
82 virtual void save(); 82 virtual void save();
83 virtual void exit(); 83 virtual void exit();
84 84 void recieve( const QCString& cmsg, const QByteArray& data );
85 protected: 85 protected:
86 void initActions(); 86 void initActions();
87#ifdef KAB_EMBEDDED 87#ifdef KAB_EMBEDDED
88 //US new method to setup menues and toolbars on embedded systems 88 //US new method to setup menues and toolbars on embedded systems
89 void createGUI(); 89 void createGUI();
90#endif //KAB_EMBEDDED 90#endif //KAB_EMBEDDED
91 91
92 /** 92 /**
93 This function is called when it is time for the app to save its 93 This function is called when it is time for the app to save its
94 properties for session management purposes. 94 properties for session management purposes.
95 */ 95 */
96 void saveProperties( KConfig* ); 96 void saveProperties( KConfig* );
97 97
98 /** 98 /**
99 This function is called when this app is restored. The KConfig 99 This function is called when this app is restored. The KConfig
100 object points to the session management config file that was saved 100 object points to the session management config file that was saved
101 with @ref saveProperties 101 with @ref saveProperties
102 */ 102 */
103 void readProperties( KConfig* ); 103 void readProperties( KConfig* );
104 104
105 void closeEvent( QCloseEvent* ce ); 105 void closeEvent( QCloseEvent* ce );
106 106
107 protected slots: 107 protected slots:
108 void configureToolbars(); 108 void configureToolbars();
109 void configureKeys(); 109 void configureKeys();
110 110
111 void slotNewToolbarConfig(); 111 void slotNewToolbarConfig();
112 112
113 private: 113 private:
114 KABCore *mCore; 114 KABCore *mCore;
115 115
116#ifdef KAB_EMBEDDED 116#ifdef KAB_EMBEDDED
117 // QToolBar *iconToolBar; 117 // QToolBar *iconToolBar;
118#endif //KAB_EMBEDDED 118#endif //KAB_EMBEDDED
119 119
120}; 120};
121 121
122#endif 122#endif
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 965fb06..6dd97b8 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,212 +1,218 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qcopchannel_qws.h>
3#include <stdlib.h> 4#include <stdlib.h>
4#else 5#else
5#include <qapplication.h> 6#include <qapplication.h>
6#include <qwindowsstyle.h> 7#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 8#include <qplatinumstyle.h>
8#include <qmainwindow.h> 9#include <qmainwindow.h>
9#endif 10#endif
10 11
11#include <kstandarddirs.h> 12#include <kstandarddirs.h>
12#include <qregexp.h> 13#include <qregexp.h>
13#include <kglobal.h> 14#include <kglobal.h>
14#include <stdio.h> 15#include <stdio.h>
15#include <qdir.h> 16#include <qdir.h>
16#include "kaddressbookmain.h" 17#include "kaddressbookmain.h"
17#include "externalapphandler.h" 18#include "externalapphandler.h"
18#include <libkdepim/kpimglobalprefs.h> 19#include <libkdepim/kpimglobalprefs.h>
19 20
20int main( int argc, char **argv ) 21int main( int argc, char **argv )
21{ 22{
22#ifndef DESKTOP_VERSION 23#ifndef DESKTOP_VERSION
23 QPEApplication a( argc, argv ); 24 QPEApplication a( argc, argv );
24 a.setKeepRunning (); 25 a.setKeepRunning ();
25#else 26#else
26 QApplication a( argc, argv ); 27 QApplication a( argc, argv );
27 QApplication::setStyle( new QPlatinumStyle ()); 28 QApplication::setStyle( new QPlatinumStyle ());
28 QString hdir = QDir::homeDirPath(); 29 QString hdir = QDir::homeDirPath();
29 // there is a bug when creating dirs for WIN 98 30 // there is a bug when creating dirs for WIN 98
30 // it is difficult to fix, because we have no WIN 98 runnung 31 // it is difficult to fix, because we have no WIN 98 runnung
31 // such that we try it to create the dirs at startup here 32 // such that we try it to create the dirs at startup here
32 if ( hdir == "C:\\" ) { // win 98 or ME 33 if ( hdir == "C:\\" ) { // win 98 or ME
33 QDir app_dir; 34 QDir app_dir;
34 if ( !app_dir.exists("C:\\kdepim") ) 35 if ( !app_dir.exists("C:\\kdepim") )
35 app_dir.mkdir ("C:\\kdepim"); 36 app_dir.mkdir ("C:\\kdepim");
36 if ( !app_dir.exists("C:\\kdepim\\apps") ) 37 if ( !app_dir.exists("C:\\kdepim\\apps") )
37 app_dir.mkdir ("C:\\kdepim\\apps"); 38 app_dir.mkdir ("C:\\kdepim\\apps");
38 if ( !app_dir.exists("C:\\kdepim\\config") ) 39 if ( !app_dir.exists("C:\\kdepim\\config") )
39 app_dir.mkdir ("C:\\kdepim\\config"); 40 app_dir.mkdir ("C:\\kdepim\\config");
40 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) 41 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
41 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); 42 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
42 } 43 }
43#endif 44#endif
44 45
45 bool exitHelp = false; 46 bool exitHelp = false;
46 if ( argc > 1 ) { 47 if ( argc > 1 ) {
47 QString command = argv[1]; 48 QString command = argv[1];
48 if ( command == "-help" ){ 49 if ( command == "-help" ){
49 printf("KA/E command line commands:\n"); 50 printf("KA/E command line commands:\n");
50 printf(" no command: Start KA/E in usual way\n"); 51 printf(" no command: Start KA/E in usual way\n");
51 printf(" -help: This output\n"); 52 printf(" -help: This output\n");
52 printf(" KA/E is exiting now. Bye!\n"); 53 printf(" KA/E is exiting now. Bye!\n");
53 exitHelp = true; 54 exitHelp = true;
54 } 55 }
55 } 56 }
56 if ( ! exitHelp ) { 57 if ( ! exitHelp ) {
57 58
58 KGlobal::setAppName( "kaddressbook" ); 59 KGlobal::setAppName( "kaddressbook" );
59#ifndef DESKTOP_VERSION 60#ifndef DESKTOP_VERSION
60 if ( QApplication::desktop()->width() > 320 ) 61 if ( QApplication::desktop()->width() > 320 )
61 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
62 else 63 else
63 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 64 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
64#else 65#else
65 QString fileName ; 66 QString fileName ;
66 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 67 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
67 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 68 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
68 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 69 QApplication::addLibraryPath ( qApp->applicationDirPath () );
69 70
70#endif 71#endif
71 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 72 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
72 KAddressBookMain m ; 73 KAddressBookMain m ;
73//US MainWindow m; 74//US MainWindow m;
74 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 75 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
75 76
76 { 77 {
77 KPimGlobalPrefs::instance()->setGlobalConfig(); 78 KPimGlobalPrefs::instance()->setGlobalConfig();
78 } 79 }
79#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
80 a.showMainWidget( &m ); 81 a.showMainWidget( &m );
82 QCopChannel* c1 = new QCopChannel("QPE/Application/addressbook",&m, "channelAB" ) ;
83 QObject::connect( c1, SIGNAL (received ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
81#else 84#else
82 a.setMainWidget( &m ); 85 a.setMainWidget( &m );
83 m.resize (640, 480 ); 86 m.resize (640, 480 );
84 m.show(); 87 m.show();
85#endif 88#endif
86 a.exec(); 89 a.exec();
90#ifndef DESKTOP_VERSION
91 delete c1;
92#endif
87 93
88 } 94 }
89 qDebug("KA: Bye! "); 95 qDebug("KA: Bye! ");
90} 96}
91 97
92/* 98/*
93#include <stdlib.h> 99#include <stdlib.h>
94 100
95#include <qstring.h> 101#include <qstring.h>
96 102
97#include <kabc/stdaddressbook.h> 103#include <kabc/stdaddressbook.h>
98#include <kaboutdata.h> 104#include <kaboutdata.h>
99#include <kcmdlineargs.h> 105#include <kcmdlineargs.h>
100#include <kcrash.h> 106#include <kcrash.h>
101#include <kdebug.h> 107#include <kdebug.h>
102#include <klocale.h> 108#include <klocale.h>
103#include <kstartupinfo.h> 109#include <kstartupinfo.h>
104#include <kuniqueapplication.h> 110#include <kuniqueapplication.h>
105#include <kwin.h> 111#include <kwin.h>
106 112
107#include "kaddressbookmain.h" 113#include "kaddressbookmain.h"
108#include "kabcore.h" 114#include "kabcore.h"
109 115
110extern "C" { 116extern "C" {
111 117
112void crashHandler( int ) 118void crashHandler( int )
113{ 119{
114 KABC::StdAddressBook::handleCrash(); 120 KABC::StdAddressBook::handleCrash();
115 ::exit( 0 ); 121 ::exit( 0 );
116} 122}
117 123
118} 124}
119 125
120class KAddressBookApp : public KUniqueApplication { 126class KAddressBookApp : public KUniqueApplication {
121 public: 127 public:
122 KAddressBookApp() : mMainWin( 0 ) {} 128 KAddressBookApp() : mMainWin( 0 ) {}
123 ~KAddressBookApp() {} 129 ~KAddressBookApp() {}
124 130
125 int newInstance(); 131 int newInstance();
126 132
127 private: 133 private:
128 KAddressBookMain *mMainWin; 134 KAddressBookMain *mMainWin;
129}; 135};
130 136
131int KAddressBookApp::newInstance() 137int KAddressBookApp::newInstance()
132{ 138{
133 if ( isRestored() ) { 139 if ( isRestored() ) {
134 // There can only be one main window 140 // There can only be one main window
135 if ( KMainWindow::canBeRestored( 1 ) ) { 141 if ( KMainWindow::canBeRestored( 1 ) ) {
136 mMainWin = new KAddressBookMain; 142 mMainWin = new KAddressBookMain;
137 mMainWin->show(); 143 mMainWin->show();
138 mMainWin->restore( 1 ); 144 mMainWin->restore( 1 );
139 } 145 }
140 } else { 146 } else {
141 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 147 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
142 148
143 QCString addrStr = args->getOption( "addr" ); 149 QCString addrStr = args->getOption( "addr" );
144 QCString uidStr = args->getOption( "uid" ); 150 QCString uidStr = args->getOption( "uid" );
145 QString addr; 151 QString addr;
146 QString uid; 152 QString uid;
147 if ( !addrStr.isEmpty() ) 153 if ( !addrStr.isEmpty() )
148 addr = QString::fromLocal8Bit( addrStr ); 154 addr = QString::fromLocal8Bit( addrStr );
149 if ( !uidStr.isEmpty() ) 155 if ( !uidStr.isEmpty() )
150 uid = QString::fromLocal8Bit( uidStr ); 156 uid = QString::fromLocal8Bit( uidStr );
151 157
152 158
153 if ( args->isSet( "editor-only" ) ) { 159 if ( args->isSet( "editor-only" ) ) {
154 if ( !mMainWin ) 160 if ( !mMainWin )
155 mMainWin = new KAddressBookMain; 161 mMainWin = new KAddressBookMain;
156 KStartupInfo::appStarted(); 162 KStartupInfo::appStarted();
157 mMainWin->hide(); 163 mMainWin->hide();
158 } else { 164 } else {
159 if ( mMainWin ) { 165 if ( mMainWin ) {
160 mMainWin->show(); 166 mMainWin->show();
161 KWin::setActiveWindow( mMainWin->winId() ); 167 KWin::setActiveWindow( mMainWin->winId() );
162 } else { 168 } else {
163 mMainWin = new KAddressBookMain; 169 mMainWin = new KAddressBookMain;
164 mMainWin->show(); 170 mMainWin->show();
165 } 171 }
166 } 172 }
167 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 173 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
168 if ( !addr.isEmpty() ) 174 if ( !addr.isEmpty() )
169 mMainWin->addEmail( addr ); 175 mMainWin->addEmail( addr );
170 176
171 if ( !uid.isEmpty() ) 177 if ( !uid.isEmpty() )
172 mMainWin->showContactEditor( uid ); 178 mMainWin->showContactEditor( uid );
173 if ( args->isSet( "new-contact" ) ) { 179 if ( args->isSet( "new-contact" ) ) {
174 mMainWin->newContact(); 180 mMainWin->newContact();
175 } 181 }
176 } 182 }
177 183
178 KCrash::setEmergencySaveFunction( crashHandler ); 184 KCrash::setEmergencySaveFunction( crashHandler );
179 185
180 return 0; 186 return 0;
181} 187}
182 188
183// the dummy argument is required, because KMail apparently sends an empty 189// the dummy argument is required, because KMail apparently sends an empty
184// argument. 190// argument.
185static KCmdLineOptions kmoptions[] = 191static KCmdLineOptions kmoptions[] =
186{ 192{
187 { "a", 0 , 0 }, 193 { "a", 0 , 0 },
188 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 194 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
189 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 195 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
190 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 196 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
191 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 197 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
192 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 198 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
193 { 0, 0, 0} 199 { 0, 0, 0}
194}; 200};
195 201
196int main( int argc, char *argv[] ) 202int main( int argc, char *argv[] )
197{ 203{
198 KLocale::setMainCatalogue( "kaddressbook" ); 204 KLocale::setMainCatalogue( "kaddressbook" );
199 205
200 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 206 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
201 KCmdLineArgs::addCmdLineOptions( kmoptions ); 207 KCmdLineArgs::addCmdLineOptions( kmoptions );
202 KUniqueApplication::addCmdLineOptions(); 208 KUniqueApplication::addCmdLineOptions();
203 209
204 if ( !KAddressBookApp::start() ) 210 if ( !KAddressBookApp::start() )
205 exit( 0 ); 211 exit( 0 );
206 212
207 KAddressBookApp app; 213 KAddressBookApp app;
208 KGlobal::locale()->insertCatalogue( "libkdepim" ); 214 KGlobal::locale()->insertCatalogue( "libkdepim" );
209 215
210 return app.exec(); 216 return app.exec();
211} 217}
212*/ 218*/
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 3c16458..a69a0bd 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -81,519 +81,520 @@ class KOex2phonePrefs : public QDialog
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mClosed = false; 133 mClosed = false;
134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
135 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
136 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
137 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
138 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
139 mBlockAtStartup = true; 139 mBlockAtStartup = true;
140 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
141 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
142 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
143 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
144 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
145 p->mHourSize = 18; 145 p->mHourSize = 18;
146 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
147 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
148 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
149 tbd = Bottom; 149 tbd = Bottom;
150 else 150 else
151 tbd = Top; 151 tbd = Top;
152 } 152 }
153 else { 153 else {
154 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
155 tbd = Right; 155 tbd = Right;
156 else 156 else
157 tbd = Left; 157 tbd = Left;
158 } 158 }
159 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
161 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
162 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
163 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
164 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
165 165
166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
167 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
168 setCentralWidget( splash ); 168 setCentralWidget( splash );
169#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
170 showMaximized(); 170 showMaximized();
171#endif 171#endif
172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
173 setDefaultPreferences(); 173 setDefaultPreferences();
174 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
175 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
176 mView->hide(); 176 mView->hide();
177 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
178 initActions(); 178 initActions();
179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
180 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
181 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 183 iconToolBar->show();
184 qApp->processEvents(); 184 qApp->processEvents();
185#endif 185#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 187 int vh = height() ;
188 int vw = width(); 188 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
192 } else { 192 } else {
193 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
194 } 194 }
195 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 198 mView->readSettings();
199 bool newFile = false; 199 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
205 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 206 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
209 qApp->processEvents(); 209 qApp->processEvents();
210 } else { 210 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } 217 }
218 } 218 }
219 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
220 newFile = true; 220 newFile = true;
221 } 221 }
222 222
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
232 } 232 }
233 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
235 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
236 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
237 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
238 238
239 239
240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
241 mView->setModified( false ); 241 mView->setModified( false );
242 mBlockAtStartup = false; 242 mBlockAtStartup = false;
243 mView->setModified( false ); 243 mView->setModified( false );
244 setCentralWidget( mView ); 244 setCentralWidget( mView );
245 globalFlagBlockStartup = 0; 245 globalFlagBlockStartup = 0;
246 mView->show(); 246 mView->show();
247 delete splash; 247 delete splash;
248 if ( newFile ) 248 if ( newFile )
249 mView->updateConfig(); 249 mView->updateConfig();
250 // qApp->processEvents(); 250 // qApp->processEvents();
251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
252 //fillSyncMenu(); 252 //fillSyncMenu();
253 253
254 254
255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
258 mSyncManager->setDefaultFileName( defaultFileName()); 258 mSyncManager->setDefaultFileName( defaultFileName());
259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
260 mSyncManager->fillSyncMenu(); 260 mSyncManager->fillSyncMenu();
261 261
262 262
263 263
264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
265 if ( showWarning ) { 265 if ( showWarning ) {
266 KMessageBox::information( this, 266 KMessageBox::information( this,
267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
268 qApp->processEvents(); 268 qApp->processEvents();
269 mView->dialogManager()->showSyncOptions(); 269 mView->dialogManager()->showSyncOptions();
270 } 270 }
271 271
272 //US listen for result adressed from Ka/Pi 272 //US listen for result adressed from Ka/Pi
273#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
275#endif 275#endif
276} 276}
277MainWindow::~MainWindow() 277MainWindow::~MainWindow()
278{ 278{
279 //qDebug("MainWindow::~MainWindow() "); 279 //qDebug("MainWindow::~MainWindow() ");
280 //save toolbar location 280 //save toolbar location
281 delete mCalendar; 281 delete mCalendar;
282 delete mSyncManager; 282 delete mSyncManager;
283 283
284 284
285} 285}
286void MainWindow::showMaximized () 286void MainWindow::showMaximized ()
287{ 287{
288#ifndef DESKTOP_VERSION 288#ifndef DESKTOP_VERSION
289 if ( ! globalFlagBlockStartup ) 289 if ( ! globalFlagBlockStartup )
290 if ( mClosed ) 290 if ( mClosed )
291 mView->goToday(); 291 mView->goToday();
292#endif 292#endif
293 QWidget::showMaximized () ; 293 QWidget::showMaximized () ;
294 mClosed = false; 294 mClosed = false;
295} 295}
296void MainWindow::closeEvent( QCloseEvent* ce ) 296void MainWindow::closeEvent( QCloseEvent* ce )
297{ 297{
298 298
299 299
300 300
301 if ( ! KOPrefs::instance()->mAskForQuit ) { 301 if ( ! KOPrefs::instance()->mAskForQuit ) {
302 saveOnClose(); 302 saveOnClose();
303 mClosed = true; 303 mClosed = true;
304 ce->accept(); 304 ce->accept();
305 return; 305 return;
306 306
307 } 307 }
308 308
309 switch( QMessageBox::information( this, "KO/Pi", 309 switch( QMessageBox::information( this, "KO/Pi",
310 i18n("Do you really want\nto close KO/Pi?"), 310 i18n("Do you really want\nto close KO/Pi?"),
311 i18n("Close"), i18n("No"), 311 i18n("Close"), i18n("No"),
312 0, 0 ) ) { 312 0, 0 ) ) {
313 case 0: 313 case 0:
314 saveOnClose(); 314 saveOnClose();
315 mClosed = true; 315 mClosed = true;
316 ce->accept(); 316 ce->accept();
317 break; 317 break;
318 case 1: 318 case 1:
319 ce->ignore(); 319 ce->ignore();
320 break; 320 break;
321 case 2: 321 case 2:
322 322
323 default: 323 default:
324 break; 324 break;
325 } 325 }
326 326
327 327
328} 328}
329 329
330void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 330void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
331{ 331{
332 QDataStream stream( data, IO_ReadOnly ); 332 QDataStream stream( data, IO_ReadOnly );
333 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 333 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
334 //QString datamess; 334 //QString datamess;
335 //qDebug("message "); 335 //qDebug("message ");
336 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 336 qDebug("KO: QCOP message received: %s ", cmsg.data() );
337 337
338 if ( cmsg == "-writeFile" ) { 338 if ( cmsg == "setDocument(QString)" ) {
339 // I made from the "-writeFile" an "-writeAlarm" 339 QDataStream stream( data, IO_ReadOnly );
340 mView->viewManager()->showWhatsNextView(); 340 QString fileName;
341 mCalendar->checkAlarmForIncidence( 0, true); 341 stream >> fileName;
342 showMaximized(); 342 qDebug("filename %s ", fileName.latin1());
343 raise(); 343 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
344 mSyncManager->slotSyncMenu( 1002 );
344 return; 345 return;
345 } 346 }
346 347
347 if ( cmsg == "-writeFile" ) { 348 if ( cmsg == "-writeFile" ) {
348 // I made from the "-writeFile" an "-writeAlarm" 349 // I made from the "-writeFile" an "-writeAlarm"
349 mView->viewManager()->showWhatsNextView(); 350 mView->viewManager()->showWhatsNextView();
350 mCalendar->checkAlarmForIncidence( 0, true); 351 mCalendar->checkAlarmForIncidence( 0, true);
351 showMaximized(); 352 showMaximized();
352 raise(); 353 raise();
353 return; 354 return;
354 355
355 } 356 }
356 if ( cmsg == "-writeFileSilent" ) { 357 if ( cmsg == "-writeFileSilent" ) {
357 // I made from the "-writeFile" an "-writeAlarm" 358 // I made from the "-writeFile" an "-writeAlarm"
358 // mView->viewManager()->showWhatsNextView(); 359 // mView->viewManager()->showWhatsNextView();
359 mCalendar->checkAlarmForIncidence( 0, true); 360 mCalendar->checkAlarmForIncidence( 0, true);
360 //showMaximized(); 361 //showMaximized();
361 //raise(); 362 //raise();
362 hide(); 363 hide();
363 return; 364 return;
364 } 365 }
365 if ( cmsg == "-newCountdown" ) { 366 if ( cmsg == "-newCountdown" ) {
366 qDebug("newCountdown "); 367 qDebug("newCountdown ");
367 368
368 } 369 }
369 QString msg ; 370 QString msg ;
370 QString allmsg = cmsg; 371 QString allmsg = cmsg;
371 while ( allmsg.length() > 0 ) { 372 while ( allmsg.length() > 0 ) {
372 int nextC = allmsg.find( "-", 1 ); 373 int nextC = allmsg.find( "-", 1 );
373 if ( nextC == -1 ) { 374 if ( nextC == -1 ) {
374 msg = allmsg; 375 msg = allmsg;
375 allmsg = ""; 376 allmsg = "";
376 } else{ 377 } else{
377 msg = allmsg.left( nextC ); 378 msg = allmsg.left( nextC );
378 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 379 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
379 } 380 }
380 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 381 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
381 if ( msg == "-newEvent" ) { 382 if ( msg == "-newEvent" ) {
382 mView->newEvent(); 383 mView->newEvent();
383 } 384 }
384 if ( msg == "-newTodo" ) { 385 if ( msg == "-newTodo" ) {
385 mView->newTodo(); 386 mView->newTodo();
386 387
387 } 388 }
388 if ( msg == "-showWN" ) { 389 if ( msg == "-showWN" ) {
389 mView->viewManager()->showWhatsNextView(); 390 mView->viewManager()->showWhatsNextView();
390 } 391 }
391 if ( msg == "-showTodo" ) { 392 if ( msg == "-showTodo" ) {
392 mView->viewManager()->showTodoView(); 393 mView->viewManager()->showTodoView();
393 } 394 }
394 if ( msg == "-showList" ) { 395 if ( msg == "-showList" ) {
395 mView->viewManager()->showListView(); 396 mView->viewManager()->showListView();
396 } 397 }
397 else if ( msg == "-showDay" ) { 398 else if ( msg == "-showDay" ) {
398 mView->viewManager()->showDayView(); 399 mView->viewManager()->showDayView();
399 } 400 }
400 else if ( msg == "-showWWeek" ) { 401 else if ( msg == "-showWWeek" ) {
401 mView->viewManager()->showWorkWeekView(); 402 mView->viewManager()->showWorkWeekView();
402 } 403 }
403 else if ( msg == "-ringSync" ) { 404 else if ( msg == "-ringSync" ) {
404 mSyncManager->multiSync( false ); 405 mSyncManager->multiSync( false );
405 } 406 }
406 else if ( msg == "-showWeek" ) { 407 else if ( msg == "-showWeek" ) {
407 mView->viewManager()->showWeekView(); 408 mView->viewManager()->showWeekView();
408 } 409 }
409 else if ( msg == "-showTodo" ) { 410 else if ( msg == "-showTodo" ) {
410 mView->viewManager()->showTodoView(); 411 mView->viewManager()->showTodoView();
411 } 412 }
412 else if ( msg == "-showJournal" ) { 413 else if ( msg == "-showJournal" ) {
413 mView->dateNavigator()->selectDates( 1 ); 414 mView->dateNavigator()->selectDates( 1 );
414 mView->dateNavigator()->selectToday(); 415 mView->dateNavigator()->selectToday();
415 mView->viewManager()->showJournalView(); 416 mView->viewManager()->showJournalView();
416 } 417 }
417 else if ( msg == "-showKO" ) { 418 else if ( msg == "-showKO" ) {
418 mView->viewManager()->showNextXView(); 419 mView->viewManager()->showNextXView();
419 } 420 }
420 else if ( msg == "-showWNext" || msg == "nextView()" ) { 421 else if ( msg == "-showWNext" || msg == "nextView()" ) {
421 mView->viewManager()->showWhatsNextView(); 422 mView->viewManager()->showWhatsNextView();
422 } 423 }
423 else if ( msg == "-showNextXView" ) { 424 else if ( msg == "-showNextXView" ) {
424 mView->viewManager()->showNextXView(); 425 mView->viewManager()->showNextXView();
425 } 426 }
426 427
427 428
428 } 429 }
429 430
430 showMaximized(); 431 showMaximized();
431 raise(); 432 raise();
432} 433}
433 434
434QPixmap MainWindow::loadPixmap( QString name ) 435QPixmap MainWindow::loadPixmap( QString name )
435{ 436{
436 return SmallIcon( name ); 437 return SmallIcon( name );
437 438
438} 439}
439void MainWindow::initActions() 440void MainWindow::initActions()
440{ 441{
441 //KOPrefs::instance()->mShowFullMenu 442 //KOPrefs::instance()->mShowFullMenu
442 iconToolBar->clear(); 443 iconToolBar->clear();
443 KOPrefs *p = KOPrefs::instance(); 444 KOPrefs *p = KOPrefs::instance();
444 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 445 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
445 446
446 QPopupMenu *viewMenu = new QPopupMenu( this ); 447 QPopupMenu *viewMenu = new QPopupMenu( this );
447 QPopupMenu *actionMenu = new QPopupMenu( this ); 448 QPopupMenu *actionMenu = new QPopupMenu( this );
448 QPopupMenu *importMenu = new QPopupMenu( this ); 449 QPopupMenu *importMenu = new QPopupMenu( this );
449 selectFilterMenu = new QPopupMenu( this ); 450 selectFilterMenu = new QPopupMenu( this );
450 selectFilterMenu->setCheckable( true ); 451 selectFilterMenu->setCheckable( true );
451 syncMenu = new QPopupMenu( this ); 452 syncMenu = new QPopupMenu( this );
452 configureAgendaMenu = new QPopupMenu( this ); 453 configureAgendaMenu = new QPopupMenu( this );
453 configureToolBarMenu = new QPopupMenu( this ); 454 configureToolBarMenu = new QPopupMenu( this );
454 QPopupMenu *helpMenu = new QPopupMenu( this ); 455 QPopupMenu *helpMenu = new QPopupMenu( this );
455 if ( KOPrefs::instance()->mShowFullMenu ) { 456 if ( KOPrefs::instance()->mShowFullMenu ) {
456 QMenuBar *menuBar1; 457 QMenuBar *menuBar1;
457 menuBar1 = menuBar(); 458 menuBar1 = menuBar();
458 menuBar1->insertItem( i18n("File"), importMenu ); 459 menuBar1->insertItem( i18n("File"), importMenu );
459 menuBar1->insertItem( i18n("View"), viewMenu ); 460 menuBar1->insertItem( i18n("View"), viewMenu );
460 menuBar1->insertItem( i18n("Actions"), actionMenu ); 461 menuBar1->insertItem( i18n("Actions"), actionMenu );
461 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 462 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
462 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 463 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
463 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 464 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
464 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 465 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
465 menuBar1->insertItem( i18n("Help"), helpMenu ); 466 menuBar1->insertItem( i18n("Help"), helpMenu );
466 } else { 467 } else {
467 QPEMenuBar *menuBar1; 468 QPEMenuBar *menuBar1;
468 menuBar1 = new QPEMenuBar( iconToolBar ); 469 menuBar1 = new QPEMenuBar( iconToolBar );
469 QPopupMenu *menuBar = new QPopupMenu( this ); 470 QPopupMenu *menuBar = new QPopupMenu( this );
470 menuBar1->insertItem( i18n("ME"), menuBar); 471 menuBar1->insertItem( i18n("ME"), menuBar);
471 menuBar->insertItem( i18n("File"), importMenu ); 472 menuBar->insertItem( i18n("File"), importMenu );
472 menuBar->insertItem( i18n("View"), viewMenu ); 473 menuBar->insertItem( i18n("View"), viewMenu );
473 menuBar->insertItem( i18n("Actions"), actionMenu ); 474 menuBar->insertItem( i18n("Actions"), actionMenu );
474 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 475 menuBar->insertItem( i18n("Synchronize"), syncMenu );
475 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 476 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
476 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 477 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
477 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 478 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
478 menuBar->insertItem( i18n("Help"), helpMenu ); 479 menuBar->insertItem( i18n("Help"), helpMenu );
479 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 480 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
480 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 481 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
481 } 482 }
482 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 483 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
483 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 484 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
484 485
485 // ****************** 486 // ******************
486 QAction *action; 487 QAction *action;
487 QIconSet icon; 488 QIconSet icon;
488 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 489 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
489 configureToolBarMenu->setCheckable( true ); 490 configureToolBarMenu->setCheckable( true );
490 491
491 QString pathString = ""; 492 QString pathString = "";
492 if ( !p->mToolBarMiniIcons ) { 493 if ( !p->mToolBarMiniIcons ) {
493 if ( QApplication::desktop()->width() < 480 ) 494 if ( QApplication::desktop()->width() < 480 )
494 pathString += "icons16/"; 495 pathString += "icons16/";
495 } else 496 } else
496 pathString += "iconsmini/"; 497 pathString += "iconsmini/";
497 configureAgendaMenu->setCheckable( true ); 498 configureAgendaMenu->setCheckable( true );
498 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 499 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
499 configureAgendaMenu->insertSeparator(); 500 configureAgendaMenu->insertSeparator();
500 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 501 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
501 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 502 configureAgendaMenu->insertItem(i18n("Small"), 6 );
502 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 503 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
503 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 504 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
504 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 505 configureAgendaMenu->insertItem(i18n("Large"), 12 );
505 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 506 configureAgendaMenu->insertItem(i18n("Big"), 14 );
506 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 507 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
507 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 508 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
508 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 509 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
509 510
510 icon = loadPixmap( pathString + "configure" ); 511 icon = loadPixmap( pathString + "configure" );
511 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 512 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
512 action->addTo( actionMenu ); 513 action->addTo( actionMenu );
513 connect( action, SIGNAL( activated() ), 514 connect( action, SIGNAL( activated() ),
514 mView, SLOT( edit_options() ) ); 515 mView, SLOT( edit_options() ) );
515 actionMenu->insertSeparator(); 516 actionMenu->insertSeparator();
516 icon = loadPixmap( pathString + "newevent" ); 517 icon = loadPixmap( pathString + "newevent" );
517 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 518 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
518 configureToolBarMenu->insertSeparator(); 519 configureToolBarMenu->insertSeparator();
519 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 520 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
520 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 521 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
521 ne_action->addTo( actionMenu ); 522 ne_action->addTo( actionMenu );
522 connect( ne_action, SIGNAL( activated() ), 523 connect( ne_action, SIGNAL( activated() ),
523 mView, SLOT( newEvent() ) ); 524 mView, SLOT( newEvent() ) );
524 icon = loadPixmap( pathString + "newtodo" ); 525 icon = loadPixmap( pathString + "newtodo" );
525 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 526 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
526 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 527 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
527 nt_action->addTo( actionMenu ); 528 nt_action->addTo( actionMenu );
528 connect( nt_action, SIGNAL( activated() ), 529 connect( nt_action, SIGNAL( activated() ),
529 mView, SLOT( newTodo() ) ); 530 mView, SLOT( newTodo() ) );
530 icon = loadPixmap( pathString + "navi" ); 531 icon = loadPixmap( pathString + "navi" );
531 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 532 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
532 action->addTo( viewMenu ); 533 action->addTo( viewMenu );
533 connect( action, SIGNAL( activated() ), 534 connect( action, SIGNAL( activated() ),
534 mView, SLOT( toggleDateNavigatorWidget() ) ); 535 mView, SLOT( toggleDateNavigatorWidget() ) );
535 icon = loadPixmap( pathString + "filter" ); 536 icon = loadPixmap( pathString + "filter" );
536 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 537 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
537 action->addTo( viewMenu ); 538 action->addTo( viewMenu );
538 connect( action, SIGNAL( activated() ), 539 connect( action, SIGNAL( activated() ),
539 mView, SLOT( toggleFilter() ) ); 540 mView, SLOT( toggleFilter() ) );
540 541
541 542
542 viewMenu->insertSeparator(); 543 viewMenu->insertSeparator();
543 icon = loadPixmap( pathString + "picker" ); 544 icon = loadPixmap( pathString + "picker" );
544 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 545 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
545 action->addTo( viewMenu ); 546 action->addTo( viewMenu );
546 connect( action, SIGNAL( activated() ), 547 connect( action, SIGNAL( activated() ),
547 mView, SLOT( showDatePicker() ) ); 548 mView, SLOT( showDatePicker() ) );
548 action->addTo( iconToolBar ); 549 action->addTo( iconToolBar );
549 viewMenu->insertSeparator(); 550 viewMenu->insertSeparator();
550 icon = loadPixmap( pathString + "list" ); 551 icon = loadPixmap( pathString + "list" );
551 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 552 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
552 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 553 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
553 showlist_action->addTo( viewMenu ); 554 showlist_action->addTo( viewMenu );
554 connect( showlist_action, SIGNAL( activated() ), 555 connect( showlist_action, SIGNAL( activated() ),
555 mView->viewManager(), SLOT( showListView() ) ); 556 mView->viewManager(), SLOT( showListView() ) );
556 557
557 558
558 icon = loadPixmap( pathString + "day" ); 559 icon = loadPixmap( pathString + "day" );
559 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 560 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
560 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 561 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
561 day1_action->addTo( viewMenu ); 562 day1_action->addTo( viewMenu );
562 // action->addTo( toolBar ); 563 // action->addTo( toolBar );
563 connect( day1_action, SIGNAL( activated() ), 564 connect( day1_action, SIGNAL( activated() ),
564 mView->viewManager(), SLOT( showDayView() ) ); 565 mView->viewManager(), SLOT( showDayView() ) );
565 566
566 icon = loadPixmap( pathString + "workweek" ); 567 icon = loadPixmap( pathString + "workweek" );
567 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 568 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
568 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 569 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
569 day5_action->addTo( viewMenu ); 570 day5_action->addTo( viewMenu );
570 connect( day5_action, SIGNAL( activated() ), 571 connect( day5_action, SIGNAL( activated() ),
571 mView->viewManager(), SLOT( showWorkWeekView() ) ); 572 mView->viewManager(), SLOT( showWorkWeekView() ) );
572 573
573 icon = loadPixmap( pathString + "week" ); 574 icon = loadPixmap( pathString + "week" );
574 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 575 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
575 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 576 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
576 day7_action->addTo( viewMenu ); 577 day7_action->addTo( viewMenu );
577 connect( day7_action, SIGNAL( activated() ), 578 connect( day7_action, SIGNAL( activated() ),
578 mView->viewManager(), SLOT( showWeekView() ) ); 579 mView->viewManager(), SLOT( showWeekView() ) );
579 580
580 icon = loadPixmap( pathString + "month" ); 581 icon = loadPixmap( pathString + "month" );
581 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 582 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
582 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 583 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
583 month_action->addTo( viewMenu ); 584 month_action->addTo( viewMenu );
584 connect( month_action, SIGNAL( activated() ), 585 connect( month_action, SIGNAL( activated() ),
585 mView->viewManager(), SLOT( showMonthView() ) ); 586 mView->viewManager(), SLOT( showMonthView() ) );
586 587
587 icon = loadPixmap( pathString + "todo" ); 588 icon = loadPixmap( pathString + "todo" );
588 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 589 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
589 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 590 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
590 todoview_action->addTo( viewMenu ); 591 todoview_action->addTo( viewMenu );
591 connect( todoview_action, SIGNAL( activated() ), 592 connect( todoview_action, SIGNAL( activated() ),
592 mView->viewManager(), SLOT( showTodoView() ) ); 593 mView->viewManager(), SLOT( showTodoView() ) );
593 594
594 icon = loadPixmap( pathString + "journal" ); 595 icon = loadPixmap( pathString + "journal" );
595 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 596 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
596 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 597 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
597 viewjournal_action->addTo( viewMenu ); 598 viewjournal_action->addTo( viewMenu );
598 connect( viewjournal_action, SIGNAL( activated() ), 599 connect( viewjournal_action, SIGNAL( activated() ),
599 mView->viewManager(), SLOT( showJournalView() ) ); 600 mView->viewManager(), SLOT( showJournalView() ) );
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 08b1a3d..80fb147 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,625 +1,629 @@
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 51
52#include <klocale.h> 52#include <klocale.h>
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kconfig.h> 54#include <kconfig.h>
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79 79
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 prof << i18n("Last_file"); 104 prof << i18n("Last_file");
105 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
106 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
107 temp->writeConfig(&config); 107 temp->writeConfig(&config);
108 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
109 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] ); 110 temp->setName( prof[2] );
111 temp->writeConfig(&config); 111 temp->writeConfig(&config);
112 config.setGroup("General"); 112 config.setGroup("General");
113 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
114 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
115 config.sync(); 115 config.sync();
116 delete temp; 116 delete temp;
117 } 117 }
118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
119 mSyncProfileNames = prof; 119 mSyncProfileNames = prof;
120 unsigned int i; 120 unsigned int i;
121 for ( i = 0; i < prof.count(); ++i ) { 121 for ( i = 0; i < prof.count(); ++i ) {
122 mSyncMenu->insertItem( prof[i], 1000+i ); 122 mSyncMenu->insertItem( prof[i], 1000+i );
123 if ( i == 2 ) 123 if ( i == 2 )
124 mSyncMenu->insertSeparator(); 124 mSyncMenu->insertSeparator();
125 } 125 }
126 QDir app_dir; 126 QDir app_dir;
127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
128 if ( mTargetApp == PWMPI) { 128 if ( mTargetApp == PWMPI) {
129 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
130 } 130 }
131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
132 mSyncMenu->removeItem( 1000 ); 132 mSyncMenu->removeItem( 1000 );
133 } 133 }
134 mSyncMenu->removeItem( 1002 ); 134 mSyncMenu->removeItem( 1002 );
135} 135}
136 136
137void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
138{ 138{
139 //qDebug("syncaction %d ", action); 139 //qDebug("syncaction %d ", action);
140 if ( action == 0 ) { 140 if ( action == 0 ) {
141 141
142 // seems to be a Qt2 event handling bug 142 // seems to be a Qt2 event handling bug
143 // syncmenu.clear causes a segfault at first time 143 // syncmenu.clear causes a segfault at first time
144 // when we call it after the main event loop, it is ok 144 // when we call it after the main event loop, it is ok
145 // same behaviour when calling OM/Pi via QCOP for the first time 145 // same behaviour when calling OM/Pi via QCOP for the first time
146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
147 //confSync(); 147 //confSync();
148 148
149 return; 149 return;
150 } 150 }
151 if ( action == 1 ) { 151 if ( action == 1 ) {
152 multiSync( true ); 152 multiSync( true );
153 return; 153 return;
154 } 154 }
155 if ( action == 2 ) { 155 if ( action == 2 ) {
156 enableQuick(); 156 enableQuick();
157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
158 return; 158 return;
159 } 159 }
160 if ( action == 3 ) { 160 if ( action == 3 ) {
161 delete mServerSocket; 161 delete mServerSocket;
162 mServerSocket = 0; 162 mServerSocket = 0;
163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
164 return; 164 return;
165 } 165 }
166 166
167 if (blockSave()) 167 if (blockSave())
168 return; 168 return;
169 169
170 setBlockSave(true); 170 setBlockSave(true);
171 171
172 mCurrentSyncProfile = action - 1000 ; 172 mCurrentSyncProfile = action - 1000 ;
173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
174 mCurrentSyncName = mLocalMachineName ; 174 mCurrentSyncName = mLocalMachineName ;
175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
176 KSyncProfile* temp = new KSyncProfile (); 176 KSyncProfile* temp = new KSyncProfile ();
177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
178 temp->readConfig(&config); 178 temp->readConfig(&config);
179 mAskForPreferences = temp->getAskForPreferences(); 179 mAskForPreferences = temp->getAskForPreferences();
180 mSyncAlgoPrefs = temp->getSyncPrefs(); 180 mSyncAlgoPrefs = temp->getSyncPrefs();
181 mWriteBackFile = temp->getWriteBackFile(); 181 mWriteBackFile = temp->getWriteBackFile();
182 mWriteBackExistingOnly = temp->getWriteBackExisting(); 182 mWriteBackExistingOnly = temp->getWriteBackExisting();
183 mWriteBackInFuture = 0; 183 mWriteBackInFuture = 0;
184 if ( temp->getWriteBackFuture() ) 184 if ( temp->getWriteBackFuture() )
185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
186 mShowSyncSummary = temp->getShowSummaryAfterSync(); 186 mShowSyncSummary = temp->getShowSummaryAfterSync();
187 if ( action == 1000 ) { 187 if ( action == 1000 ) {
188 syncSharp(); 188 syncSharp();
189 189
190 } else if ( action == 1001 ) { 190 } else if ( action == 1001 ) {
191 syncLocalFile(); 191 syncLocalFile();
192 192
193 } else if ( action == 1002 ) { 193 } else if ( action == 1002 ) {
194 mWriteBackFile = false;
195 mAskForPreferences = false;
196 mShowSyncSummary = false;
197 mSyncAlgoPrefs = 3;
194 quickSyncLocalFile(); 198 quickSyncLocalFile();
195 199
196 } else if ( action >= 1003 ) { 200 } else if ( action >= 1003 ) {
197 if ( temp->getIsLocalFileSync() ) { 201 if ( temp->getIsLocalFileSync() ) {
198 switch(mTargetApp) 202 switch(mTargetApp)
199 { 203 {
200 case (KAPI): 204 case (KAPI):
201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
202 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
203 break; 207 break;
204 case (KOPI): 208 case (KOPI):
205 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
207 break; 211 break;
208 case (PWMPI): 212 case (PWMPI):
209 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 213 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 214 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
211 break; 215 break;
212 default: 216 default:
213 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 217 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
214 break; 218 break;
215 219
216 } 220 }
217 } else { 221 } else {
218 if ( temp->getIsPhoneSync() ) { 222 if ( temp->getIsPhoneSync() ) {
219 mPhoneDevice = temp->getPhoneDevice( ) ; 223 mPhoneDevice = temp->getPhoneDevice( ) ;
220 mPhoneConnection = temp->getPhoneConnection( ); 224 mPhoneConnection = temp->getPhoneConnection( );
221 mPhoneModel = temp->getPhoneModel( ); 225 mPhoneModel = temp->getPhoneModel( );
222 syncPhone(); 226 syncPhone();
223 } else if ( temp->getIsPiSync() ) { 227 } else if ( temp->getIsPiSync() ) {
224 if ( mTargetApp == KAPI ) { 228 if ( mTargetApp == KAPI ) {
225 mPassWordPiSync = temp->getRemotePwAB(); 229 mPassWordPiSync = temp->getRemotePwAB();
226 mActiveSyncPort = temp->getRemotePortAB(); 230 mActiveSyncPort = temp->getRemotePortAB();
227 mActiveSyncIP = temp->getRemoteIPAB(); 231 mActiveSyncIP = temp->getRemoteIPAB();
228 } else if ( mTargetApp == KOPI ) { 232 } else if ( mTargetApp == KOPI ) {
229 mPassWordPiSync = temp->getRemotePw(); 233 mPassWordPiSync = temp->getRemotePw();
230 mActiveSyncPort = temp->getRemotePort(); 234 mActiveSyncPort = temp->getRemotePort();
231 mActiveSyncIP = temp->getRemoteIP(); 235 mActiveSyncIP = temp->getRemoteIP();
232 } else { 236 } else {
233 mPassWordPiSync = temp->getRemotePwPWM(); 237 mPassWordPiSync = temp->getRemotePwPWM();
234 mActiveSyncPort = temp->getRemotePortPWM(); 238 mActiveSyncPort = temp->getRemotePortPWM();
235 mActiveSyncIP = temp->getRemoteIPPWM(); 239 mActiveSyncIP = temp->getRemoteIPPWM();
236 } 240 }
237 syncPi(); 241 syncPi();
238 } else 242 } else
239 syncRemote( temp ); 243 syncRemote( temp );
240 244
241 } 245 }
242 } 246 }
243 delete temp; 247 delete temp;
244 setBlockSave(false); 248 setBlockSave(false);
245} 249}
246 250
247void KSyncManager::enableQuick() 251void KSyncManager::enableQuick()
248{ 252{
249 QDialog dia ( 0, "input-dialog", true ); 253 QDialog dia ( 0, "input-dialog", true );
250 QLineEdit lab ( &dia ); 254 QLineEdit lab ( &dia );
251 QVBoxLayout lay( &dia ); 255 QVBoxLayout lay( &dia );
252 lab.setText( mPrefs->mPassiveSyncPort ); 256 lab.setText( mPrefs->mPassiveSyncPort );
253 lay.setMargin(7); 257 lay.setMargin(7);
254 lay.setSpacing(7); 258 lay.setSpacing(7);
255 int po = 9197+mTargetApp; 259 int po = 9197+mTargetApp;
256 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 260 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
257 lay.addWidget( &label); 261 lay.addWidget( &label);
258 lay.addWidget( &lab); 262 lay.addWidget( &lab);
259 263
260 QLineEdit lepw ( &dia ); 264 QLineEdit lepw ( &dia );
261 lepw.setText( mPrefs->mPassiveSyncPw ); 265 lepw.setText( mPrefs->mPassiveSyncPw );
262 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 266 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
263 lay.addWidget( &label2); 267 lay.addWidget( &label2);
264 lay.addWidget( &lepw); 268 lay.addWidget( &lepw);
265 dia.setFixedSize( 230,80 ); 269 dia.setFixedSize( 230,80 );
266 dia.setCaption( i18n("Enter port for Pi-Sync") ); 270 dia.setCaption( i18n("Enter port for Pi-Sync") );
267 QPushButton pb ( "OK", &dia); 271 QPushButton pb ( "OK", &dia);
268 lay.addWidget( &pb ); 272 lay.addWidget( &pb );
269 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 273 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
270 dia.show(); 274 dia.show();
271 if ( ! dia.exec() ) 275 if ( ! dia.exec() )
272 return; 276 return;
273 dia.hide(); 277 dia.hide();
274 qApp->processEvents(); 278 qApp->processEvents();
275 mPrefs->mPassiveSyncPw = lepw.text(); 279 mPrefs->mPassiveSyncPw = lepw.text();
276 mPrefs->mPassiveSyncPort = lab.text(); 280 mPrefs->mPassiveSyncPort = lab.text();
277 bool ok; 281 bool ok;
278 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 282 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
279 if ( ! ok ) { 283 if ( ! ok ) {
280 KMessageBox::information( 0, i18n("No valid port")); 284 KMessageBox::information( 0, i18n("No valid port"));
281 return; 285 return;
282 } 286 }
283 //qDebug("port %d ", port); 287 //qDebug("port %d ", port);
284 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 288 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
285 mServerSocket->setFileName( defaultFileName() ); 289 mServerSocket->setFileName( defaultFileName() );
286 //qDebug("connected "); 290 //qDebug("connected ");
287 if ( !mServerSocket->ok() ) { 291 if ( !mServerSocket->ok() ) {
288 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 292 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
289 delete mServerSocket; 293 delete mServerSocket;
290 mServerSocket = 0; 294 mServerSocket = 0;
291 return; 295 return;
292 } 296 }
293 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 297 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
294 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 298 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
295} 299}
296 300
297void KSyncManager::syncLocalFile() 301void KSyncManager::syncLocalFile()
298{ 302{
299 303
300 QString fn =mPrefs->mLastSyncedLocalFile; 304 QString fn =mPrefs->mLastSyncedLocalFile;
301 QString ext; 305 QString ext;
302 306
303 switch(mTargetApp) 307 switch(mTargetApp)
304 { 308 {
305 case (KAPI): 309 case (KAPI):
306 ext = "(*.vcf)"; 310 ext = "(*.vcf)";
307 break; 311 break;
308 case (KOPI): 312 case (KOPI):
309 ext = "(*.ics/*.vcs)"; 313 ext = "(*.ics/*.vcs)";
310 break; 314 break;
311 case (PWMPI): 315 case (PWMPI):
312 ext = "(*.pwm)"; 316 ext = "(*.pwm)";
313 break; 317 break;
314 default: 318 default:
315 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 319 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
316 break; 320 break;
317 321
318 } 322 }
319 323
320 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 324 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
321 if ( fn == "" ) 325 if ( fn == "" )
322 return; 326 return;
323 if ( syncWithFile( fn, false ) ) { 327 if ( syncWithFile( fn, false ) ) {
324 qDebug("syncLocalFile() successful "); 328 qDebug("syncLocalFile() successful ");
325 } 329 }
326 330
327} 331}
328 332
329bool KSyncManager::syncWithFile( QString fn , bool quick ) 333bool KSyncManager::syncWithFile( QString fn , bool quick )
330{ 334{
331 bool ret = false; 335 bool ret = false;
332 QFileInfo info; 336 QFileInfo info;
333 info.setFile( fn ); 337 info.setFile( fn );
334 QString mess; 338 QString mess;
335 bool loadbup = true; 339 bool loadbup = true;
336 if ( !info. exists() ) { 340 if ( !info. exists() ) {
337 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 341 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
338 int result = QMessageBox::warning( mParent, i18n("Warning!"), 342 int result = QMessageBox::warning( mParent, i18n("Warning!"),
339 mess ); 343 mess );
340 return ret; 344 return ret;
341 } 345 }
342 int result = 0; 346 int result = 0;
343 if ( !quick ) { 347 if ( !quick ) {
344 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 348 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
345 result = QMessageBox::warning( mParent, i18n("Warning!"), 349 result = QMessageBox::warning( mParent, i18n("Warning!"),
346 mess, 350 mess,
347 i18n("Sync"), i18n("Cancel"), 0, 351 i18n("Sync"), i18n("Cancel"), 0,
348 0, 1 ); 352 0, 1 );
349 if ( result ) 353 if ( result )
350 return false; 354 return false;
351 } 355 }
352 if ( mAskForPreferences ) 356 if ( mAskForPreferences )
353 edit_sync_options(); 357 edit_sync_options();
354 if ( result == 0 ) { 358 if ( result == 0 ) {
355 //qDebug("Now sycing ... "); 359 //qDebug("Now sycing ... ");
356 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 360 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
357 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 361 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
358 else 362 else
359 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 363 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
360 if ( ! quick ) 364 if ( ! quick )
361 mPrefs->mLastSyncedLocalFile = fn; 365 mPrefs->mLastSyncedLocalFile = fn;
362 } 366 }
363 return ret; 367 return ret;
364} 368}
365 369
366void KSyncManager::quickSyncLocalFile() 370void KSyncManager::quickSyncLocalFile()
367{ 371{
368 372
369 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { 373 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
370 qDebug("quick syncLocalFile() successful "); 374 qDebug("quick syncLocalFile() successful ");
371 375
372 } 376 }
373} 377}
374 378
375void KSyncManager::multiSync( bool askforPrefs ) 379void KSyncManager::multiSync( bool askforPrefs )
376{ 380{
377 if (blockSave()) 381 if (blockSave())
378 return; 382 return;
379 setBlockSave(true); 383 setBlockSave(true);
380 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 384 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
381 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 385 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
382 question, 386 question,
383 i18n("Yes"), i18n("No"), 387 i18n("Yes"), i18n("No"),
384 0, 0 ) != 0 ) { 388 0, 0 ) != 0 ) {
385 setBlockSave(false); 389 setBlockSave(false);
386 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 390 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
387 return; 391 return;
388 } 392 }
389 mCurrentSyncDevice = i18n("Multiple profiles") ; 393 mCurrentSyncDevice = i18n("Multiple profiles") ;
390 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 394 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
391 if ( askforPrefs ) { 395 if ( askforPrefs ) {
392 edit_sync_options(); 396 edit_sync_options();
393 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 397 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
394 } 398 }
395 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 399 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
396 qApp->processEvents(); 400 qApp->processEvents();
397 int num = ringSync() ; 401 int num = ringSync() ;
398 if ( num > 1 ) 402 if ( num > 1 )
399 ringSync(); 403 ringSync();
400 setBlockSave(false); 404 setBlockSave(false);
401 if ( num ) 405 if ( num )
402 emit save(); 406 emit save();
403 if ( num ) 407 if ( num )
404 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 408 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
405 else 409 else
406 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 410 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
407 return; 411 return;
408} 412}
409 413
410int KSyncManager::ringSync() 414int KSyncManager::ringSync()
411{ 415{
412 int syncedProfiles = 0; 416 int syncedProfiles = 0;
413 unsigned int i; 417 unsigned int i;
414 QTime timer; 418 QTime timer;
415 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 419 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
416 QStringList syncProfileNames = mSyncProfileNames; 420 QStringList syncProfileNames = mSyncProfileNames;
417 KSyncProfile* temp = new KSyncProfile (); 421 KSyncProfile* temp = new KSyncProfile ();
418 mAskForPreferences = false; 422 mAskForPreferences = false;
419 for ( i = 0; i < syncProfileNames.count(); ++i ) { 423 for ( i = 0; i < syncProfileNames.count(); ++i ) {
420 mCurrentSyncProfile = i; 424 mCurrentSyncProfile = i;
421 temp->setName(syncProfileNames[mCurrentSyncProfile]); 425 temp->setName(syncProfileNames[mCurrentSyncProfile]);
422 temp->readConfig(&config); 426 temp->readConfig(&config);
423 427
424 bool includeInRingSync; 428 bool includeInRingSync;
425 switch(mTargetApp) 429 switch(mTargetApp)
426 { 430 {
427 case (KAPI): 431 case (KAPI):
428 includeInRingSync = temp->getIncludeInRingSyncAB(); 432 includeInRingSync = temp->getIncludeInRingSyncAB();
429 break; 433 break;
430 case (KOPI): 434 case (KOPI):
431 includeInRingSync = temp->getIncludeInRingSync(); 435 includeInRingSync = temp->getIncludeInRingSync();
432 break; 436 break;
433 case (PWMPI): 437 case (PWMPI):
434 includeInRingSync = temp->getIncludeInRingSyncPWM(); 438 includeInRingSync = temp->getIncludeInRingSyncPWM();
435 break; 439 break;
436 default: 440 default:
437 qDebug("KSyncManager::ringSync: invalid apptype selected"); 441 qDebug("KSyncManager::ringSync: invalid apptype selected");
438 break; 442 break;
439 443
440 } 444 }
441 445
442 446
443 if ( includeInRingSync && ( i < 1 || i > 2 )) { 447 if ( includeInRingSync && ( i < 1 || i > 2 )) {
444 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 448 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
445 ++syncedProfiles; 449 ++syncedProfiles;
446 // mAskForPreferences = temp->getAskForPreferences(); 450 // mAskForPreferences = temp->getAskForPreferences();
447 mWriteBackFile = temp->getWriteBackFile(); 451 mWriteBackFile = temp->getWriteBackFile();
448 mWriteBackExistingOnly = temp->getWriteBackExisting(); 452 mWriteBackExistingOnly = temp->getWriteBackExisting();
449 mWriteBackInFuture = 0; 453 mWriteBackInFuture = 0;
450 if ( temp->getWriteBackFuture() ) 454 if ( temp->getWriteBackFuture() )
451 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 455 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
452 mShowSyncSummary = false; 456 mShowSyncSummary = false;
453 mCurrentSyncDevice = syncProfileNames[i] ; 457 mCurrentSyncDevice = syncProfileNames[i] ;
454 mCurrentSyncName = mLocalMachineName; 458 mCurrentSyncName = mLocalMachineName;
455 if ( i == 0 ) { 459 if ( i == 0 ) {
456 syncSharp(); 460 syncSharp();
457 } else { 461 } else {
458 if ( temp->getIsLocalFileSync() ) { 462 if ( temp->getIsLocalFileSync() ) {
459 switch(mTargetApp) 463 switch(mTargetApp)
460 { 464 {
461 case (KAPI): 465 case (KAPI):
462 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
463 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
464 break; 468 break;
465 case (KOPI): 469 case (KOPI):
466 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 470 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
468 break; 472 break;
469 case (PWMPI): 473 case (PWMPI):
470 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 474 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 475 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
472 break; 476 break;
473 default: 477 default:
474 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 478 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
475 break; 479 break;
476 } 480 }
477 } else { 481 } else {
478 if ( temp->getIsPhoneSync() ) { 482 if ( temp->getIsPhoneSync() ) {
479 mPhoneDevice = temp->getPhoneDevice( ) ; 483 mPhoneDevice = temp->getPhoneDevice( ) ;
480 mPhoneConnection = temp->getPhoneConnection( ); 484 mPhoneConnection = temp->getPhoneConnection( );
481 mPhoneModel = temp->getPhoneModel( ); 485 mPhoneModel = temp->getPhoneModel( );
482 syncPhone(); 486 syncPhone();
483 } else if ( temp->getIsPiSync() ) { 487 } else if ( temp->getIsPiSync() ) {
484 if ( mTargetApp == KAPI ) { 488 if ( mTargetApp == KAPI ) {
485 mPassWordPiSync = temp->getRemotePwAB(); 489 mPassWordPiSync = temp->getRemotePwAB();
486 mActiveSyncPort = temp->getRemotePortAB(); 490 mActiveSyncPort = temp->getRemotePortAB();
487 mActiveSyncIP = temp->getRemoteIPAB(); 491 mActiveSyncIP = temp->getRemoteIPAB();
488 } else if ( mTargetApp == KOPI ) { 492 } else if ( mTargetApp == KOPI ) {
489 mPassWordPiSync = temp->getRemotePw(); 493 mPassWordPiSync = temp->getRemotePw();
490 mActiveSyncPort = temp->getRemotePort(); 494 mActiveSyncPort = temp->getRemotePort();
491 mActiveSyncIP = temp->getRemoteIP(); 495 mActiveSyncIP = temp->getRemoteIP();
492 } else { 496 } else {
493 mPassWordPiSync = temp->getRemotePwPWM(); 497 mPassWordPiSync = temp->getRemotePwPWM();
494 mActiveSyncPort = temp->getRemotePortPWM(); 498 mActiveSyncPort = temp->getRemotePortPWM();
495 mActiveSyncIP = temp->getRemoteIPPWM(); 499 mActiveSyncIP = temp->getRemoteIPPWM();
496 } 500 }
497 syncPi(); 501 syncPi();
498 } else 502 } else
499 syncRemote( temp, false ); 503 syncRemote( temp, false );
500 504
501 } 505 }
502 } 506 }
503 timer.start(); 507 timer.start();
504 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 508 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
505 while ( timer.elapsed () < 2000 ) { 509 while ( timer.elapsed () < 2000 ) {
506 qApp->processEvents(); 510 qApp->processEvents();
507#ifndef _WIN32_ 511#ifndef _WIN32_
508 sleep (1); 512 sleep (1);
509#endif 513#endif
510 } 514 }
511 515
512 } 516 }
513 517
514 } 518 }
515 delete temp; 519 delete temp;
516 return syncedProfiles; 520 return syncedProfiles;
517} 521}
518 522
519void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 523void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
520{ 524{
521 QString question; 525 QString question;
522 if ( ask ) { 526 if ( ask ) {
523 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 527 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
524 if ( QMessageBox::information( mParent, i18n("Sync"), 528 if ( QMessageBox::information( mParent, i18n("Sync"),
525 question, 529 question,
526 i18n("Yes"), i18n("No"), 530 i18n("Yes"), i18n("No"),
527 0, 0 ) != 0 ) 531 0, 0 ) != 0 )
528 return; 532 return;
529 } 533 }
530 534
531 QString preCommand; 535 QString preCommand;
532 QString localTempFile; 536 QString localTempFile;
533 QString postCommand; 537 QString postCommand;
534 538
535 switch(mTargetApp) 539 switch(mTargetApp)
536 { 540 {
537 case (KAPI): 541 case (KAPI):
538 preCommand = prof->getPreSyncCommandAB(); 542 preCommand = prof->getPreSyncCommandAB();
539 postCommand = prof->getPostSyncCommandAB(); 543 postCommand = prof->getPostSyncCommandAB();
540 localTempFile = prof->getLocalTempFileAB(); 544 localTempFile = prof->getLocalTempFileAB();
541 break; 545 break;
542 case (KOPI): 546 case (KOPI):
543 preCommand = prof->getPreSyncCommand(); 547 preCommand = prof->getPreSyncCommand();
544 postCommand = prof->getPostSyncCommand(); 548 postCommand = prof->getPostSyncCommand();
545 localTempFile = prof->getLocalTempFile(); 549 localTempFile = prof->getLocalTempFile();
546 break; 550 break;
547 case (PWMPI): 551 case (PWMPI):
548 preCommand = prof->getPreSyncCommandPWM(); 552 preCommand = prof->getPreSyncCommandPWM();
549 postCommand = prof->getPostSyncCommandPWM(); 553 postCommand = prof->getPostSyncCommandPWM();
550 localTempFile = prof->getLocalTempFilePWM(); 554 localTempFile = prof->getLocalTempFilePWM();
551 break; 555 break;
552 default: 556 default:
553 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 557 qDebug("KSyncManager::syncRemote: invalid apptype selected");
554 break; 558 break;
555 } 559 }
556 560
557 561
558 int fi; 562 int fi;
559 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 563 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
560 QString pwd = getPassword(); 564 QString pwd = getPassword();
561 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 565 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
562 566
563 } 567 }
564 int maxlen = 30; 568 int maxlen = 30;
565 if ( QApplication::desktop()->width() > 320 ) 569 if ( QApplication::desktop()->width() > 320 )
566 maxlen += 25; 570 maxlen += 25;
567 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
568 int fileSize = 0; 572 int fileSize = 0;
569 int result = system ( preCommand ); 573 int result = system ( preCommand );
570 // 0 : okay 574 // 0 : okay
571 // 256: no such file or dir 575 // 256: no such file or dir
572 // 576 //
573 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 577 qDebug("KO: Remote copy result(0 = okay): %d ",result );
574 if ( result != 0 ) { 578 if ( result != 0 ) {
575 unsigned int len = maxlen; 579 unsigned int len = maxlen;
576 while ( len < preCommand.length() ) { 580 while ( len < preCommand.length() ) {
577 preCommand.insert( len , "\n" ); 581 preCommand.insert( len , "\n" );
578 len += maxlen +2; 582 len += maxlen +2;
579 } 583 }
580 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 584 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
581 QMessageBox::information( mParent, i18n("Sync - ERROR"), 585 QMessageBox::information( mParent, i18n("Sync - ERROR"),
582 question, 586 question,
583 i18n("Okay!")) ; 587 i18n("Okay!")) ;
584 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 588 mParent->topLevelWidget()->setCaption ("KDE-Pim");
585 return; 589 return;
586 } 590 }
587 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 591 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
588 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 592 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
589 593
590 if ( syncWithFile( localTempFile, true ) ) { 594 if ( syncWithFile( localTempFile, true ) ) {
591 595
592 if ( mWriteBackFile ) { 596 if ( mWriteBackFile ) {
593 int fi; 597 int fi;
594 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 598 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
595 QString pwd = getPassword(); 599 QString pwd = getPassword();
596 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
597 601
598 } 602 }
599 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
600 result = system ( postCommand ); 604 result = system ( postCommand );
601 qDebug("Writing back file result: %d ", result); 605 qDebug("Writing back file result: %d ", result);
602 if ( result != 0 ) { 606 if ( result != 0 ) {
603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
604 return; 608 return;
605 } else { 609 } else {
606 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
607 } 611 }
608 } 612 }
609 } 613 }
610 return; 614 return;
611} 615}
612void KSyncManager::edit_pisync_options() 616void KSyncManager::edit_pisync_options()
613{ 617{
614 QDialog dia( mParent, "dia", true ); 618 QDialog dia( mParent, "dia", true );
615 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 619 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
616 QVBoxLayout lay ( &dia ); 620 QVBoxLayout lay ( &dia );
617 lay.setSpacing( 5 ); 621 lay.setSpacing( 5 );
618 lay.setMargin( 3 ); 622 lay.setMargin( 3 );
619 QLabel lab1 ( i18n("Password for remote access:"), &dia); 623 QLabel lab1 ( i18n("Password for remote access:"), &dia);
620 lay.addWidget( &lab1 ); 624 lay.addWidget( &lab1 );
621 QLineEdit le1 (&dia ); 625 QLineEdit le1 (&dia );
622 lay.addWidget( &le1 ); 626 lay.addWidget( &le1 );
623 QLabel lab2 ( i18n("Remote IP address:"), &dia); 627 QLabel lab2 ( i18n("Remote IP address:"), &dia);
624 lay.addWidget( &lab2 ); 628 lay.addWidget( &lab2 );
625 QLineEdit le2 (&dia ); 629 QLineEdit le2 (&dia );