summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-06 09:29:15 (UTC)
committer zautrix <zautrix>2005-07-06 09:29:15 (UTC)
commit38c8ca3f376451c072650fad8964adbbc513a105 (patch) (unidiff)
treeb1d4f1cec8b208294a16ff0d88ef6f8d5812c887
parent68016257abe13019610cb7bb230f8d754179abfb (diff)
downloadkdepimpi-38c8ca3f376451c072650fad8964adbbc513a105.zip
kdepimpi-38c8ca3f376451c072650fad8964adbbc513a105.tar.gz
kdepimpi-38c8ca3f376451c072650fad8964adbbc513a105.tar.bz2
fixxxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt37
-rw-r--r--kabc/vcardformatimpl.cpp28
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp17
3 files changed, 59 insertions, 23 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 27d37c4..ea49c2c 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,200 +1,233 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.1.13 ************ 3********** VERSION 2.1.13 ************
4 4
5Fixed a problem in KA/Pi search. 5Fixed a problem in KA/Pi search.
6Fixed some minor problems in KO/Pi. 6Fixed some minor problems in KO/Pi.
7Added calendar selection possibility to the todo view popup and to the event/todo editor. 7Added calendar selection possibility to the todo view popup and to the event/todo/journal editor.
8 8
9Fixed memory usage problems in KA/Pi:
10When loading data KA/Pi did load the file data twice.
11Example:
12 A 600k file did consume 1200k memory during loading process.
13 This is fixed, it does now consume only 600k during loading process.
14When saving data KA/Pi did consume a lot of memory for the data parsing during the save process.
15This is fixed.
16Example:
17 Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram.
18 When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system.
19 Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process.
20Note: The memory usage of KA/Pi after the data is loaded/saved has not changed.
21
22Fixed memory usage problems in KO/Pi:
23When KO/Pi did save the data to file, it did not release the used buffers after saving.
24The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation.
25This is fixed.
26Example:
27 When saving a 400k file KO/Pi do now use 400k less memory now.
28
29Optimized memory usage in KO/Pi Agenda view:
30KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view.
31These buffers were not made smaller (i.e. downsized) because of performance reasons.
32The handling of these buffers are now much smarter:
33Two (of six) buffers are removed completely.
34The remaing four buffers are now downsized after not using the agenda view for 45 seconds.
35Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi.
36
37Worst case example ( for a maximum size agenda content):
38 When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem.
39
40Summary:
41Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus.
9 42
10********** VERSION 2.1.12 ************ 43********** VERSION 2.1.12 ************
11 44
12KO/Pi: 45KO/Pi:
13Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. 46Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus.
14Fixed a problem with the month view when file was saved but KO/Pi was not the active window. 47Fixed a problem with the month view when file was saved but KO/Pi was not the active window.
15Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). 48Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only).
16Fixed some other small problems. 49Fixed some other small problems.
17 50
18********** VERSION 2.1.11 ************ 51********** VERSION 2.1.11 ************
19 52
20KO/Pi: 53KO/Pi:
21Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. 54Because we can have many calendars now in KO/Pi we can have more than one journal entry per day.
22Added features to handle (and add ) more than one journal entry per day. 55Added features to handle (and add ) more than one journal entry per day.
23Added option for a journal title. 56Added option for a journal title.
24 57
25Added info about the calendar, the item belongs to, to the event/todo/journal viewer. 58Added info about the calendar, the item belongs to, to the event/todo/journal viewer.
26Fixed a problem of the alarm of completed recurring todos. 59Fixed a problem of the alarm of completed recurring todos.
27Added to the event/todo editor to set quickly the category of an item. 60Added to the event/todo editor to set quickly the category of an item.
28 61
29 62
30Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. 63Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet.
31 64
32Added KA/Pi multi sync to the multi sync called from the alarm applet. 65Added KA/Pi multi sync to the multi sync called from the alarm applet.
33 66
34********** VERSION 2.1.10 ************ 67********** VERSION 2.1.10 ************
35 68
36KO/Pi: 69KO/Pi:
37Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. 70Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file.
38When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. 71When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted.
39Fixed a bug in searching for a small timerange, i.e. one day. 72Fixed a bug in searching for a small timerange, i.e. one day.
40 73
41KA/Pi: 74KA/Pi:
42Fixed two problems in csv export. 75Fixed two problems in csv export.
43Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. 76Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi.
44 77
45********** VERSION 2.1.9 ************ 78********** VERSION 2.1.9 ************
46 79
47KO/Pi: 80KO/Pi:
48Fixed some problems of the new search options in the search dialog. 81Fixed some problems of the new search options in the search dialog.
49Fixed some problems in the new resource config options. 82Fixed some problems in the new resource config options.
50Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. 83Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page.
51Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: 84Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown:
52Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. 85Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup.
53 86
54Fixed a problem in recurrence range in syncing with DTM. 87Fixed a problem in recurrence range in syncing with DTM.
55 88
56KA/Pi: 89KA/Pi:
57Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) 90Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...)
58 91
59PwM/Pi: 92PwM/Pi:
60Added "sec" to the timeout config settings to make it clear the timeout values are seconds. 93Added "sec" to the timeout config settings to make it clear the timeout values are seconds.
61 94
62********** VERSION 2.1.8 ************ 95********** VERSION 2.1.8 ************
63 96
64KO/Pi: 97KO/Pi:
65Added info about the completion state of a todo in the ListView/Searchdialog. 98Added info about the completion state of a todo in the ListView/Searchdialog.
66If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. 99If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well.
67Fixed some updating problems when changing the filter. 100Fixed some updating problems when changing the filter.
68 101
69KA/Pi: 102KA/Pi:
70In the addressee selection dialog now the formatted name is shown, if not empty. 103In the addressee selection dialog now the formatted name is shown, if not empty.
71Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. 104Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category.
72Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. 105Now in the addressee selection dialog a selected contact is remove with a single click from the selected list.
73 106
74Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. 107Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored.
75Fixed the sorting for size in the file selector on the Z. 108Fixed the sorting for size in the file selector on the Z.
76 109
77Changed the color selection dialog on the Zaurus to a more user friendly version. 110Changed the color selection dialog on the Zaurus to a more user friendly version.
78 111
79********** VERSION 2.1.7 ************ 112********** VERSION 2.1.7 ************
80 113
81KO/Pi: 114KO/Pi:
82Fixed several problems in the new Resource handling. 115Fixed several problems in the new Resource handling.
83Added more options to the search dialog. 116Added more options to the search dialog.
84Fixed a problem in the Month view. 117Fixed a problem in the Month view.
85Added more options to the dialog when setting a todo to stopped. 118Added more options to the dialog when setting a todo to stopped.
86 119
87Fixed two small problems in KO/Pi Alarm applet. 120Fixed two small problems in KO/Pi Alarm applet.
88 121
89********** VERSION 2.1.6 ************ 122********** VERSION 2.1.6 ************
90 123
91This release is for testing only. 124This release is for testing only.
92 125
93KO/Pi: 126KO/Pi:
94Added to the list view (the list view is used in search dialog as well) the possibility to print it. 127Added to the list view (the list view is used in search dialog as well) the possibility to print it.
95Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. 128Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view.
96Added to the list view the possibility to add all subtodos of selected todos to an export/beam. 129Added to the list view the possibility to add all subtodos of selected todos to an export/beam.
97Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. 130Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout.
98Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. 131Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus.
99Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. 132Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly.
100 133
101Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. 134Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars.
102In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. 135In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later.
103Now on every sync the set of calendars is synced which are enabled in the resource view. 136Now on every sync the set of calendars is synced which are enabled in the resource view.
104 137
105A calendar is enabled in the resource view if the "eye" column is checked. 138A calendar is enabled in the resource view if the "eye" column is checked.
106You can set a calendar to be the default for new items( "+" column ). 139You can set a calendar to be the default for new items( "+" column ).
107You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. 140You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly.
108To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... 141To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ...
109 142
110 143
111********** VERSION 2.1.5 ************ 144********** VERSION 2.1.5 ************
112 145
113This is the new stable version. 146This is the new stable version.
114Bugfix: 147Bugfix:
115Fixed a problem with agenda popup on the desktop in KO/Pi. 148Fixed a problem with agenda popup on the desktop in KO/Pi.
116Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. 149Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization.
117Added config option to not display completed todos in agenda view. 150Added config option to not display completed todos in agenda view.
118Addressee view is now using the formatted name, if defined. 151Addressee view is now using the formatted name, if defined.
119That makes it possible to display "lastname, firstname" in that view now. 152That makes it possible to display "lastname, firstname" in that view now.
120To set the formatted name for all contacts, please use menu: 153To set the formatted name for all contacts, please use menu:
121Edit->Change->Set formatted name. 154Edit->Change->Set formatted name.
122Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. 155Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows.
123 156
124********** VERSION 2.1.4 ************ 157********** VERSION 2.1.4 ************
125 158
126Fixed two more bugs in the KA/Pi CSV import dialog: 159Fixed two more bugs in the KA/Pi CSV import dialog:
127Made it possible to read multi-line fields and import it to the "Note" field. 160Made it possible to read multi-line fields and import it to the "Note" field.
128Fixed a problem in mapping custom fields, whatever a custem field is... 161Fixed a problem in mapping custom fields, whatever a custem field is...
129 162
130********** VERSION 2.1.3 ************ 163********** VERSION 2.1.3 ************
131 164
132Changed the menu structure of the alarm applet: 165Changed the menu structure of the alarm applet:
133Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". 166Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List".
134 167
135Fixed several problems in the KA/Pi CSV import dialog: 168Fixed several problems in the KA/Pi CSV import dialog:
136Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. 169Added "Category", made codec configureable and made it possible to map many fields to the "Note" field.
137 170
138 171
139********** VERSION 2.1.2 ************ 172********** VERSION 2.1.2 ************
140 173
141Fixed a problem closing the alarm dialog on Zaurus with "OK" button. 174Fixed a problem closing the alarm dialog on Zaurus with "OK" button.
142 175
143Fixed a problem when importing data from Outlook with mutiple categories set. 176Fixed a problem when importing data from Outlook with mutiple categories set.
144 177
145Changed display of days in datenavigator: 178Changed display of days in datenavigator:
146Birthdays are now blue, not dark green. 179Birthdays are now blue, not dark green.
147When todo view is shown, no birtdays are shown and days with due todos are shown blue. 180When todo view is shown, no birtdays are shown and days with due todos are shown blue.
148When journal view is shown, only holidays are shown and days with journals are blue. 181When journal view is shown, only holidays are shown and days with journals are blue.
149 182
150Added Backup options to global config: 183Added Backup options to global config:
151You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). 184You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ).
152It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. 185It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again.
153The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. 186The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups.
154 187
155********** VERSION 2.1.1 ************ 188********** VERSION 2.1.1 ************
156 189
157Stable release 2.1.1! 190Stable release 2.1.1!
158 191
159KO/Pi: 192KO/Pi:
160Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. 193Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display.
161 194
162********** VERSION 2.1.0 ************ 195********** VERSION 2.1.0 ************
163 196
164Stable release 2.1.0! 197Stable release 2.1.0!
165 198
166Summary of changes/fixes compared to version 2.0.6: 199Summary of changes/fixes compared to version 2.0.6:
167 200
168Many bugs of version 2.0.6 fixed. 201Many bugs of version 2.0.6 fixed.
169Most of them were small bugs, but some of them were important. 202Most of them were small bugs, but some of them were important.
170It is recommended to use version 2.1.0 and not version 2.0.6. 203It is recommended to use version 2.1.0 and not version 2.0.6.
171 204
172Important changes: 205Important changes:
173 206
174Added recurring todos to KO/Pi. 207Added recurring todos to KO/Pi.
175 208
176Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. 209Added global application font settings (for all KDE-Pim/Pi apps) to the general settings.
177 210
178Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 211Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
179 212
180Datenavigator can now display many months. Very useful on the desktop. 213Datenavigator can now display many months. Very useful on the desktop.
181 214
182KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. 215KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements.
183 216
184Made alarm sound working on Linux desktop. 217Made alarm sound working on Linux desktop.
185 218
186Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. 219Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details.
187 220
188Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. 221Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details.
189 222
190Many other usebility enhancements. 223Many other usebility enhancements.
191Special thanks to Ben for his suggestions! 224Special thanks to Ben for his suggestions!
192 225
193You can find the complete changelog 226You can find the complete changelog
194from version 1.7.7 to 2.1.0 227from version 1.7.7 to 2.1.0
195in the source package or on 228in the source package or on
196 229
197http://www.pi-sync.net/html/changelog.html 230http://www.pi-sync.net/html/changelog.html
198 231
199 232
200 233
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index b9fe6ff..ec5ed80 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -1,519 +1,511 @@
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#include <qfile.h> 28#include <qfile.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qapplication.h>
30 31
31#include <kdebug.h> 32#include <kdebug.h>
32#include <kmdcodec.h> 33#include <kmdcodec.h>
33#include <kstandarddirs.h> 34#include <kstandarddirs.h>
34#include <ktempfile.h> 35#include <ktempfile.h>
35 36
36#include <VCard.h> 37#include <VCard.h>
37 38
38#include "addressbook.h" 39#include "addressbook.h"
39#include "vcardformatimpl.h" 40#include "vcardformatimpl.h"
40 41
41using namespace KABC; 42using namespace KABC;
42using namespace VCARD; 43using namespace VCARD;
43 44
44int VCardFormatImpl::debug = -1; 45int VCardFormatImpl::debug = -1;
45 46
46VCardFormatImpl::VCardFormatImpl() 47VCardFormatImpl::VCardFormatImpl()
47{ 48{
48 debug = (getenv("KABC_DEBUG") != 0); 49 debug = (getenv("KABC_DEBUG") != 0);
49} 50}
50 51
51bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) 52bool VCardFormatImpl::load( Addressee &addressee, QFile *file )
52{ 53{
53 kdDebug(5700) << "VCardFormat::load()" << endl; 54 kdDebug(5700) << "VCardFormat::load()" << endl;
54 55
55 QByteArray fdata = file->readAll(); 56 QByteArray fdata = file->readAll();
56 QCString data(fdata.data(), fdata.size()+1); 57 QCString data(fdata.data(), fdata.size()+1);
57 58
58 VCardEntity e( data ); 59 VCardEntity e( data );
59 60
60 VCardListIterator it( e.cardList() ); 61 VCardListIterator it( e.cardList() );
61 62
62 if ( it.current() ) { 63 if ( it.current() ) {
63//US VCard v(*it.current()); 64//US VCard v(*it.current());
64//US loadAddressee( addressee, v ); 65//US loadAddressee( addressee, v );
65 loadAddressee( addressee, it.current() ); 66 loadAddressee( addressee, it.current() );
66 return true; 67 return true;
67 } 68 }
68 69
69 return false; 70 return false;
70} 71}
71 72
73
74#include <kmessagebox.h>
72bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 75bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
73{ 76{
74 kdDebug(5700) << "VCardFormat::loadAll()" << endl; 77
75 78 QCString data(file->readAll().data(), file->size()+1);
76 QByteArray fdata = file->readAll();
77 QCString data(fdata.data(), fdata.size()+1);
78
79 VCardEntity e( data ); 79 VCardEntity e( data );
80 80
81 VCardListIterator it( e.cardList() ); 81 VCardListIterator it( e.cardList() );
82 82
83 for (; it.current(); ++it) { 83 for (; it.current(); ++it) {
84//US VCard v(*it.current()); 84//US VCard v(*it.current());
85 Addressee addressee; 85 Addressee addressee;
86//US loadAddressee( addressee, v ); 86//US loadAddressee( addressee, v );
87 loadAddressee( addressee, it.current() ); 87 loadAddressee( addressee, it.current() );
88 addressee.setResource( resource ); 88 addressee.setResource( resource );
89 addressBook->insertAddressee( addressee ); 89 addressBook->insertAddressee( addressee );
90 if (debug == true) 90 if (debug == true)
91 { 91 {
92 printf("address %s loaded successfully\n", addressee.formattedName().latin1()); 92 printf("address %s loaded successfully\n", addressee.formattedName().latin1());
93 } 93 }
94 } 94 }
95
96 return true; 95 return true;
97} 96}
98 97
99void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) 98void VCardFormatImpl::save( const Addressee &addressee, QFile *file )
100{ 99{
101 VCardEntity vcards; 100 VCardEntity vcards;
102 VCardList vcardlist; 101 VCardList vcardlist;
103 vcardlist.setAutoDelete( true ); 102 vcardlist.setAutoDelete( true );
104 103
105 VCard *v = new VCard; 104 VCard *v = new VCard;
106 105
107 saveAddressee( addressee, v, false ); 106 saveAddressee( addressee, v, false );
108 107
109 vcardlist.append( v ); 108 vcardlist.append( v );
110 vcards.setCardList( vcardlist ); 109 vcards.setCardList( vcardlist );
111 110
112 QCString vcardData = vcards.asString(); 111 QCString vcardData = vcards.asString();
113 file->writeBlock( (const char*)vcardData, vcardData.length() ); 112 file->writeBlock( (const char*)vcardData, vcardData.length() );
114} 113}
115 114
116void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) 115void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file )
117{ 116{
118 VCardEntity vcards;
119 VCardList vcardlist;
120 vcardlist.setAutoDelete( true );
121 117
122 AddressBook::Iterator it; 118 AddressBook::Iterator it;
123 for ( it = ab->begin(); it != ab->end(); ++it ) { 119 for ( it = ab->begin(); it != ab->end(); ++it ) {
124 if ( (*it).resource() == resource ) { 120 if ( (*it).resource() == resource ) {
125 VCard *v = new VCard; 121 save((*it),file);
126 saveAddressee( (*it), v, true ); 122 qApp->processEvents();
127 (*it).setChanged( false ); 123 (*it).setChanged( false );
128 vcardlist.append( v );
129 } 124 }
130 } 125 }
131 126 // for memory usage status test only
132 vcards.setCardList( vcardlist ); 127 // KMessageBox::information ( 0, "Stoppppp", QString("Stop ") );
133
134 QCString vcardData = vcards.asString();
135 file->writeBlock( (const char*)vcardData, vcardData.length() );
136} 128}
137 129
138bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) 130bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v )
139{ 131{
140 QPtrList<ContentLine> contentLines = v->contentLineList(); 132 QPtrList<ContentLine> contentLines = v->contentLineList();
141 ContentLine *cl; 133 ContentLine *cl;
142 134
143 for( cl = contentLines.first(); cl; cl = contentLines.next() ) { 135 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
144 QCString n = cl->name(); 136 QCString n = cl->name();
145 if ( n.left( 2 ) == "X-" ) { 137 if ( n.left( 2 ) == "X-" ) {
146 n = n.mid( 2 ); 138 n = n.mid( 2 );
147 int posDash = n.find( "-" ); 139 int posDash = n.find( "-" );
148 addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), 140 addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ),
149 QString::fromUtf8( n.mid( posDash + 1 ) ), 141 QString::fromUtf8( n.mid( posDash + 1 ) ),
150 QString::fromUtf8( cl->value()->asString() ) ); 142 QString::fromUtf8( cl->value()->asString() ) );
151 continue; 143 continue;
152 } 144 }
153 145
154 EntityType type = cl->entityType(); 146 EntityType type = cl->entityType();
155 switch( type ) { 147 switch( type ) {
156 148
157 case EntityUID: 149 case EntityUID:
158 addressee.setUid( readTextValue( cl ) ); 150 addressee.setUid( readTextValue( cl ) );
159 break; 151 break;
160 152
161 case EntityEmail: 153 case EntityEmail:
162 addressee.insertEmail( readTextValue( cl ) ); 154 addressee.insertEmail( readTextValue( cl ) );
163 break; 155 break;
164 156
165 case EntityName: 157 case EntityName:
166 addressee.setName( readTextValue( cl ) ); 158 addressee.setName( readTextValue( cl ) );
167 break; 159 break;
168 160
169 case EntityFullName: 161 case EntityFullName:
170 addressee.setFormattedName( readTextValue( cl ) ); 162 addressee.setFormattedName( readTextValue( cl ) );
171 break; 163 break;
172 164
173 case EntityURL: 165 case EntityURL:
174 addressee.setUrl( KURL( readTextValue( cl ) ) ); 166 addressee.setUrl( KURL( readTextValue( cl ) ) );
175 break; 167 break;
176 168
177 case EntityNickname: 169 case EntityNickname:
178 addressee.setNickName( readTextValue( cl ) ); 170 addressee.setNickName( readTextValue( cl ) );
179 break; 171 break;
180 172
181 case EntityLabel: 173 case EntityLabel:
182 // not yet supported by kabc 174 // not yet supported by kabc
183 break; 175 break;
184 176
185 case EntityMailer: 177 case EntityMailer:
186 addressee.setMailer( readTextValue( cl ) ); 178 addressee.setMailer( readTextValue( cl ) );
187 break; 179 break;
188 180
189 case EntityTitle: 181 case EntityTitle:
190 addressee.setTitle( readTextValue( cl ) ); 182 addressee.setTitle( readTextValue( cl ) );
191 break; 183 break;
192 184
193 case EntityRole: 185 case EntityRole:
194 addressee.setRole( readTextValue( cl ) ); 186 addressee.setRole( readTextValue( cl ) );
195 break; 187 break;
196 188
197 case EntityOrganisation: 189 case EntityOrganisation:
198 addressee.setOrganization( readTextValue( cl ) ); 190 addressee.setOrganization( readTextValue( cl ) );
199 break; 191 break;
200 192
201 case EntityNote: 193 case EntityNote:
202 addressee.setNote( readTextValue( cl ) ); 194 addressee.setNote( readTextValue( cl ) );
203 break; 195 break;
204 196
205 case EntityProductID: 197 case EntityProductID:
206 addressee.setProductId( readTextValue( cl ) ); 198 addressee.setProductId( readTextValue( cl ) );
207 break; 199 break;
208 200
209 case EntitySortString: 201 case EntitySortString:
210 addressee.setSortString( readTextValue( cl ) ); 202 addressee.setSortString( readTextValue( cl ) );
211 break; 203 break;
212 204
213 case EntityN: 205 case EntityN:
214 readNValue( cl, addressee ); 206 readNValue( cl, addressee );
215 break; 207 break;
216 208
217 case EntityAddress: 209 case EntityAddress:
218 addressee.insertAddress( readAddressValue( cl ) ); 210 addressee.insertAddress( readAddressValue( cl ) );
219 break; 211 break;
220 212
221 case EntityTelephone: 213 case EntityTelephone:
222 addressee.insertPhoneNumber( readTelephoneValue( cl ) ); 214 addressee.insertPhoneNumber( readTelephoneValue( cl ) );
223 break; 215 break;
224 216
225 case EntityCategories: 217 case EntityCategories:
226 addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); 218 addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) );
227 break; 219 break;
228 220
229 case EntityBirthday: 221 case EntityBirthday:
230 addressee.setBirthday( readDateValue( cl ) ); 222 addressee.setBirthday( readDateValue( cl ) );
231 break; 223 break;
232 224
233 case EntityRevision: 225 case EntityRevision:
234 addressee.setRevision( readDateTimeValue( cl ) ); 226 addressee.setRevision( readDateTimeValue( cl ) );
235 break; 227 break;
236 228
237 case EntityGeo: 229 case EntityGeo:
238 addressee.setGeo( readGeoValue( cl ) ); 230 addressee.setGeo( readGeoValue( cl ) );
239 break; 231 break;
240 232
241 case EntityTimeZone: 233 case EntityTimeZone:
242 addressee.setTimeZone( readUTCValue( cl ) ); 234 addressee.setTimeZone( readUTCValue( cl ) );
243 break; 235 break;
244 236
245 case EntityVersion: 237 case EntityVersion:
246 break; 238 break;
247 239
248 case EntityClass: 240 case EntityClass:
249 addressee.setSecrecy( readClassValue( cl ) ); 241 addressee.setSecrecy( readClassValue( cl ) );
250 break; 242 break;
251 243
252 case EntityKey: 244 case EntityKey:
253 addressee.insertKey( readKeyValue( cl ) ); 245 addressee.insertKey( readKeyValue( cl ) );
254 break; 246 break;
255 247
256 case EntityPhoto: 248 case EntityPhoto:
257 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); 249 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
258 break; 250 break;
259 251
260 case EntityLogo: 252 case EntityLogo:
261 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); 253 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
262 break; 254 break;
263 255
264 case EntityAgent: 256 case EntityAgent:
265 addressee.setAgent( readAgentValue( cl ) ); 257 addressee.setAgent( readAgentValue( cl ) );
266 break; 258 break;
267 259
268 case EntitySound: 260 case EntitySound:
269 addressee.setSound( readSoundValue( cl, addressee ) ); 261 addressee.setSound( readSoundValue( cl, addressee ) );
270 break; 262 break;
271 263
272 default: 264 default:
273 kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " 265 kdDebug(5700) << "VCardFormat::load(): Unsupported entity: "
274 << int( type ) << ": " << cl->asString() << endl; 266 << int( type ) << ": " << cl->asString() << endl;
275 qDebug("VCardFormat::load(): Unsupported entity: %i: %s ", int(type), (const char*)cl->asString()); 267 qDebug("VCardFormat::load(): Unsupported entity: %i: %s ", int(type), (const char*)cl->asString());
276 break; 268 break;
277 } 269 }
278 } 270 }
279 271
280 for( cl = contentLines.first(); cl; cl = contentLines.next() ) { 272 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
281 EntityType type = cl->entityType(); 273 EntityType type = cl->entityType();
282 if ( type == EntityLabel ) { 274 if ( type == EntityLabel ) {
283 int type = readAddressParam( cl ); 275 int type = readAddressParam( cl );
284 Address address = addressee.address( type ); 276 Address address = addressee.address( type );
285 if ( address.isEmpty() ) 277 if ( address.isEmpty() )
286 address.setType( type ); 278 address.setType( type );
287 279
288 address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); 280 address.setLabel( QString::fromUtf8( cl->value()->asString() ) );
289 addressee.insertAddress( address ); 281 addressee.insertAddress( address );
290 } 282 }
291 } 283 }
292 284
293 return true; 285 return true;
294} 286}
295 287
296void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) 288void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern )
297{ 289{
298//US ContentLine cl; 290//US ContentLine cl;
299//US QString value; 291//US QString value;
300 292
301 addTextValue( v, EntityName, addressee.name() ); 293 addTextValue( v, EntityName, addressee.name() );
302 addTextValue( v, EntityUID, addressee.uid() ); 294 addTextValue( v, EntityUID, addressee.uid() );
303 addTextValue( v, EntityFullName, addressee.formattedName() ); 295 addTextValue( v, EntityFullName, addressee.formattedName() );
304 296
305 QStringList emails = addressee.emails(); 297 QStringList emails = addressee.emails();
306 QStringList::ConstIterator it4; 298 QStringList::ConstIterator it4;
307 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { 299 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) {
308 addTextValue( v, EntityEmail, *it4 ); 300 addTextValue( v, EntityEmail, *it4 );
309 } 301 }
310 302
311 QStringList customs = addressee.customs(); 303 QStringList customs = addressee.customs();
312 QStringList::ConstIterator it5; 304 QStringList::ConstIterator it5;
313 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { 305 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) {
314 addCustomValue( v, *it5 ); 306 addCustomValue( v, *it5 );
315 } 307 }
316 308
317 addTextValue( v, EntityURL, addressee.url().url() ); 309 addTextValue( v, EntityURL, addressee.url().url() );
318 310
319 addNValue( v, addressee ); 311 addNValue( v, addressee );
320 312
321 addTextValue( v, EntityNickname, addressee.nickName() ); 313 addTextValue( v, EntityNickname, addressee.nickName() );
322 addTextValue( v, EntityMailer, addressee.mailer() ); 314 addTextValue( v, EntityMailer, addressee.mailer() );
323 addTextValue( v, EntityTitle, addressee.title() ); 315 addTextValue( v, EntityTitle, addressee.title() );
324 addTextValue( v, EntityRole, addressee.role() ); 316 addTextValue( v, EntityRole, addressee.role() );
325 addTextValue( v, EntityOrganisation, addressee.organization() ); 317 addTextValue( v, EntityOrganisation, addressee.organization() );
326 addTextValue( v, EntityNote, addressee.note() ); 318 addTextValue( v, EntityNote, addressee.note() );
327 addTextValue( v, EntityProductID, addressee.productId() ); 319 addTextValue( v, EntityProductID, addressee.productId() );
328 addTextValue( v, EntitySortString, addressee.sortString() ); 320 addTextValue( v, EntitySortString, addressee.sortString() );
329 321
330 Address::List addresses = addressee.addresses(); 322 Address::List addresses = addressee.addresses();
331 Address::List::ConstIterator it3; 323 Address::List::ConstIterator it3;
332 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { 324 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) {
333 addAddressValue( v, *it3 ); 325 addAddressValue( v, *it3 );
334 addLabelValue( v, *it3 ); 326 addLabelValue( v, *it3 );
335 } 327 }
336 328
337 PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); 329 PhoneNumber::List phoneNumbers = addressee.phoneNumbers();
338 PhoneNumber::List::ConstIterator it2; 330 PhoneNumber::List::ConstIterator it2;
339 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { 331 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) {
340 addTelephoneValue( v, *it2 ); 332 addTelephoneValue( v, *it2 );
341 } 333 }
342 334
343 Key::List keys = addressee.keys(); 335 Key::List keys = addressee.keys();
344 Key::List::ConstIterator it6; 336 Key::List::ConstIterator it6;
345 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { 337 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) {
346 addKeyValue( v, *it6 ); 338 addKeyValue( v, *it6 );
347 } 339 }
348 340
349 addTextValue( v, EntityCategories, addressee.categories().join(",") ); 341 addTextValue( v, EntityCategories, addressee.categories().join(",") );
350 342
351 addDateValue( v, EntityBirthday, addressee.birthday().date() ); 343 addDateValue( v, EntityBirthday, addressee.birthday().date() );
352 addDateTimeValue( v, EntityRevision, addressee.revision() ); 344 addDateTimeValue( v, EntityRevision, addressee.revision() );
353 addGeoValue( v, addressee.geo() ); 345 addGeoValue( v, addressee.geo() );
354 addUTCValue( v, addressee.timeZone() ); 346 addUTCValue( v, addressee.timeZone() );
355 347
356 addClassValue( v, addressee.secrecy() ); 348 addClassValue( v, addressee.secrecy() );
357 349
358 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); 350 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern );
359 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); 351 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern );
360 352
361 addAgentValue( v, addressee.agent() ); 353 addAgentValue( v, addressee.agent() );
362 354
363 addSoundValue( v, addressee.sound(), addressee, intern ); 355 addSoundValue( v, addressee.sound(), addressee, intern );
364} 356}
365 357
366void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) 358void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt )
367{ 359{
368 if ( txt.isEmpty() ) return; 360 if ( txt.isEmpty() ) return;
369 361
370 ContentLine cl; 362 ContentLine cl;
371 cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); 363 cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() );
372 QString value = txt.mid( txt.find( ":" ) + 1 ); 364 QString value = txt.mid( txt.find( ":" ) + 1 );
373 if ( value.isEmpty() ) 365 if ( value.isEmpty() )
374 return; 366 return;
375 cl.setValue( new TextValue( value.utf8() ) ); 367 cl.setValue( new TextValue( value.utf8() ) );
376 v->add(cl); 368 v->add(cl);
377} 369}
378 370
379void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) 371void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt )
380{ 372{
381 if ( txt.isEmpty() ) return; 373 if ( txt.isEmpty() ) return;
382 374
383 ContentLine cl; 375 ContentLine cl;
384 cl.setName( EntityTypeToParamName( type ) ); 376 cl.setName( EntityTypeToParamName( type ) );
385 cl.setValue( new TextValue( txt.utf8() ) ); 377 cl.setValue( new TextValue( txt.utf8() ) );
386 v->add(cl); 378 v->add(cl);
387} 379}
388 380
389void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, 381void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type,
390 const QDate &date ) 382 const QDate &date )
391{ 383{
392 if ( !date.isValid() ) return; 384 if ( !date.isValid() ) return;
393 385
394 ContentLine cl; 386 ContentLine cl;
395 cl.setName( EntityTypeToParamName( type ) ); 387 cl.setName( EntityTypeToParamName( type ) );
396 388
397 DateValue *v = new DateValue( date ); 389 DateValue *v = new DateValue( date );
398 cl.setValue( v ); 390 cl.setValue( v );
399 vcard->add(cl); 391 vcard->add(cl);
400} 392}
401 393
402void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type, 394void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type,
403 const QDateTime &dateTime ) 395 const QDateTime &dateTime )
404{ 396{
405 if ( !dateTime.isValid() ) return; 397 if ( !dateTime.isValid() ) return;
406 398
407 ContentLine cl; 399 ContentLine cl;
408 cl.setName( EntityTypeToParamName( type ) ); 400 cl.setName( EntityTypeToParamName( type ) );
409 401
410 DateValue *v = new DateValue( dateTime ); 402 DateValue *v = new DateValue( dateTime );
411 cl.setValue( v ); 403 cl.setValue( v );
412 vcard->add(cl); 404 vcard->add(cl);
413} 405}
414 406
415void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a ) 407void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a )
416{ 408{
417 if ( a.isEmpty() ) 409 if ( a.isEmpty() )
418 return; 410 return;
419 411
420 ContentLine cl; 412 ContentLine cl;
421 cl.setName( EntityTypeToParamName( EntityAddress ) ); 413 cl.setName( EntityTypeToParamName( EntityAddress ) );
422 414
423 AdrValue *v = new AdrValue; 415 AdrValue *v = new AdrValue;
424 v->setPOBox( a.postOfficeBox().utf8() ); 416 v->setPOBox( a.postOfficeBox().utf8() );
425 v->setExtAddress( a.extended().utf8() ); 417 v->setExtAddress( a.extended().utf8() );
426 v->setStreet( a.street().utf8() ); 418 v->setStreet( a.street().utf8() );
427 v->setLocality( a.locality().utf8() ); 419 v->setLocality( a.locality().utf8() );
428 v->setRegion( a.region().utf8() ); 420 v->setRegion( a.region().utf8() );
429 v->setPostCode( a.postalCode().utf8() ); 421 v->setPostCode( a.postalCode().utf8() );
430 v->setCountryName( a.country().utf8() ); 422 v->setCountryName( a.country().utf8() );
431 cl.setValue( v ); 423 cl.setValue( v );
432 424
433 addAddressParam( &cl, a.type() ); 425 addAddressParam( &cl, a.type() );
434 426
435 vcard->add( cl ); 427 vcard->add( cl );
436} 428}
437 429
438void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a ) 430void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a )
439{ 431{
440 if ( a.label().isEmpty() ) return; 432 if ( a.label().isEmpty() ) return;
441 433
442 ContentLine cl; 434 ContentLine cl;
443 cl.setName( EntityTypeToParamName( EntityLabel ) ); 435 cl.setName( EntityTypeToParamName( EntityLabel ) );
444 cl.setValue( new TextValue( a.label().utf8() ) ); 436 cl.setValue( new TextValue( a.label().utf8() ) );
445 437
446 addAddressParam( &cl, a.type() ); 438 addAddressParam( &cl, a.type() );
447 439
448 vcard->add( cl ); 440 vcard->add( cl );
449} 441}
450 442
451void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) 443void VCardFormatImpl::addAddressParam( ContentLine *cl, int type )
452{ 444{
453 ParamList params; 445 ParamList params;
454 if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); 446 if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) );
455 if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); 447 if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) );
456 if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); 448 if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) );
457 if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); 449 if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) );
458 if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); 450 if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) );
459 if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); 451 if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) );
460 if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); 452 if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) );
461 cl->setParamList( params ); 453 cl->setParamList( params );
462} 454}
463 455
464void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) 456void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo )
465{ 457{
466 if ( !geo.isValid() ) return; 458 if ( !geo.isValid() ) return;
467 459
468 ContentLine cl; 460 ContentLine cl;
469 cl.setName( EntityTypeToParamName( EntityGeo ) ); 461 cl.setName( EntityTypeToParamName( EntityGeo ) );
470 462
471 GeoValue *v = new GeoValue; 463 GeoValue *v = new GeoValue;
472 v->setLatitude( geo.latitude() ); 464 v->setLatitude( geo.latitude() );
473 v->setLongitude( geo.longitude() ); 465 v->setLongitude( geo.longitude() );
474 466
475 cl.setValue( v ); 467 cl.setValue( v );
476 vcard->add(cl); 468 vcard->add(cl);
477} 469}
478 470
479void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) 471void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz )
480{ 472{
481 if ( !tz.isValid() ) return; 473 if ( !tz.isValid() ) return;
482 474
483 ContentLine cl; 475 ContentLine cl;
484 cl.setName( EntityTypeToParamName( EntityTimeZone ) ); 476 cl.setName( EntityTypeToParamName( EntityTimeZone ) );
485 477
486 UTCValue *v = new UTCValue; 478 UTCValue *v = new UTCValue;
487 479
488 v->setPositive( tz.offset() >= 0 ); 480 v->setPositive( tz.offset() >= 0 );
489 v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); 481 v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
490 v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); 482 v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
491 483
492 cl.setValue( v ); 484 cl.setValue( v );
493 vcard->add(cl); 485 vcard->add(cl);
494} 486}
495 487
496void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) 488void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy )
497{ 489{
498 ContentLine cl; 490 ContentLine cl;
499 cl.setName( EntityTypeToParamName( EntityClass ) ); 491 cl.setName( EntityTypeToParamName( EntityClass ) );
500 492
501 ClassValue *v = new ClassValue; 493 ClassValue *v = new ClassValue;
502 switch ( secrecy.type() ) { 494 switch ( secrecy.type() ) {
503 case Secrecy::Public: 495 case Secrecy::Public:
504 v->setType( (int)ClassValue::Public ); 496 v->setType( (int)ClassValue::Public );
505 break; 497 break;
506 case Secrecy::Private: 498 case Secrecy::Private:
507 v->setType( (int)ClassValue::Private ); 499 v->setType( (int)ClassValue::Private );
508 break; 500 break;
509 case Secrecy::Confidential: 501 case Secrecy::Confidential:
510 v->setType( (int)ClassValue::Confidential ); 502 v->setType( (int)ClassValue::Confidential );
511 break; 503 break;
512 } 504 }
513 505
514 cl.setValue( v ); 506 cl.setValue( v );
515 vcard->add(cl); 507 vcard->add(cl);
516} 508}
517 509
518 510
519Address VCardFormatImpl::readAddressValue( ContentLine *cl ) 511Address VCardFormatImpl::readAddressValue( ContentLine *cl )
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index c56be8b..91df96d 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -1,255 +1,266 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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/* 24/*
25 Enhanced Version of the file for platform independent KDE tools. 25 Enhanced Version of the file for platform independent KDE tools.
26 Copyright (c) 2004 Ulf Schenk 26 Copyright (c) 2004 Ulf Schenk
27 27
28 $Id$ 28 $Id$
29*/ 29*/
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34 34
35#include <kabc/vcardconverter.h> 35#include <kabc/vcardconverter.h>
36#include <kabc/vcardparser/vcardtool.h> 36#include <kabc/vcardparser/vcardtool.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#ifndef KAB_EMBEDDED 38#ifndef KAB_EMBEDDED
39#include <kio/netaccess.h> 39#include <kio/netaccess.h>
40#endif //KAB_EMBEDDED 40#endif //KAB_EMBEDDED
41 41
42#include <klocale.h> 42#include <klocale.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include <ktempfile.h> 44#include <ktempfile.h>
45#include <kurl.h> 45#include <kurl.h>
46 46
47#include "xxportmanager.h" 47#include "xxportmanager.h"
48 48
49#include "vcard_xxport.h" 49#include "vcard_xxport.h"
50 50
51#ifndef KAB_EMBEDDED 51#ifndef KAB_EMBEDDED
52 52
53class VCardXXPortFactory : public XXPortFactory 53class VCardXXPortFactory : public XXPortFactory
54{ 54{
55public: 55public:
56 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 56 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
57 { 57 {
58 return new VCardXXPort( ab, parent, name ); 58 return new VCardXXPort( ab, parent, name );
59 } 59 }
60}; 60};
61#endif //KAB_EMBEDDED 61#endif //KAB_EMBEDDED
62 62
63 63
64extern "C" 64extern "C"
65{ 65{
66#ifndef KAB_EMBEDDED 66#ifndef KAB_EMBEDDED
67 void *init_libkaddrbk_vcard_xxport() 67 void *init_libkaddrbk_vcard_xxport()
68#else //KAB_EMBEDDED 68#else //KAB_EMBEDDED
69 void *init_microkaddrbk_vcard_xxport() 69 void *init_microkaddrbk_vcard_xxport()
70#endif //KAB_EMBEDDED 70#endif //KAB_EMBEDDED
71 { 71 {
72 return ( new VCardXXPortFactory() ); 72 return ( new VCardXXPortFactory() );
73 } 73 }
74} 74}
75 75
76 76
77VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 77VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
78 : XXPortObject( ab, parent, name ) 78 : XXPortObject( ab, parent, name )
79{ 79{
80 createImportAction( i18n( "Import vCard..." ) ); 80 createImportAction( i18n( "Import vCard..." ) );
81 //US KABC::VCardConverter does not support the export of 2.1 addressbooks. 81 //US KABC::VCardConverter does not support the export of 2.1 addressbooks.
82 //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); 82 //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" );
83 createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); 83 createExportAction( i18n( "Export vCard 3.0..." ), "v30" );
84} 84}
85 85
86bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) 86bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data )
87{ 87{
88 QString name; 88 QString name;
89 89
90 if ( list.count() == 1 ) 90 if ( list.count() == 1 )
91 name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; 91 name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf";
92 else 92 else
93 name = "addressbook.vcf"; 93 name = "addressbook.vcf";
94 94
95#ifndef KAB_EMBEDDED 95#ifndef KAB_EMBEDDED
96 QString fileName = KFileDialog::getSaveFileName( name ); 96 QString fileName = KFileDialog::getSaveFileName( name );
97#else //KAB_EMBEDDED 97#else //KAB_EMBEDDED
98 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); 98 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() );
99#endif //KAB_EMBEDDED 99#endif //KAB_EMBEDDED
100 100
101 if ( fileName.isEmpty() ) 101 if ( fileName.isEmpty() )
102 return false; 102 return false;
103 103
104 QFile outFile( fileName ); 104 QFile outFile( fileName );
105 if ( !outFile.open( IO_WriteOnly ) ) { 105 if ( !outFile.open( IO_WriteOnly ) ) {
106 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 106 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
107 KMessageBox::error( parentWidget(), text.arg( fileName ) ); 107 KMessageBox::error( parentWidget(), text.arg( fileName ) );
108 return false; 108 return false;
109 } 109 }
110 110
111 QTextStream t( &outFile ); 111 QTextStream t( &outFile );
112 t.setEncoding( QTextStream::UnicodeUTF8 ); 112 t.setEncoding( QTextStream::UnicodeUTF8 );
113 113
114 KABC::Addressee::List::ConstIterator it; 114 KABC::Addressee::List::ConstIterator it;
115 for ( it = list.begin(); it != list.end(); ++it ) { 115 for ( it = list.begin(); it != list.end(); ++it ) {
116 KABC::VCardConverter converter; 116 KABC::VCardConverter converter;
117 QString vcard; 117 QString vcard;
118 118
119 KABC::VCardConverter::Version version; 119 KABC::VCardConverter::Version version;
120 if ( data == "v21" ) 120 if ( data == "v21" )
121 version = KABC::VCardConverter::v2_1; 121 version = KABC::VCardConverter::v2_1;
122 else 122 else
123 version = KABC::VCardConverter::v3_0; 123 version = KABC::VCardConverter::v3_0;
124 124
125 converter.addresseeToVCard( *it, vcard, version ); 125 converter.addresseeToVCard( *it, vcard, version );
126 t << vcard << "\r\n\r\n"; 126 t << vcard << "\r\n\r\n";
127 } 127 }
128 128
129 outFile.close(); 129 outFile.close();
130 130
131 return true; 131 return true;
132} 132}
133 133
134KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const 134KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
135{ 135{
136 QString fileName; 136 QString fileName;
137 KABC::AddresseeList addrList; 137 KABC::AddresseeList addrList;
138 KURL url; 138 KURL url;
139 139
140#ifndef KAB_EMBEDDED 140#ifndef KAB_EMBEDDED
141 if ( !XXPortManager::importData.isEmpty() ) 141 if ( !XXPortManager::importData.isEmpty() )
142 addrList = parseVCard( XXPortManager::importData ); 142 addrList = parseVCard( XXPortManager::importData );
143 else { 143 else {
144 if ( XXPortManager::importURL.isEmpty() ) 144 if ( XXPortManager::importURL.isEmpty() )
145 { 145 {
146 url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); 146 url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() );
147 } 147 }
148 else 148 else
149 url = XXPortManager::importURL; 149 url = XXPortManager::importURL;
150 if ( url.isEmpty() ) 150 if ( url.isEmpty() )
151 return addrList; 151 return addrList;
152 QString caption( i18n( "vCard Import Failed" ) ); 152 QString caption( i18n( "vCard Import Failed" ) );
153 if ( KIO::NetAccess::download( url, fileName ) ) { 153 if ( KIO::NetAccess::download( url, fileName ) ) {
154 QFile file( fileName ); 154 QFile file( fileName );
155 155
156 file.open( IO_ReadOnly ); 156 file.open( IO_ReadOnly );
157 QByteArray rawData = file.readAll(); 157 QByteArray rawData = file.readAll();
158 file.close(); 158 file.close();
159 159
160 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 160 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
161 addrList = parseVCard( data ); 161 addrList = parseVCard( data );
162 162
163 if ( !url.isLocalFile() ) 163 if ( !url.isLocalFile() )
164 KIO::NetAccess::removeTempFile( fileName ); 164 KIO::NetAccess::removeTempFile( fileName );
165 165
166 } else { 166 } else {
167 QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); 167 QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" );
168 KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); 168 KMessageBox::error( parentWidget(), text.arg( url.url() ), caption );
169 } 169 }
170 170
171 } 171 }
172 172
173 173
174#else //KAB_EMBEDDED 174#else //KAB_EMBEDDED
175 175
176 176
177 if ( !XXPortManager::importData.isEmpty() ) 177 if ( !XXPortManager::importData.isEmpty() )
178 addrList = parseVCard( XXPortManager::importData ); 178 addrList = parseVCard( XXPortManager::importData );
179 else { 179 else {
180 if ( XXPortManager::importURL.isEmpty() ) 180 if ( XXPortManager::importURL.isEmpty() )
181 { 181 {
182 fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); 182 fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() );
183 183
184 if ( fileName.isEmpty() ) 184 if ( fileName.isEmpty() )
185 return addrList; 185 return addrList;
186 QFileInfo fi ( fileName ); 186 QFileInfo fi ( fileName );
187 if ( !fi.isFile() ) 187 if ( !fi.isFile() )
188 return addrList; 188 return addrList;
189 } 189 }
190 else 190 else
191 { 191 {
192 //US url = XXPortManager::importURL; 192 //US url = XXPortManager::importURL;
193 qDebug("VCardXXPort::importContacts Urls at the moment not supported"); 193 qDebug("VCardXXPort::importContacts Urls at the moment not supported");
194 if ( url.isEmpty() ) 194 if ( url.isEmpty() )
195 return addrList; 195 return addrList;
196 196
197 } 197 }
198 QFile file( fileName ); 198 QFile file( fileName );
199 if ( file.open( IO_ReadOnly ) ) { 199 if ( file.open( IO_ReadOnly ) ) {
200 QByteArray rawData = file.readAll(); 200 QCString rawData ( file.readAll().data(),file.size()+1);
201 file.close(); 201 file.close();
202 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 202 int start = 0;
203 addrList = parseVCard( data ); 203#ifndef DESKTOP_VERSION
204 while ( start < rawData.size()-2 ) {
205 if ( rawData.at( start ) == '\r' )
206 if ( rawData.at( start+1 ) == '\n' )
207 if ( rawData.at( start+2 ) == ' ' ) {
208 rawData.remove(start,3);
209 --start;
210 }
211 ++start;
212 }
213#endif
214 addrList = parseVCard( QString::fromUtf8( rawData.data() ) );
204 } 215 }
205 216
206 } 217 }
207#endif //KAB_EMBEDDED 218#endif //KAB_EMBEDDED
208 219
209 return addrList; 220 return addrList;
210} 221}
211 222
212KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const 223KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const
213{ 224{
214 225
215 KABC::VCardTool tool; 226 KABC::VCardTool tool;
216 KABC::AddresseeList addrList; 227 KABC::AddresseeList addrList;
217 addrList = tool.parseVCards( data ); 228 addrList = tool.parseVCards( data );
218 // LR : I switched to the code, which is in current cvs HEAD 229 // LR : I switched to the code, which is in current cvs HEAD
219 /* 230 /*
220 uint numVCards = data.contains( "BEGIN:VCARD", false ); 231 uint numVCards = data.contains( "BEGIN:VCARD", false );
221 QStringList dataList = QStringList::split( "\r\n\r\n", data ); 232 QStringList dataList = QStringList::split( "\r\n\r\n", data );
222 233
223 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { 234 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) {
224 KABC::Addressee addr; 235 KABC::Addressee addr;
225 bool ok = false; 236 bool ok = false;
226 237
227 if ( dataList[ i ].contains( "VERSION:3.0" ) ) 238 if ( dataList[ i ].contains( "VERSION:3.0" ) )
228 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); 239 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 );
229 else if ( dataList[ i ].contains( "VERSION:2.1" ) ) 240 else if ( dataList[ i ].contains( "VERSION:2.1" ) )
230 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); 241 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 );
231 else { 242 else {
232 KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); 243 KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) );
233 continue; 244 continue;
234 } 245 }
235 246
236 if ( !addr.isEmpty() && ok ) 247 if ( !addr.isEmpty() && ok )
237 addrList.append( addr ); 248 addrList.append( addr );
238 else { 249 else {
239 QString text = i18n( "The selected file does not include a valid vCard. " 250 QString text = i18n( "The selected file does not include a valid vCard. "
240 "Please check the file and try again." ); 251 "Please check the file and try again." );
241 KMessageBox::sorry( parentWidget(), text ); 252 KMessageBox::sorry( parentWidget(), text );
242 } 253 }
243 } 254 }
244 */ 255 */
245 if ( addrList.isEmpty() ) { 256 if ( addrList.isEmpty() ) {
246 QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); 257 QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" );
247 KMessageBox::sorry( parentWidget(), text ); 258 KMessageBox::sorry( parentWidget(), text );
248 } 259 }
249 return addrList; 260 return addrList;
250} 261}
251 262
252 263
253#ifndef KAB_EMBEDDED 264#ifndef KAB_EMBEDDED
254#include "vcard_xxport.moc" 265#include "vcard_xxport.moc"
255#endif //KAB_EMBEDDED 266#endif //KAB_EMBEDDED