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,104 +1,137 @@
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
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index b9fe6ff..ec5ed80 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -1,231 +1,223 @@
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;
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
@@ -104,152 +104,163 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString
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