summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-19 11:32:40 (UTC)
committer zautrix <zautrix>2004-09-19 11:32:40 (UTC)
commiteea0ff04703dffdbe8b67a0dc9f592597d7450c1 (patch) (unidiff)
tree874549d9c1c6239304fe1540d1b56269652954c0
parent953277a85e6ec5630ab0d64b4d68815e4e4f9906 (diff)
downloadkdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.zip
kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.gz
kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.bz2
more AB sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/address.h1
-rw-r--r--kabc/addressbook.cpp28
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp39
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp9
-rw-r--r--kaddressbook/kabcore.cpp2
7 files changed, 81 insertions, 6 deletions
diff --git a/kabc/address.h b/kabc/address.h
index 6b53c7e..37dd851 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -1,288 +1,289 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESS_H 28#ifndef KABC_ADDRESS_H
29#define KABC_ADDRESS_H 29#define KABC_ADDRESS_H
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qstring.h> 32#include <qstring.h>
33#include <qstringlist.h>
33#include <qvaluelist.h> 34#include <qvaluelist.h>
34 35
35// template tags for address formatting localization 36// template tags for address formatting localization
36#define KABC_FMTTAG_realname QString("%n") 37#define KABC_FMTTAG_realname QString("%n")
37#define KABC_FMTTAG_REALNAME QString("%N") 38#define KABC_FMTTAG_REALNAME QString("%N")
38#define KABC_FMTTAG_company QString("%cm") 39#define KABC_FMTTAG_company QString("%cm")
39#define KABC_FMTTAG_COMPANY QString("%CM") 40#define KABC_FMTTAG_COMPANY QString("%CM")
40#define KABC_FMTTAG_pobox QString("%p") 41#define KABC_FMTTAG_pobox QString("%p")
41#define KABC_FMTTAG_street QString("%s") 42#define KABC_FMTTAG_street QString("%s")
42#define KABC_FMTTAG_STREET QString("%S") 43#define KABC_FMTTAG_STREET QString("%S")
43#define KABC_FMTTAG_zipcode QString("%z") 44#define KABC_FMTTAG_zipcode QString("%z")
44#define KABC_FMTTAG_location QString("%l") 45#define KABC_FMTTAG_location QString("%l")
45#define KABC_FMTTAG_LOCATION QString("%L") 46#define KABC_FMTTAG_LOCATION QString("%L")
46#define KABC_FMTTAG_region QString("%r") 47#define KABC_FMTTAG_region QString("%r")
47#define KABC_FMTTAG_REGION QString("%R") 48#define KABC_FMTTAG_REGION QString("%R")
48#define KABC_FMTTAG_newline QString("\\n") 49#define KABC_FMTTAG_newline QString("\\n")
49#define KABC_FMTTAG_condcomma QString("%,") 50#define KABC_FMTTAG_condcomma QString("%,")
50#define KABC_FMTTAG_condwhite QString("%w") 51#define KABC_FMTTAG_condwhite QString("%w")
51#define KABC_FMTTAG_purgeempty QString("%0") 52#define KABC_FMTTAG_purgeempty QString("%0")
52 53
53namespace KABC { 54namespace KABC {
54 55
55/** 56/**
56 @short Postal address information. 57 @short Postal address information.
57 58
58 This class represents information about a postal address. 59 This class represents information about a postal address.
59*/ 60*/
60class Address 61class Address
61{ 62{
62 friend QDataStream &operator<<( QDataStream &, const Address & ); 63 friend QDataStream &operator<<( QDataStream &, const Address & );
63 friend QDataStream &operator>>( QDataStream &, Address & ); 64 friend QDataStream &operator>>( QDataStream &, Address & );
64 65
65 public: 66 public:
66 /** 67 /**
67 List of addresses. 68 List of addresses.
68 */ 69 */
69 typedef QValueList<Address> List; 70 typedef QValueList<Address> List;
70 typedef QValueList<int> TypeList; 71 typedef QValueList<int> TypeList;
71 72
72 /** 73 /**
73 Address types: 74 Address types:
74 75
75 @li @p Dom - domestic 76 @li @p Dom - domestic
76 @li @p Intl - international 77 @li @p Intl - international
77 @li @p Postal - postal 78 @li @p Postal - postal
78 @li @p Parcel - parcel 79 @li @p Parcel - parcel
79 @li @p Home - home address 80 @li @p Home - home address
80 @li @p Work - address at work 81 @li @p Work - address at work
81 @li @p Pref - preferred address 82 @li @p Pref - preferred address
82 */ 83 */
83 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, 84 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
84 Pref = 64 }; 85 Pref = 64 };
85 86
86 /** 87 /**
87 Constructor that creates an empty Address, which is initialized 88 Constructor that creates an empty Address, which is initialized
88 with a unique id (see @ref id()). 89 with a unique id (see @ref id()).
89 */ 90 */
90 Address(); 91 Address();
91 92
92 /** 93 /**
93 This is like @ref Address() just above, with the difference 94 This is like @ref Address() just above, with the difference
94 that you can specify the type. 95 that you can specify the type.
95 */ 96 */
96 Address( int ); 97 Address( int );
97 98
98 bool operator==( const Address & ) const; 99 bool operator==( const Address & ) const;
99 bool operator!=( const Address & ) const; 100 bool operator!=( const Address & ) const;
100 101
101 /** 102 /**
102 Returns true, if the address is empty. 103 Returns true, if the address is empty.
103 */ 104 */
104 bool isEmpty() const; 105 bool isEmpty() const;
105 106
106 /** 107 /**
107 Clears all entries of the address. 108 Clears all entries of the address.
108 */ 109 */
109 void clear(); 110 void clear();
110 QStringList asList(); 111 QStringList asList();
111 112
112 /** 113 /**
113 Sets the unique id. 114 Sets the unique id.
114 */ 115 */
115 void setId( const QString & ); 116 void setId( const QString & );
116 117
117 /* 118 /*
118 Returns the unique id. 119 Returns the unique id.
119 */ 120 */
120 QString id() const; 121 QString id() const;
121 122
122 /** 123 /**
123 Sets the type of address. See enum for definiton of types. 124 Sets the type of address. See enum for definiton of types.
124 125
125 @param type type, can be a bitwise or of multiple types. 126 @param type type, can be a bitwise or of multiple types.
126 */ 127 */
127 void setType( int type ); 128 void setType( int type );
128 129
129 /** 130 /**
130 Returns the type of address. Can be a bitwise or of multiple types. 131 Returns the type of address. Can be a bitwise or of multiple types.
131 */ 132 */
132 int type() const; 133 int type() const;
133 134
134 /** 135 /**
135 Returns a translated string of all types the address has. 136 Returns a translated string of all types the address has.
136 */ 137 */
137 QString typeLabel() const; 138 QString typeLabel() const;
138 139
139 /** 140 /**
140 Sets the post office box. 141 Sets the post office box.
141 */ 142 */
142 void setPostOfficeBox( const QString & ); 143 void setPostOfficeBox( const QString & );
143 144
144 /** 145 /**
145 Returns the post office box. 146 Returns the post office box.
146 */ 147 */
147 QString postOfficeBox() const; 148 QString postOfficeBox() const;
148 149
149 /** 150 /**
150 Returns the translated label for post office box field. 151 Returns the translated label for post office box field.
151 */ 152 */
152 static QString postOfficeBoxLabel(); 153 static QString postOfficeBoxLabel();
153 154
154 /** 155 /**
155 Sets the extended address information. 156 Sets the extended address information.
156 */ 157 */
157 void setExtended( const QString & ); 158 void setExtended( const QString & );
158 159
159 /** 160 /**
160 Returns the extended address information. 161 Returns the extended address information.
161 */ 162 */
162 QString extended() const; 163 QString extended() const;
163 164
164 /** 165 /**
165 Returns the translated label for extended field. 166 Returns the translated label for extended field.
166 */ 167 */
167 static QString extendedLabel(); 168 static QString extendedLabel();
168 169
169 /** 170 /**
170 Sets the street (including number). 171 Sets the street (including number).
171 */ 172 */
172 void setStreet( const QString & ); 173 void setStreet( const QString & );
173 174
174 /** 175 /**
175 Returns the street. 176 Returns the street.
176 */ 177 */
177 QString street() const; 178 QString street() const;
178 179
179 /** 180 /**
180 Returns the translated label for street field. 181 Returns the translated label for street field.
181 */ 182 */
182 static QString streetLabel(); 183 static QString streetLabel();
183 184
184 /** 185 /**
185 Sets the locality, e.g. city. 186 Sets the locality, e.g. city.
186 */ 187 */
187 void setLocality( const QString & ); 188 void setLocality( const QString & );
188 189
189 /** 190 /**
190 Returns the locality. 191 Returns the locality.
191 */ 192 */
192 QString locality() const; 193 QString locality() const;
193 194
194 /** 195 /**
195 Returns the translated label for locality field. 196 Returns the translated label for locality field.
196 */ 197 */
197 static QString localityLabel(); 198 static QString localityLabel();
198 199
199 /** 200 /**
200 Sets the region, e.g. state. 201 Sets the region, e.g. state.
201 */ 202 */
202 void setRegion( const QString & ); 203 void setRegion( const QString & );
203 204
204 /** 205 /**
205 Returns the region. 206 Returns the region.
206 */ 207 */
207 QString region() const; 208 QString region() const;
208 209
209 /** 210 /**
210 Returns the translated label for region field. 211 Returns the translated label for region field.
211 */ 212 */
212 static QString regionLabel(); 213 static QString regionLabel();
213 214
214 /** 215 /**
215 Sets the postal code. 216 Sets the postal code.
216 */ 217 */
217 void setPostalCode( const QString & ); 218 void setPostalCode( const QString & );
218 219
219 /** 220 /**
220 Returns the postal code. 221 Returns the postal code.
221 */ 222 */
222 QString postalCode() const; 223 QString postalCode() const;
223 224
224 /** 225 /**
225 Returns the translated label for postal code field. 226 Returns the translated label for postal code field.
226 */ 227 */
227 static QString postalCodeLabel(); 228 static QString postalCodeLabel();
228 229
229 /** 230 /**
230 Sets the country. 231 Sets the country.
231 */ 232 */
232 void setCountry( const QString & ); 233 void setCountry( const QString & );
233 234
234 /** 235 /**
235 Returns the country. 236 Returns the country.
236 */ 237 */
237 QString country() const; 238 QString country() const;
238 239
239 /** 240 /**
240 Returns the translated label for country field. 241 Returns the translated label for country field.
241 */ 242 */
242 static QString countryLabel(); 243 static QString countryLabel();
243 244
244 /** 245 /**
245 Sets the delivery label. This is the literal text to be used as label. 246 Sets the delivery label. This is the literal text to be used as label.
246 */ 247 */
247 void setLabel( const QString & ); 248 void setLabel( const QString & );
248 249
249 /** 250 /**
250 Returns the delivery label. 251 Returns the delivery label.
251 */ 252 */
252 QString label() const; 253 QString label() const;
253 254
254 /** 255 /**
255 Returns the translated label for delivery label field. 256 Returns the translated label for delivery label field.
256 */ 257 */
257 static QString labelLabel(); 258 static QString labelLabel();
258 259
259 /** 260 /**
260 Returns the list of available types. 261 Returns the list of available types.
261 */ 262 */
262 static TypeList typeList(); 263 static TypeList typeList();
263 264
264 /** 265 /**
265 Returns the translated label for a special type. 266 Returns the translated label for a special type.
266 */ 267 */
267 static QString typeLabel( int type ); 268 static QString typeLabel( int type );
268 269
269 /** 270 /**
270 Used for debug output. 271 Used for debug output.
271 */ 272 */
272 void dump() const; 273 void dump() const;
273 274
274 /** 275 /**
275 Returns this address formatted according to the country-specific 276 Returns this address formatted according to the country-specific
276 address formatting rules. The formatting rules applied depend on 277 address formatting rules. The formatting rules applied depend on
277 either the addresses {@link #country country} field, or (if the 278 either the addresses {@link #country country} field, or (if the
278 latter is empty) on the system country setting. If companyName is 279 latter is empty) on the system country setting. If companyName is
279 provided, an available business address format will be preferred. 280 provided, an available business address format will be preferred.
280 281
281 @param realName the formatted name of the contact 282 @param realName the formatted name of the contact
282 @param orgaName the name of the organization or company 283 @param orgaName the name of the organization or company
283 @return the formatted address (containing newline characters) 284 @return the formatted address (containing newline characters)
284 */ 285 */
285 QString formattedAddress( const QString &realName=QString::null 286 QString formattedAddress( const QString &realName=QString::null
286 , const QString &orgaName=QString::null ) const; 287 , const QString &orgaName=QString::null ) const;
287 288
288 /** 289 /**
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 46a9cf4..64832f1 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,857 +1,881 @@
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/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41 41
42#include <kglobal.h> 42#include <kglobal.h>
43#include <klocale.h> 43#include <klocale.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <libkcal/syncdefines.h> 45#include <libkcal/syncdefines.h>
46#include "addressbook.h" 46#include "addressbook.h"
47#include "resource.h" 47#include "resource.h"
48 48
49//US #include "addressbook.moc" 49//US #include "addressbook.moc"
50 50
51using namespace KABC; 51using namespace KABC;
52 52
53struct AddressBook::AddressBookData 53struct AddressBook::AddressBookData
54{ 54{
55 Addressee::List mAddressees; 55 Addressee::List mAddressees;
56 Addressee::List mRemovedAddressees; 56 Addressee::List mRemovedAddressees;
57 Field::List mAllFields; 57 Field::List mAllFields;
58 KConfig *mConfig; 58 KConfig *mConfig;
59 KRES::Manager<Resource> *mManager; 59 KRES::Manager<Resource> *mManager;
60//US ErrorHandler *mErrorHandler; 60//US ErrorHandler *mErrorHandler;
61}; 61};
62 62
63struct AddressBook::Iterator::IteratorData 63struct AddressBook::Iterator::IteratorData
64{ 64{
65 Addressee::List::Iterator mIt; 65 Addressee::List::Iterator mIt;
66}; 66};
67 67
68struct AddressBook::ConstIterator::ConstIteratorData 68struct AddressBook::ConstIterator::ConstIteratorData
69{ 69{
70 Addressee::List::ConstIterator mIt; 70 Addressee::List::ConstIterator mIt;
71}; 71};
72 72
73AddressBook::Iterator::Iterator() 73AddressBook::Iterator::Iterator()
74{ 74{
75 d = new IteratorData; 75 d = new IteratorData;
76} 76}
77 77
78AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 78AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
79{ 79{
80 d = new IteratorData; 80 d = new IteratorData;
81 d->mIt = i.d->mIt; 81 d->mIt = i.d->mIt;
82} 82}
83 83
84AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 84AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
85{ 85{
86 if( this == &i ) return *this; // guard against self assignment 86 if( this == &i ) return *this; // guard against self assignment
87 delete d; // delete the old data the Iterator was completely constructed before 87 delete d; // delete the old data the Iterator was completely constructed before
88 d = new IteratorData; 88 d = new IteratorData;
89 d->mIt = i.d->mIt; 89 d->mIt = i.d->mIt;
90 return *this; 90 return *this;
91} 91}
92 92
93AddressBook::Iterator::~Iterator() 93AddressBook::Iterator::~Iterator()
94{ 94{
95 delete d; 95 delete d;
96} 96}
97 97
98const Addressee &AddressBook::Iterator::operator*() const 98const Addressee &AddressBook::Iterator::operator*() const
99{ 99{
100 return *(d->mIt); 100 return *(d->mIt);
101} 101}
102 102
103Addressee &AddressBook::Iterator::operator*() 103Addressee &AddressBook::Iterator::operator*()
104{ 104{
105 return *(d->mIt); 105 return *(d->mIt);
106} 106}
107 107
108Addressee *AddressBook::Iterator::operator->() 108Addressee *AddressBook::Iterator::operator->()
109{ 109{
110 return &(*(d->mIt)); 110 return &(*(d->mIt));
111} 111}
112 112
113AddressBook::Iterator &AddressBook::Iterator::operator++() 113AddressBook::Iterator &AddressBook::Iterator::operator++()
114{ 114{
115 (d->mIt)++; 115 (d->mIt)++;
116 return *this; 116 return *this;
117} 117}
118 118
119AddressBook::Iterator &AddressBook::Iterator::operator++(int) 119AddressBook::Iterator &AddressBook::Iterator::operator++(int)
120{ 120{
121 (d->mIt)++; 121 (d->mIt)++;
122 return *this; 122 return *this;
123} 123}
124 124
125AddressBook::Iterator &AddressBook::Iterator::operator--() 125AddressBook::Iterator &AddressBook::Iterator::operator--()
126{ 126{
127 (d->mIt)--; 127 (d->mIt)--;
128 return *this; 128 return *this;
129} 129}
130 130
131AddressBook::Iterator &AddressBook::Iterator::operator--(int) 131AddressBook::Iterator &AddressBook::Iterator::operator--(int)
132{ 132{
133 (d->mIt)--; 133 (d->mIt)--;
134 return *this; 134 return *this;
135} 135}
136 136
137bool AddressBook::Iterator::operator==( const Iterator &it ) 137bool AddressBook::Iterator::operator==( const Iterator &it )
138{ 138{
139 return ( d->mIt == it.d->mIt ); 139 return ( d->mIt == it.d->mIt );
140} 140}
141 141
142bool AddressBook::Iterator::operator!=( const Iterator &it ) 142bool AddressBook::Iterator::operator!=( const Iterator &it )
143{ 143{
144 return ( d->mIt != it.d->mIt ); 144 return ( d->mIt != it.d->mIt );
145} 145}
146 146
147 147
148AddressBook::ConstIterator::ConstIterator() 148AddressBook::ConstIterator::ConstIterator()
149{ 149{
150 d = new ConstIteratorData; 150 d = new ConstIteratorData;
151} 151}
152 152
153AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 153AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
154{ 154{
155 d = new ConstIteratorData; 155 d = new ConstIteratorData;
156 d->mIt = i.d->mIt; 156 d->mIt = i.d->mIt;
157} 157}
158 158
159AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 159AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
160{ 160{
161 if( this == &i ) return *this; // guard for self assignment 161 if( this == &i ) return *this; // guard for self assignment
162 delete d; // delete the old data because the Iterator was really constructed before 162 delete d; // delete the old data because the Iterator was really constructed before
163 d = new ConstIteratorData; 163 d = new ConstIteratorData;
164 d->mIt = i.d->mIt; 164 d->mIt = i.d->mIt;
165 return *this; 165 return *this;
166} 166}
167 167
168AddressBook::ConstIterator::~ConstIterator() 168AddressBook::ConstIterator::~ConstIterator()
169{ 169{
170 delete d; 170 delete d;
171} 171}
172 172
173const Addressee &AddressBook::ConstIterator::operator*() const 173const Addressee &AddressBook::ConstIterator::operator*() const
174{ 174{
175 return *(d->mIt); 175 return *(d->mIt);
176} 176}
177 177
178const Addressee* AddressBook::ConstIterator::operator->() const 178const Addressee* AddressBook::ConstIterator::operator->() const
179{ 179{
180 return &(*(d->mIt)); 180 return &(*(d->mIt));
181} 181}
182 182
183AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 183AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
184{ 184{
185 (d->mIt)++; 185 (d->mIt)++;
186 return *this; 186 return *this;
187} 187}
188 188
189AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 189AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
190{ 190{
191 (d->mIt)++; 191 (d->mIt)++;
192 return *this; 192 return *this;
193} 193}
194 194
195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
196{ 196{
197 (d->mIt)--; 197 (d->mIt)--;
198 return *this; 198 return *this;
199} 199}
200 200
201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
202{ 202{
203 (d->mIt)--; 203 (d->mIt)--;
204 return *this; 204 return *this;
205} 205}
206 206
207bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 207bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
208{ 208{
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
210} 210}
211 211
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 213{
214 return ( d->mIt != it.d->mIt ); 214 return ( d->mIt != it.d->mIt );
215} 215}
216 216
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false; 237 blockLSEchange = false;
238 d = new AddressBookData; 238 d = new AddressBookData;
239 QString fami = family; 239 QString fami = family;
240 qDebug("new ab "); 240 qDebug("new ab ");
241 if (config != 0) { 241 if (config != 0) {
242 qDebug("config != 0 "); 242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 243 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 244 qDebug("creating sync config ");
245 fami = "contact"; 245 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 247 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 248 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 249 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 250 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileFormat", QString("vcard") );
252 con->writeEntry( "FileName", config ); 251 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 253 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 254 con->writeEntry( "ResourceName", QString("sync_res") );
255 con->writeEntry( "ResourceType", QString("file") ); 255 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") );
257 else
258 con->writeEntry( "ResourceType", QString("file") );
256 //con->sync(); 259 //con->sync();
257 d->mConfig = con; 260 d->mConfig = con;
258 } 261 }
259 else 262 else
260 d->mConfig = new KConfig( locateLocal("config", config) ); 263 d->mConfig = new KConfig( locateLocal("config", config) );
261// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 264// qDebug("AddressBook::init 1 config=%s",config.latin1() );
262 } 265 }
263 else { 266 else {
264 d->mConfig = 0; 267 d->mConfig = 0;
265// qDebug("AddressBook::init 1 config=0"); 268// qDebug("AddressBook::init 1 config=0");
266 } 269 }
267 270
268//US d->mErrorHandler = 0; 271//US d->mErrorHandler = 0;
269 d->mManager = new KRES::Manager<Resource>( fami, false ); 272 d->mManager = new KRES::Manager<Resource>( fami, false );
270 d->mManager->readConfig( d->mConfig ); 273 d->mManager->readConfig( d->mConfig );
271 if ( family == "syncContact" ) { 274 if ( family == "syncContact" ) {
272 KRES::Manager<Resource> *manager = d->mManager; 275 KRES::Manager<Resource> *manager = d->mManager;
273 KRES::Manager<Resource>::ActiveIterator it; 276 KRES::Manager<Resource>::ActiveIterator it;
274 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 277 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
275 (*it)->setAddressBook( this ); 278 (*it)->setAddressBook( this );
276 if ( !(*it)->open() ) 279 if ( !(*it)->open() )
277 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 280 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
278 } 281 }
279 Resource *res = standardResource(); 282 Resource *res = standardResource();
280 if ( !res ) { 283 if ( !res ) {
281 qDebug("ERROR: no standard resource"); 284 qDebug("ERROR: no standard resource");
282 res = manager->createResource( "file" ); 285 res = manager->createResource( "file" );
283 if ( res ) 286 if ( res )
284 { 287 {
285 addResource( res ); 288 addResource( res );
286 } 289 }
287 else 290 else
288 qDebug(" No resource available!!!"); 291 qDebug(" No resource available!!!");
289 } 292 }
290 setStandardResource( res ); 293 setStandardResource( res );
291 manager->writeConfig(); 294 manager->writeConfig();
292 } 295 }
293 addCustomField( i18n( "Department" ), KABC::Field::Organization, 296 addCustomField( i18n( "Department" ), KABC::Field::Organization,
294 "X-Department", "KADDRESSBOOK" ); 297 "X-Department", "KADDRESSBOOK" );
295 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 298 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
296 "X-Profession", "KADDRESSBOOK" ); 299 "X-Profession", "KADDRESSBOOK" );
297 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 300 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
298 "X-AssistantsName", "KADDRESSBOOK" ); 301 "X-AssistantsName", "KADDRESSBOOK" );
299 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 302 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
300 "X-ManagersName", "KADDRESSBOOK" ); 303 "X-ManagersName", "KADDRESSBOOK" );
301 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 304 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
302 "X-SpousesName", "KADDRESSBOOK" ); 305 "X-SpousesName", "KADDRESSBOOK" );
303 addCustomField( i18n( "Office" ), KABC::Field::Personal, 306 addCustomField( i18n( "Office" ), KABC::Field::Personal,
304 "X-Office", "KADDRESSBOOK" ); 307 "X-Office", "KADDRESSBOOK" );
305 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 308 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
306 "X-IMAddress", "KADDRESSBOOK" ); 309 "X-IMAddress", "KADDRESSBOOK" );
307 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 310 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
308 "X-Anniversary", "KADDRESSBOOK" ); 311 "X-Anniversary", "KADDRESSBOOK" );
309 312
310 //US added this field to become compatible with Opie/qtopia addressbook 313 //US added this field to become compatible with Opie/qtopia addressbook
311 // values can be "female" or "male" or "". An empty field represents undefined. 314 // values can be "female" or "male" or "". An empty field represents undefined.
312 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 315 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
313 "X-Gender", "KADDRESSBOOK" ); 316 "X-Gender", "KADDRESSBOOK" );
314 addCustomField( i18n( "Children" ), KABC::Field::Personal, 317 addCustomField( i18n( "Children" ), KABC::Field::Personal,
315 "X-Children", "KADDRESSBOOK" ); 318 "X-Children", "KADDRESSBOOK" );
316 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 319 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
317 "X-FreeBusyUrl", "KADDRESSBOOK" ); 320 "X-FreeBusyUrl", "KADDRESSBOOK" );
318 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 321 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
319 "X-ExternalID", "KADDRESSBOOK" ); 322 "X-ExternalID", "KADDRESSBOOK" );
320} 323}
321 324
322AddressBook::~AddressBook() 325AddressBook::~AddressBook()
323{ 326{
324 delete d->mConfig; d->mConfig = 0; 327 delete d->mConfig; d->mConfig = 0;
325 delete d->mManager; d->mManager = 0; 328 delete d->mManager; d->mManager = 0;
326//US delete d->mErrorHandler; d->mErrorHandler = 0; 329//US delete d->mErrorHandler; d->mErrorHandler = 0;
327 delete d; d = 0; 330 delete d; d = 0;
328} 331}
329 332
330bool AddressBook::load() 333bool AddressBook::load()
331{ 334{
332 335
333 336
334 clear(); 337 clear();
335 338
336 KRES::Manager<Resource>::ActiveIterator it; 339 KRES::Manager<Resource>::ActiveIterator it;
337 bool ok = true; 340 bool ok = true;
338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 341 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
339 if ( !(*it)->load() ) { 342 if ( !(*it)->load() ) {
340 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 343 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
341 ok = false; 344 ok = false;
342 } 345 }
343 346
344 // mark all addressees as unchanged 347 // mark all addressees as unchanged
345 Addressee::List::Iterator addrIt; 348 Addressee::List::Iterator addrIt;
346 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 349 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
347 (*addrIt).setChanged( false ); 350 (*addrIt).setChanged( false );
348 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 351 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
349 if ( !id.isEmpty() ) { 352 if ( !id.isEmpty() ) {
350 //qDebug("setId aa %s ", id.latin1()); 353 //qDebug("setId aa %s ", id.latin1());
351 (*addrIt).setIDStr(id ); 354 (*addrIt).setIDStr(id );
352 } 355 }
353 } 356 }
354 blockLSEchange = true; 357 blockLSEchange = true;
355 return ok; 358 return ok;
356} 359}
357 360
358bool AddressBook::save( Ticket *ticket ) 361bool AddressBook::save( Ticket *ticket )
359{ 362{
360 kdDebug(5700) << "AddressBook::save()"<< endl; 363 kdDebug(5700) << "AddressBook::save()"<< endl;
361 364
362 if ( ticket->resource() ) { 365 if ( ticket->resource() ) {
363 deleteRemovedAddressees(); 366 deleteRemovedAddressees();
364 return ticket->resource()->save( ticket ); 367 return ticket->resource()->save( ticket );
365 } 368 }
366 369
367 return false; 370 return false;
368} 371}
369bool AddressBook::saveAB() 372bool AddressBook::saveAB()
370{ 373{
371 bool ok = true; 374 bool ok = true;
372 375
373 deleteRemovedAddressees(); 376 deleteRemovedAddressees();
374 Iterator ait; 377 Iterator ait;
375 for ( ait = begin(); ait != end(); ++ait ) { 378 for ( ait = begin(); ait != end(); ++ait ) {
376 if ( !(*ait).IDStr().isEmpty() ) { 379 if ( !(*ait).IDStr().isEmpty() ) {
377 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 380 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
378 } 381 }
379 } 382 }
380 KRES::Manager<Resource>::ActiveIterator it; 383 KRES::Manager<Resource>::ActiveIterator it;
381 KRES::Manager<Resource> *manager = d->mManager; 384 KRES::Manager<Resource> *manager = d->mManager;
382 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 385 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
383 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 386 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
384 Ticket *ticket = requestSaveTicket( *it ); 387 Ticket *ticket = requestSaveTicket( *it );
385// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 388// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
386 if ( !ticket ) { 389 if ( !ticket ) {
387 error( i18n( "Unable to save to resource '%1'. It is locked." ) 390 error( i18n( "Unable to save to resource '%1'. It is locked." )
388 .arg( (*it)->resourceName() ) ); 391 .arg( (*it)->resourceName() ) );
389 return false; 392 return false;
390 } 393 }
391 394
392 //if ( !save( ticket ) ) 395 //if ( !save( ticket ) )
393 if ( ticket->resource() ) { 396 if ( ticket->resource() ) {
394 if ( ! ticket->resource()->save( ticket ) ) 397 if ( ! ticket->resource()->save( ticket ) )
395 ok = false; 398 ok = false;
396 } else 399 } else
397 ok = false; 400 ok = false;
398 401
399 } 402 }
400 } 403 }
401 return ok; 404 return ok;
402} 405}
403 406
404AddressBook::Iterator AddressBook::begin() 407AddressBook::Iterator AddressBook::begin()
405{ 408{
406 Iterator it = Iterator(); 409 Iterator it = Iterator();
407 it.d->mIt = d->mAddressees.begin(); 410 it.d->mIt = d->mAddressees.begin();
408 return it; 411 return it;
409} 412}
410 413
411AddressBook::ConstIterator AddressBook::begin() const 414AddressBook::ConstIterator AddressBook::begin() const
412{ 415{
413 ConstIterator it = ConstIterator(); 416 ConstIterator it = ConstIterator();
414 it.d->mIt = d->mAddressees.begin(); 417 it.d->mIt = d->mAddressees.begin();
415 return it; 418 return it;
416} 419}
417 420
418AddressBook::Iterator AddressBook::end() 421AddressBook::Iterator AddressBook::end()
419{ 422{
420 Iterator it = Iterator(); 423 Iterator it = Iterator();
421 it.d->mIt = d->mAddressees.end(); 424 it.d->mIt = d->mAddressees.end();
422 return it; 425 return it;
423} 426}
424 427
425AddressBook::ConstIterator AddressBook::end() const 428AddressBook::ConstIterator AddressBook::end() const
426{ 429{
427 ConstIterator it = ConstIterator(); 430 ConstIterator it = ConstIterator();
428 it.d->mIt = d->mAddressees.end(); 431 it.d->mIt = d->mAddressees.end();
429 return it; 432 return it;
430} 433}
431 434
432void AddressBook::clear() 435void AddressBook::clear()
433{ 436{
434 d->mAddressees.clear(); 437 d->mAddressees.clear();
435} 438}
436 439
437Ticket *AddressBook::requestSaveTicket( Resource *resource ) 440Ticket *AddressBook::requestSaveTicket( Resource *resource )
438{ 441{
439 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 442 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
440 443
441 if ( !resource ) 444 if ( !resource )
442 { 445 {
443 qDebug("AddressBook::requestSaveTicket no resource" ); 446 qDebug("AddressBook::requestSaveTicket no resource" );
444 resource = standardResource(); 447 resource = standardResource();
445 } 448 }
446 449
447 KRES::Manager<Resource>::ActiveIterator it; 450 KRES::Manager<Resource>::ActiveIterator it;
448 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 451 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
449 if ( (*it) == resource ) { 452 if ( (*it) == resource ) {
450 if ( (*it)->readOnly() || !(*it)->isOpen() ) 453 if ( (*it)->readOnly() || !(*it)->isOpen() )
451 return 0; 454 return 0;
452 else 455 else
453 return (*it)->requestSaveTicket(); 456 return (*it)->requestSaveTicket();
454 } 457 }
455 } 458 }
456 459
457 return 0; 460 return 0;
458} 461}
459 462
460void AddressBook::insertAddressee( const Addressee &a, bool setRev ) 463void AddressBook::insertAddressee( const Addressee &a, bool setRev )
461{ 464{
462 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 465 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
463 //qDebug("block insert "); 466 //qDebug("block insert ");
464 return; 467 return;
465 } 468 }
466 //qDebug("inserting.... %s ",a.uid().latin1() ); 469 //qDebug("inserting.... %s ",a.uid().latin1() );
467 bool found = false; 470 bool found = false;
468 Addressee::List::Iterator it; 471 Addressee::List::Iterator it;
469 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 472 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
470 if ( a.uid() == (*it).uid() ) { 473 if ( a.uid() == (*it).uid() ) {
471 474
472 bool changed = false; 475 bool changed = false;
473 Addressee addr = a; 476 Addressee addr = a;
474 if ( addr != (*it) ) 477 if ( addr != (*it) )
475 changed = true; 478 changed = true;
476 479
477 (*it) = a; 480 (*it) = a;
478 if ( (*it).resource() == 0 ) 481 if ( (*it).resource() == 0 )
479 (*it).setResource( standardResource() ); 482 (*it).setResource( standardResource() );
480 483
481 if ( changed ) { 484 if ( changed ) {
482 if ( setRev ) { 485 if ( setRev ) {
483 486
484 // get rid of micro seconds 487 // get rid of micro seconds
485 QDateTime dt = QDateTime::currentDateTime(); 488 QDateTime dt = QDateTime::currentDateTime();
486 QTime t = dt.time(); 489 QTime t = dt.time();
487 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 490 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
488 (*it).setRevision( dt ); 491 (*it).setRevision( dt );
489 } 492 }
490 (*it).setChanged( true ); 493 (*it).setChanged( true );
491 } 494 }
492 495
493 found = true; 496 found = true;
494 } else { 497 } else {
495 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 498 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
496 QString name = (*it).uid().mid( 19 ); 499 QString name = (*it).uid().mid( 19 );
497 Addressee b = a; 500 Addressee b = a;
498 QString id = b.getID( name ); 501 QString id = b.getID( name );
499 if ( ! id.isEmpty() ) { 502 if ( ! id.isEmpty() ) {
500 QString des = (*it).note(); 503 QString des = (*it).note();
501 int startN; 504 int startN;
502 if( (startN = des.find( id ) ) >= 0 ) { 505 if( (startN = des.find( id ) ) >= 0 ) {
503 int endN = des.find( ",", startN+1 ); 506 int endN = des.find( ",", startN+1 );
504 des = des.left( startN ) + des.mid( endN+1 ); 507 des = des.left( startN ) + des.mid( endN+1 );
505 (*it).setNote( des ); 508 (*it).setNote( des );
506 } 509 }
507 } 510 }
508 } 511 }
509 } 512 }
510 } 513 }
511 if ( found ) 514 if ( found )
512 return; 515 return;
513 d->mAddressees.append( a ); 516 d->mAddressees.append( a );
514 Addressee& addr = d->mAddressees.last(); 517 Addressee& addr = d->mAddressees.last();
515 if ( addr.resource() == 0 ) 518 if ( addr.resource() == 0 )
516 addr.setResource( standardResource() ); 519 addr.setResource( standardResource() );
517 520
518 addr.setChanged( true ); 521 addr.setChanged( true );
519} 522}
520 523
521void AddressBook::removeAddressee( const Addressee &a ) 524void AddressBook::removeAddressee( const Addressee &a )
522{ 525{
523 Iterator it; 526 Iterator it;
524 Iterator it2; 527 Iterator it2;
525 bool found = false; 528 bool found = false;
526 for ( it = begin(); it != end(); ++it ) { 529 for ( it = begin(); it != end(); ++it ) {
527 if ( a.uid() == (*it).uid() ) { 530 if ( a.uid() == (*it).uid() ) {
528 found = true; 531 found = true;
529 it2 = it; 532 it2 = it;
530 } else { 533 } else {
531 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 534 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
532 QString name = (*it).uid().mid( 19 ); 535 QString name = (*it).uid().mid( 19 );
533 Addressee b = a; 536 Addressee b = a;
534 QString id = b.getID( name ); 537 QString id = b.getID( name );
535 if ( ! id.isEmpty() ) { 538 if ( ! id.isEmpty() ) {
536 QString des = (*it).note(); 539 QString des = (*it).note();
537 if( des.find( id ) < 0 ) { 540 if( des.find( id ) < 0 ) {
538 des += id + ","; 541 des += id + ",";
539 (*it).setNote( des ); 542 (*it).setNote( des );
540 } 543 }
541 } 544 }
542 } 545 }
543 546
544 } 547 }
545 } 548 }
546 549
547 if ( found ) 550 if ( found )
548 removeAddressee( it2 ); 551 removeAddressee( it2 );
549 552
550} 553}
551 554
552void AddressBook::removeDeletedAddressees() 555void AddressBook::removeDeletedAddressees()
553{ 556{
554 deleteRemovedAddressees(); 557 deleteRemovedAddressees();
555 Iterator it = begin(); 558 Iterator it = begin();
556 Iterator it2 ; 559 Iterator it2 ;
557 QDateTime dt ( QDate( 2004,1,1) ); 560 QDateTime dt ( QDate( 2004,1,1) );
558 while ( it != end() ) { 561 while ( it != end() ) {
559 (*it).setRevision( dt ); 562 (*it).setRevision( dt );
560 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 563 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
561 (*it).setIDStr(""); 564 (*it).setIDStr("");
562 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 565 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
563 it2 = it; 566 it2 = it;
564 //qDebug("removing %s ",(*it).uid().latin1() ); 567 //qDebug("removing %s ",(*it).uid().latin1() );
565 ++it; 568 ++it;
566 removeAddressee( it2 ); 569 removeAddressee( it2 );
567 } else { 570 } else {
568 //qDebug("skipping %s ",(*it).uid().latin1() ); 571 //qDebug("skipping %s ",(*it).uid().latin1() );
569 ++it; 572 ++it;
570 } 573 }
571 } 574 }
572 deleteRemovedAddressees(); 575 deleteRemovedAddressees();
573} 576}
574 577
575void AddressBook::removeAddressee( const Iterator &it ) 578void AddressBook::removeAddressee( const Iterator &it )
576{ 579{
577 d->mRemovedAddressees.append( (*it) ); 580 d->mRemovedAddressees.append( (*it) );
578 d->mAddressees.remove( it.d->mIt ); 581 d->mAddressees.remove( it.d->mIt );
579} 582}
580 583
581AddressBook::Iterator AddressBook::find( const Addressee &a ) 584AddressBook::Iterator AddressBook::find( const Addressee &a )
582{ 585{
583 Iterator it; 586 Iterator it;
584 for ( it = begin(); it != end(); ++it ) { 587 for ( it = begin(); it != end(); ++it ) {
585 if ( a.uid() == (*it).uid() ) { 588 if ( a.uid() == (*it).uid() ) {
586 return it; 589 return it;
587 } 590 }
588 } 591 }
589 return end(); 592 return end();
590} 593}
591 594
592Addressee AddressBook::findByUid( const QString &uid ) 595Addressee AddressBook::findByUid( const QString &uid )
593{ 596{
594 Iterator it; 597 Iterator it;
595 for ( it = begin(); it != end(); ++it ) { 598 for ( it = begin(); it != end(); ++it ) {
596 if ( uid == (*it).uid() ) { 599 if ( uid == (*it).uid() ) {
597 return *it; 600 return *it;
598 } 601 }
599 } 602 }
600 return Addressee(); 603 return Addressee();
601} 604}
605Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
606{
607 Iterator it;
608 for ( it = begin(); it != end(); ++it ) {
609 if ( uid == (*it).getID( profile ) )
610 return (*it);
611 }
612 return Addressee();
613}
614void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
615{
616 Iterator it;
617 Addressee ad;
618 for ( it = begin(); it != end(); ++it ) {
619 ad = aBook->findByExternUid( (*it).externalUID(), profile );
620 if ( !ad.isEmpty() ) {
621 (*it).mergeContact( ad );
622 }
623 }
624}
625
602#if 0 626#if 0
603Addressee::List AddressBook::getExternLastSyncAddressees() 627Addressee::List AddressBook::getExternLastSyncAddressees()
604{ 628{
605 Addressee::List results; 629 Addressee::List results;
606 630
607 Iterator it; 631 Iterator it;
608 for ( it = begin(); it != end(); ++it ) { 632 for ( it = begin(); it != end(); ++it ) {
609 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 633 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
610 if ( (*it).familyName().left(4) == "!E: " ) 634 if ( (*it).familyName().left(4) == "!E: " )
611 results.append( *it ); 635 results.append( *it );
612 } 636 }
613 } 637 }
614 638
615 return results; 639 return results;
616} 640}
617#endif 641#endif
618void AddressBook::resetTempSyncStat() 642void AddressBook::resetTempSyncStat()
619{ 643{
620 Iterator it; 644 Iterator it;
621 for ( it = begin(); it != end(); ++it ) { 645 for ( it = begin(); it != end(); ++it ) {
622 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 646 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
623 } 647 }
624 648
625} 649}
626 650
627QStringList AddressBook:: uidList() 651QStringList AddressBook:: uidList()
628{ 652{
629 QStringList results; 653 QStringList results;
630 Iterator it; 654 Iterator it;
631 for ( it = begin(); it != end(); ++it ) { 655 for ( it = begin(); it != end(); ++it ) {
632 results.append( (*it).uid() ); 656 results.append( (*it).uid() );
633 } 657 }
634 return results; 658 return results;
635} 659}
636 660
637 661
638Addressee::List AddressBook::allAddressees() 662Addressee::List AddressBook::allAddressees()
639{ 663{
640 return d->mAddressees; 664 return d->mAddressees;
641 665
642} 666}
643 667
644Addressee::List AddressBook::findByName( const QString &name ) 668Addressee::List AddressBook::findByName( const QString &name )
645{ 669{
646 Addressee::List results; 670 Addressee::List results;
647 671
648 Iterator it; 672 Iterator it;
649 for ( it = begin(); it != end(); ++it ) { 673 for ( it = begin(); it != end(); ++it ) {
650 if ( name == (*it).realName() ) { 674 if ( name == (*it).realName() ) {
651 results.append( *it ); 675 results.append( *it );
652 } 676 }
653 } 677 }
654 678
655 return results; 679 return results;
656} 680}
657 681
658Addressee::List AddressBook::findByEmail( const QString &email ) 682Addressee::List AddressBook::findByEmail( const QString &email )
659{ 683{
660 Addressee::List results; 684 Addressee::List results;
661 QStringList mailList; 685 QStringList mailList;
662 686
663 Iterator it; 687 Iterator it;
664 for ( it = begin(); it != end(); ++it ) { 688 for ( it = begin(); it != end(); ++it ) {
665 mailList = (*it).emails(); 689 mailList = (*it).emails();
666 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 690 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
667 if ( email == (*ite) ) { 691 if ( email == (*ite) ) {
668 results.append( *it ); 692 results.append( *it );
669 } 693 }
670 } 694 }
671 } 695 }
672 696
673 return results; 697 return results;
674} 698}
675 699
676Addressee::List AddressBook::findByCategory( const QString &category ) 700Addressee::List AddressBook::findByCategory( const QString &category )
677{ 701{
678 Addressee::List results; 702 Addressee::List results;
679 703
680 Iterator it; 704 Iterator it;
681 for ( it = begin(); it != end(); ++it ) { 705 for ( it = begin(); it != end(); ++it ) {
682 if ( (*it).hasCategory( category) ) { 706 if ( (*it).hasCategory( category) ) {
683 results.append( *it ); 707 results.append( *it );
684 } 708 }
685 } 709 }
686 710
687 return results; 711 return results;
688} 712}
689 713
690void AddressBook::dump() const 714void AddressBook::dump() const
691{ 715{
692 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 716 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
693 717
694 ConstIterator it; 718 ConstIterator it;
695 for( it = begin(); it != end(); ++it ) { 719 for( it = begin(); it != end(); ++it ) {
696 (*it).dump(); 720 (*it).dump();
697 } 721 }
698 722
699 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 723 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
700} 724}
701 725
702QString AddressBook::identifier() 726QString AddressBook::identifier()
703{ 727{
704 QStringList identifier; 728 QStringList identifier;
705 729
706 730
707 KRES::Manager<Resource>::ActiveIterator it; 731 KRES::Manager<Resource>::ActiveIterator it;
708 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 732 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
709 if ( !(*it)->identifier().isEmpty() ) 733 if ( !(*it)->identifier().isEmpty() )
710 identifier.append( (*it)->identifier() ); 734 identifier.append( (*it)->identifier() );
711 } 735 }
712 736
713 return identifier.join( ":" ); 737 return identifier.join( ":" );
714} 738}
715 739
716Field::List AddressBook::fields( int category ) 740Field::List AddressBook::fields( int category )
717{ 741{
718 if ( d->mAllFields.isEmpty() ) { 742 if ( d->mAllFields.isEmpty() ) {
719 d->mAllFields = Field::allFields(); 743 d->mAllFields = Field::allFields();
720 } 744 }
721 745
722 if ( category == Field::All ) return d->mAllFields; 746 if ( category == Field::All ) return d->mAllFields;
723 747
724 Field::List result; 748 Field::List result;
725 Field::List::ConstIterator it; 749 Field::List::ConstIterator it;
726 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 750 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
727 if ( (*it)->category() & category ) result.append( *it ); 751 if ( (*it)->category() & category ) result.append( *it );
728 } 752 }
729 753
730 return result; 754 return result;
731} 755}
732 756
733bool AddressBook::addCustomField( const QString &label, int category, 757bool AddressBook::addCustomField( const QString &label, int category,
734 const QString &key, const QString &app ) 758 const QString &key, const QString &app )
735{ 759{
736 if ( d->mAllFields.isEmpty() ) { 760 if ( d->mAllFields.isEmpty() ) {
737 d->mAllFields = Field::allFields(); 761 d->mAllFields = Field::allFields();
738 } 762 }
739//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 763//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
740 QString a = app.isNull() ? KGlobal::getAppName() : app; 764 QString a = app.isNull() ? KGlobal::getAppName() : app;
741 765
742 QString k = key.isNull() ? label : key; 766 QString k = key.isNull() ? label : key;
743 767
744 Field *field = Field::createCustomField( label, category, k, a ); 768 Field *field = Field::createCustomField( label, category, k, a );
745 769
746 if ( !field ) return false; 770 if ( !field ) return false;
747 771
748 d->mAllFields.append( field ); 772 d->mAllFields.append( field );
749 773
750 return true; 774 return true;
751} 775}
752 776
753QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 777QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
754{ 778{
755 if (!ab.d) return s; 779 if (!ab.d) return s;
756 780
757 return s << ab.d->mAddressees; 781 return s << ab.d->mAddressees;
758} 782}
759 783
760QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 784QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
761{ 785{
762 if (!ab.d) return s; 786 if (!ab.d) return s;
763 787
764 s >> ab.d->mAddressees; 788 s >> ab.d->mAddressees;
765 789
766 return s; 790 return s;
767} 791}
768 792
769bool AddressBook::addResource( Resource *resource ) 793bool AddressBook::addResource( Resource *resource )
770{ 794{
771 if ( !resource->open() ) { 795 if ( !resource->open() ) {
772 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 796 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
773 return false; 797 return false;
774 } 798 }
775 799
776 resource->setAddressBook( this ); 800 resource->setAddressBook( this );
777 801
778 d->mManager->add( resource ); 802 d->mManager->add( resource );
779 return true; 803 return true;
780} 804}
781 805
782bool AddressBook::removeResource( Resource *resource ) 806bool AddressBook::removeResource( Resource *resource )
783{ 807{
784 resource->close(); 808 resource->close();
785 809
786 if ( resource == standardResource() ) 810 if ( resource == standardResource() )
787 d->mManager->setStandardResource( 0 ); 811 d->mManager->setStandardResource( 0 );
788 812
789 resource->setAddressBook( 0 ); 813 resource->setAddressBook( 0 );
790 814
791 d->mManager->remove( resource ); 815 d->mManager->remove( resource );
792 return true; 816 return true;
793} 817}
794 818
795QPtrList<Resource> AddressBook::resources() 819QPtrList<Resource> AddressBook::resources()
796{ 820{
797 QPtrList<Resource> list; 821 QPtrList<Resource> list;
798 822
799// qDebug("AddressBook::resources() 1"); 823// qDebug("AddressBook::resources() 1");
800 824
801 KRES::Manager<Resource>::ActiveIterator it; 825 KRES::Manager<Resource>::ActiveIterator it;
802 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 826 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
803 list.append( *it ); 827 list.append( *it );
804 828
805 return list; 829 return list;
806} 830}
807 831
808/*US 832/*US
809void AddressBook::setErrorHandler( ErrorHandler *handler ) 833void AddressBook::setErrorHandler( ErrorHandler *handler )
810{ 834{
811 delete d->mErrorHandler; 835 delete d->mErrorHandler;
812 d->mErrorHandler = handler; 836 d->mErrorHandler = handler;
813} 837}
814*/ 838*/
815 839
816void AddressBook::error( const QString& msg ) 840void AddressBook::error( const QString& msg )
817{ 841{
818/*US 842/*US
819 if ( !d->mErrorHandler ) // create default error handler 843 if ( !d->mErrorHandler ) // create default error handler
820 d->mErrorHandler = new ConsoleErrorHandler; 844 d->mErrorHandler = new ConsoleErrorHandler;
821 845
822 if ( d->mErrorHandler ) 846 if ( d->mErrorHandler )
823 d->mErrorHandler->error( msg ); 847 d->mErrorHandler->error( msg );
824 else 848 else
825 kdError(5700) << "no error handler defined" << endl; 849 kdError(5700) << "no error handler defined" << endl;
826*/ 850*/
827 kdDebug(5700) << "msg" << endl; 851 kdDebug(5700) << "msg" << endl;
828 qDebug(msg); 852 qDebug(msg);
829} 853}
830 854
831void AddressBook::deleteRemovedAddressees() 855void AddressBook::deleteRemovedAddressees()
832{ 856{
833 Addressee::List::Iterator it; 857 Addressee::List::Iterator it;
834 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 858 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
835 Resource *resource = (*it).resource(); 859 Resource *resource = (*it).resource();
836 if ( resource && !resource->readOnly() && resource->isOpen() ) 860 if ( resource && !resource->readOnly() && resource->isOpen() )
837 resource->removeAddressee( *it ); 861 resource->removeAddressee( *it );
838 } 862 }
839 863
840 d->mRemovedAddressees.clear(); 864 d->mRemovedAddressees.clear();
841} 865}
842 866
843void AddressBook::setStandardResource( Resource *resource ) 867void AddressBook::setStandardResource( Resource *resource )
844{ 868{
845// qDebug("AddressBook::setStandardResource 1"); 869// qDebug("AddressBook::setStandardResource 1");
846 d->mManager->setStandardResource( resource ); 870 d->mManager->setStandardResource( resource );
847} 871}
848 872
849Resource *AddressBook::standardResource() 873Resource *AddressBook::standardResource()
850{ 874{
851 return d->mManager->standardResource(); 875 return d->mManager->standardResource();
852} 876}
853 877
854KRES::Manager<Resource> *AddressBook::resourceManager() 878KRES::Manager<Resource> *AddressBook::resourceManager()
855{ 879{
856 return d->mManager; 880 return d->mManager;
857} 881}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 2f2678b..f40e015 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -40,297 +40,297 @@ namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 145
146 /** 146 /**
147 Returns a iterator for first entry of address book. 147 Returns a iterator for first entry of address book.
148 */ 148 */
149 Iterator begin(); 149 Iterator begin();
150 150
151 /** 151 /**
152 Returns a const iterator for first entry of address book. 152 Returns a const iterator for first entry of address book.
153 */ 153 */
154 ConstIterator begin() const; 154 ConstIterator begin() const;
155 155
156 /** 156 /**
157 Returns a iterator for first entry of address book. 157 Returns a iterator for first entry of address book.
158 */ 158 */
159 Iterator end(); 159 Iterator end();
160 160
161 /** 161 /**
162 Returns a const iterator for first entry of address book. 162 Returns a const iterator for first entry of address book.
163 */ 163 */
164 ConstIterator end() const; 164 ConstIterator end() const;
165 165
166 /** 166 /**
167 Removes all entries from address book. 167 Removes all entries from address book.
168 */ 168 */
169 void clear(); 169 void clear();
170 170
171 /** 171 /**
172 Insert an Addressee object into address book. If an object with the same 172 Insert an Addressee object into address book. If an object with the same
173 unique id already exists in the address book it it replaced by the new 173 unique id already exists in the address book it it replaced by the new
174 one. If not the new object is appended to the address book. 174 one. If not the new object is appended to the address book.
175 */ 175 */
176 void insertAddressee( const Addressee &, bool setRev = true ); 176 void insertAddressee( const Addressee &, bool setRev = true );
177 177
178 /** 178 /**
179 Removes entry from the address book. 179 Removes entry from the address book.
180 */ 180 */
181 void removeAddressee( const Addressee & ); 181 void removeAddressee( const Addressee & );
182 182
183 /** 183 /**
184 This is like @ref removeAddressee() just above, with the difference that 184 This is like @ref removeAddressee() just above, with the difference that
185 the first element is a iterator, returned by @ref begin(). 185 the first element is a iterator, returned by @ref begin().
186 */ 186 */
187 void removeAddressee( const Iterator & ); 187 void removeAddressee( const Iterator & );
188 188
189 /** 189 /**
190 Find the specified entry in address book. Returns end(), if the entry 190 Find the specified entry in address book. Returns end(), if the entry
191 couldn't be found. 191 couldn't be found.
192 */ 192 */
193 Iterator find( const Addressee & ); 193 Iterator find( const Addressee & );
194 194
195 /** 195 /**
196 Find the entry specified by an unique id. Returns an empty Addressee 196 Find the entry specified by an unique id. Returns an empty Addressee
197 object, if the address book does not contain an entry with this id. 197 object, if the address book does not contain an entry with this id.
198 */ 198 */
199 Addressee findByUid( const QString & ); 199 Addressee findByUid( const QString & );
200 200
201 201
202 /** 202 /**
203 Returns a list of all addressees in the address book. This list can 203 Returns a list of all addressees in the address book. This list can
204 be sorted with @ref KABC::AddresseeList for example. 204 be sorted with @ref KABC::AddresseeList for example.
205 */ 205 */
206 Addressee::List allAddressees(); 206 Addressee::List allAddressees();
207 207
208 /** 208 /**
209 Find all entries with the specified name in the address book. Returns 209 Find all entries with the specified name in the address book. Returns
210 an empty list, if no entries could be found. 210 an empty list, if no entries could be found.
211 */ 211 */
212 Addressee::List findByName( const QString & ); 212 Addressee::List findByName( const QString & );
213 213
214 /** 214 /**
215 Find all entries with the specified email address in the address book. 215 Find all entries with the specified email address in the address book.
216 Returns an empty list, if no entries could be found. 216 Returns an empty list, if no entries could be found.
217 */ 217 */
218 Addressee::List findByEmail( const QString & ); 218 Addressee::List findByEmail( const QString & );
219 219
220 /** 220 /**
221 Find all entries wich have the specified category in the address book. 221 Find all entries wich have the specified category in the address book.
222 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
223 */ 223 */
224 Addressee::List findByCategory( const QString & ); 224 Addressee::List findByCategory( const QString & );
225 225
226 /** 226 /**
227 Return a string identifying this addressbook. 227 Return a string identifying this addressbook.
228 */ 228 */
229 virtual QString identifier(); 229 virtual QString identifier();
230 230
231 /** 231 /**
232 Used for debug output. 232 Used for debug output.
233 */ 233 */
234 void dump() const; 234 void dump() const;
235 235
236 void emitAddressBookLocked() { emit addressBookLocked( this ); } 236 void emitAddressBookLocked() { emit addressBookLocked( this ); }
237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
238 void emitAddressBookChanged() { emit addressBookChanged( this ); } 238 void emitAddressBookChanged() { emit addressBookChanged( this ); }
239 239
240 /** 240 /**
241 Return list of all Fields known to the address book which are associated 241 Return list of all Fields known to the address book which are associated
242 with the given field category. 242 with the given field category.
243 */ 243 */
244 Field::List fields( int category = Field::All ); 244 Field::List fields( int category = Field::All );
245 245
246 /** 246 /**
247 Add custom field to address book. 247 Add custom field to address book.
248 248
249 @param label User visible label of the field. 249 @param label User visible label of the field.
250 @param category Ored list of field categories. 250 @param category Ored list of field categories.
251 @param key Identifier used as key for reading and writing the field. 251 @param key Identifier used as key for reading and writing the field.
252 @param app String used as application key for reading and writing 252 @param app String used as application key for reading and writing
253 the field. 253 the field.
254 */ 254 */
255 bool addCustomField( const QString &label, int category = Field::All, 255 bool addCustomField( const QString &label, int category = Field::All,
256 const QString &key = QString::null, 256 const QString &key = QString::null,
257 const QString &app = QString::null ); 257 const QString &app = QString::null );
258 258
259 259
260 /** 260 /**
261 Add address book resource. 261 Add address book resource.
262 */ 262 */
263 bool addResource( Resource * ); 263 bool addResource( Resource * );
264 264
265 /** 265 /**
266 Remove address book resource. 266 Remove address book resource.
267 */ 267 */
268 bool removeResource( Resource * ); 268 bool removeResource( Resource * );
269 269
270 /** 270 /**
271 Return pointer list of all resources. 271 Return pointer list of all resources.
272 */ 272 */
273 QPtrList<Resource> resources(); 273 QPtrList<Resource> resources();
274 274
275 /** 275 /**
276 Set the @p ErrorHandler, that is used by @ref error() to 276 Set the @p ErrorHandler, that is used by @ref error() to
277 provide gui-independend error messages. 277 provide gui-independend error messages.
278 */ 278 */
279 void setErrorHandler( ErrorHandler * ); 279 void setErrorHandler( ErrorHandler * );
280 280
281 /** 281 /**
282 Shows gui independend error messages. 282 Shows gui independend error messages.
283 */ 283 */
284 void error( const QString& ); 284 void error( const QString& );
285 285
286 /** 286 /**
287 Query all resources to clean up their lock files 287 Query all resources to clean up their lock files
288 */ 288 */
289 void cleanUp(); 289 void cleanUp();
290 290
291 // sync stuff 291 // sync stuff
292 //Addressee::List getExternLastSyncAddressees(); 292 //Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat(); 293 void resetTempSyncStat();
294 QStringList uidList(); 294 QStringList uidList();
295 void removeDeletedAddressees(); 295 void removeDeletedAddressees();
296 296 void mergeAB( AddressBook *aBook, const QString& profile );
297 297 Addressee findByExternUid( const QString& uid , const QString& profile );
298 signals: 298 signals:
299 /** 299 /**
300 Emitted, when the address book has changed on disk. 300 Emitted, when the address book has changed on disk.
301 */ 301 */
302 void addressBookChanged( AddressBook * ); 302 void addressBookChanged( AddressBook * );
303 303
304 /** 304 /**
305 Emitted, when the address book has been locked for writing. 305 Emitted, when the address book has been locked for writing.
306 */ 306 */
307 void addressBookLocked( AddressBook * ); 307 void addressBookLocked( AddressBook * );
308 308
309 /** 309 /**
310 Emitted, when the address book has been unlocked. 310 Emitted, when the address book has been unlocked.
311 */ 311 */
312 void addressBookUnlocked( AddressBook * ); 312 void addressBookUnlocked( AddressBook * );
313 313
314 protected: 314 protected:
315 void deleteRemovedAddressees(); 315 void deleteRemovedAddressees();
316 void setStandardResource( Resource * ); 316 void setStandardResource( Resource * );
317 Resource *standardResource(); 317 Resource *standardResource();
318 KRES::Manager<Resource> *resourceManager(); 318 KRES::Manager<Resource> *resourceManager();
319 319
320 void init(const QString &config, const QString &family); 320 void init(const QString &config, const QString &family);
321 321
322 private: 322 private:
323//US QPtrList<Resource> mDummy; // Remove in KDE 4 323//US QPtrList<Resource> mDummy; // Remove in KDE 4
324 324
325 325
326 struct AddressBookData; 326 struct AddressBookData;
327 AddressBookData *d; 327 AddressBookData *d;
328 bool blockLSEchange; 328 bool blockLSEchange;
329}; 329};
330 330
331QDataStream &operator<<( QDataStream &, const AddressBook & ); 331QDataStream &operator<<( QDataStream &, const AddressBook & );
332QDataStream &operator>>( QDataStream &, AddressBook & ); 332QDataStream &operator>>( QDataStream &, AddressBook & );
333 333
334} 334}
335 335
336#endif 336#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index c34f671..711c261 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,581 +1,620 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 QString externalUID;
69 KURL url; 70 KURL url;
70 Secrecy secrecy; 71 Secrecy secrecy;
71 Picture logo; 72 Picture logo;
72 Picture photo; 73 Picture photo;
73 Sound sound; 74 Sound sound;
74 Agent agent; 75 Agent agent;
75 QString mExternalId; 76 QString mExternalId;
76 PhoneNumber::List phoneNumbers; 77 PhoneNumber::List phoneNumbers;
77 Address::List addresses; 78 Address::List addresses;
78 Key::List keys; 79 Key::List keys;
79 QStringList emails; 80 QStringList emails;
80 QStringList categories; 81 QStringList categories;
81 QStringList custom; 82 QStringList custom;
82 int mTempSyncStat; 83 int mTempSyncStat;
83 Resource *resource; 84 Resource *resource;
84 85
85 bool empty :1; 86 bool empty :1;
86 bool changed :1; 87 bool changed :1;
87}; 88};
88 89
89Addressee::Addressee() 90Addressee::Addressee()
90{ 91{
91 mData = new AddresseeData; 92 mData = new AddresseeData;
92 mData->empty = true; 93 mData->empty = true;
93 mData->changed = false; 94 mData->changed = false;
94 mData->resource = 0; 95 mData->resource = 0;
95 mData->mExternalId = ":"; 96 mData->mExternalId = ":";
96 mData->revision = QDateTime ( QDate( 2004,1,1)); 97 mData->revision = QDateTime ( QDate( 2004,1,1));
97 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 98 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
98} 99}
99 100
100Addressee::~Addressee() 101Addressee::~Addressee()
101{ 102{
102} 103}
103 104
104Addressee::Addressee( const Addressee &a ) 105Addressee::Addressee( const Addressee &a )
105{ 106{
106 mData = a.mData; 107 mData = a.mData;
107} 108}
108 109
109Addressee &Addressee::operator=( const Addressee &a ) 110Addressee &Addressee::operator=( const Addressee &a )
110{ 111{
111 mData = a.mData; 112 mData = a.mData;
112 return (*this); 113 return (*this);
113} 114}
114 115
115Addressee Addressee::copy() 116Addressee Addressee::copy()
116{ 117{
117 Addressee a; 118 Addressee a;
118 *(a.mData) = *mData; 119 *(a.mData) = *mData;
119 return a; 120 return a;
120} 121}
121 122
122void Addressee::detach() 123void Addressee::detach()
123{ 124{
124 if ( mData.count() == 1 ) return; 125 if ( mData.count() == 1 ) return;
125 *this = copy(); 126 *this = copy();
126} 127}
127 128
128bool Addressee::operator==( const Addressee &a ) const 129bool Addressee::operator==( const Addressee &a ) const
129{ 130{
130 if ( uid() != a.uid() ) return false; 131 if ( uid() != a.uid() ) return false;
131 if ( mData->name != a.mData->name ) return false; 132 if ( mData->name != a.mData->name ) return false;
132 if ( mData->formattedName != a.mData->formattedName ) return false; 133 if ( mData->formattedName != a.mData->formattedName ) return false;
133 if ( mData->familyName != a.mData->familyName ) return false; 134 if ( mData->familyName != a.mData->familyName ) return false;
134 if ( mData->givenName != a.mData->givenName ) return false; 135 if ( mData->givenName != a.mData->givenName ) return false;
135 if ( mData->additionalName != a.mData->additionalName ) return false; 136 if ( mData->additionalName != a.mData->additionalName ) return false;
136 if ( mData->prefix != a.mData->prefix ) return false; 137 if ( mData->prefix != a.mData->prefix ) return false;
137 if ( mData->suffix != a.mData->suffix ) return false; 138 if ( mData->suffix != a.mData->suffix ) return false;
138 if ( mData->nickName != a.mData->nickName ) return false; 139 if ( mData->nickName != a.mData->nickName ) return false;
139 if ( mData->birthday != a.mData->birthday ) return false; 140 if ( mData->birthday != a.mData->birthday ) return false;
140 if ( mData->mailer != a.mData->mailer ) return false; 141 if ( mData->mailer != a.mData->mailer ) return false;
141 if ( mData->timeZone != a.mData->timeZone ) return false; 142 if ( mData->timeZone != a.mData->timeZone ) return false;
142 if ( mData->geo != a.mData->geo ) return false; 143 if ( mData->geo != a.mData->geo ) return false;
143 if ( mData->title != a.mData->title ) return false; 144 if ( mData->title != a.mData->title ) return false;
144 if ( mData->role != a.mData->role ) return false; 145 if ( mData->role != a.mData->role ) return false;
145 if ( mData->organization != a.mData->organization ) return false; 146 if ( mData->organization != a.mData->organization ) return false;
146 if ( mData->note != a.mData->note ) return false; 147 if ( mData->note != a.mData->note ) return false;
147 if ( mData->productId != a.mData->productId ) return false; 148 if ( mData->productId != a.mData->productId ) return false;
148 if ( mData->revision != a.mData->revision ) return false; 149 if ( mData->revision != a.mData->revision ) return false;
149 if ( mData->sortString != a.mData->sortString ) return false; 150 if ( mData->sortString != a.mData->sortString ) return false;
150 if ( mData->secrecy != a.mData->secrecy ) return false; 151 if ( mData->secrecy != a.mData->secrecy ) return false;
151 if ( mData->logo != a.mData->logo ) return false; 152 if ( mData->logo != a.mData->logo ) return false;
152 if ( mData->photo != a.mData->photo ) return false; 153 if ( mData->photo != a.mData->photo ) return false;
153 if ( mData->sound != a.mData->sound ) return false; 154 if ( mData->sound != a.mData->sound ) return false;
154 if ( mData->agent != a.mData->agent ) return false; 155 if ( mData->agent != a.mData->agent ) return false;
155 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 156 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
156 ( mData->url != a.mData->url ) ) return false; 157 ( mData->url != a.mData->url ) ) return false;
157 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 158 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
158 if ( mData->addresses != a.mData->addresses ) return false; 159 if ( mData->addresses != a.mData->addresses ) return false;
159 if ( mData->keys != a.mData->keys ) return false; 160 if ( mData->keys != a.mData->keys ) return false;
160 if ( mData->emails != a.mData->emails ) return false; 161 if ( mData->emails != a.mData->emails ) return false;
161 if ( mData->categories != a.mData->categories ) return false; 162 if ( mData->categories != a.mData->categories ) return false;
162 if ( mData->custom != a.mData->custom ) return false; 163 if ( mData->custom != a.mData->custom ) return false;
163 164
164 return true; 165 return true;
165} 166}
166 167
167bool Addressee::operator!=( const Addressee &a ) const 168bool Addressee::operator!=( const Addressee &a ) const
168{ 169{
169 return !( a == *this ); 170 return !( a == *this );
170} 171}
171 172
172bool Addressee::isEmpty() const 173bool Addressee::isEmpty() const
173{ 174{
174 return mData->empty; 175 return mData->empty;
175} 176}
176ulong Addressee::getCsum4List( const QStringList & attList) 177ulong Addressee::getCsum4List( const QStringList & attList)
177{ 178{
178 int max = attList.count(); 179 int max = attList.count();
179 ulong cSum = 0; 180 ulong cSum = 0;
180 int j,k,i; 181 int j,k,i;
181 int add; 182 int add;
182 for ( i = 0; i < max ; ++i ) { 183 for ( i = 0; i < max ; ++i ) {
183 QString s = attList[i]; 184 QString s = attList[i];
184 if ( ! s.isEmpty() ){ 185 if ( ! s.isEmpty() ){
185 j = s.length(); 186 j = s.length();
186 for ( k = 0; k < j; ++k ) { 187 for ( k = 0; k < j; ++k ) {
187 int mul = k +1; 188 int mul = k +1;
188 add = s[k].unicode (); 189 add = s[k].unicode ();
189 if ( k < 16 ) 190 if ( k < 16 )
190 mul = mul * mul; 191 mul = mul * mul;
191 int ii = i+1; 192 int ii = i+1;
192 add = add * mul *ii*ii*ii; 193 add = add * mul *ii*ii*ii;
193 cSum += add; 194 cSum += add;
194 } 195 }
195 } 196 }
196 197
197 } 198 }
198 //QString dump = attList.join(","); 199 //QString dump = attList.join(",");
199 //qDebug("csum: %d %s", cSum,dump.latin1()); 200 //qDebug("csum: %d %s", cSum,dump.latin1());
200 201
201 return cSum; 202 return cSum;
202 203
203} 204}
204void Addressee::computeCsum(const QString &dev) 205void Addressee::computeCsum(const QString &dev)
205{ 206{
206 QStringList l; 207 QStringList l;
207 if ( !mData->name.isEmpty() ) l.append(mData->name); 208 if ( !mData->name.isEmpty() ) l.append(mData->name);
208 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 209 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
209 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 210 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
210 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 211 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
211 if ( !mData->additionalName ) l.append( mData->additionalName ); 212 if ( !mData->additionalName ) l.append( mData->additionalName );
212 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 213 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
213 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 214 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
214 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 215 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
215 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 216 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
216 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 217 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
217 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 218 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
218 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 219 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
219 if ( !mData->title .isEmpty() ) l.append( mData->title ); 220 if ( !mData->title .isEmpty() ) l.append( mData->title );
220 if ( !mData->role.isEmpty() ) l.append( mData->role ); 221 if ( !mData->role.isEmpty() ) l.append( mData->role );
221 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 222 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
222 if ( !mData->note.isEmpty() ) l.append( mData->note ); 223 if ( !mData->note.isEmpty() ) l.append( mData->note );
223 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 224 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
224 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 225 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
225 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 226 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
226 // if ( !mData->logo.isEmpty() ) l.append( ); 227 // if ( !mData->logo.isEmpty() ) l.append( );
227 //if ( !mData->photo.isEmpty() ) l.append( ); 228 //if ( !mData->photo.isEmpty() ) l.append( );
228 //if ( !mData->sound.isEmpty() ) l.append( ); 229 //if ( !mData->sound.isEmpty() ) l.append( );
229 //if ( !mData->agent.isEmpty() ) l.append( ); 230 //if ( !mData->agent.isEmpty() ) l.append( );
230 //if ( mData->url.isValid() ) l.append( ); 231 //if ( mData->url.isValid() ) l.append( );
231#if 0 232#if 0
232 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 233 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
233 if ( !mData->addresses.isEmpty() ) l.append( ); 234 if ( !mData->addresses.isEmpty() ) l.append( );
234 //if ( !mData->keys.isEmpty() ) l.append( ); 235 //if ( !mData->keys.isEmpty() ) l.append( );
235 if ( !mData->emails.isEmpty() ) l.append( ); 236 if ( !mData->emails.isEmpty() ) l.append( );
236 if ( !mData->categories .isEmpty() ) l.append( ); 237 if ( !mData->categories .isEmpty() ) l.append( );
237 if ( !mData->custom.isEmpty() ) l.append( ); 238 if ( !mData->custom.isEmpty() ) l.append( );
238#endif 239#endif
239 KABC::PhoneNumber::List phoneNumbers; 240 KABC::PhoneNumber::List phoneNumbers;
240 KABC::PhoneNumber::List::Iterator phoneIter; 241 KABC::PhoneNumber::List::Iterator phoneIter;
241 242
242 QStringList t; 243 QStringList t;
243 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 244 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
244 ++phoneIter ) 245 ++phoneIter )
245 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 246 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
246 t.sort(); 247 t.sort();
247 uint iii; 248 uint iii;
248 for ( iii = 0; iii < t.count(); ++iii) 249 for ( iii = 0; iii < t.count(); ++iii)
249 l.append( t[iii] ); 250 l.append( t[iii] );
250 t = mData->emails; 251 t = mData->emails;
251 t.sort(); 252 t.sort();
252 for ( iii = 0; iii < t.count(); ++iii) 253 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 254 l.append( t[iii] );
254 t = mData->categories; 255 t = mData->categories;
255 t.sort(); 256 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 257 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 258 l.append( t[iii] );
258 t = mData->custom; 259 t = mData->custom;
259 t.sort(); 260 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 261 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 262 l.append( t[iii] );
262 KABC::Address::List::Iterator addressIter; 263 KABC::Address::List::Iterator addressIter;
263 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 264 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
264 ++addressIter ) { 265 ++addressIter ) {
265 t = (*addressIter).asList(); 266 t = (*addressIter).asList();
266 t.sort(); 267 t.sort();
267 for ( iii = 0; iii < t.count(); ++iii) 268 for ( iii = 0; iii < t.count(); ++iii)
268 l.append( t[iii] ); 269 l.append( t[iii] );
269 } 270 }
270 uint cs = getCsum4List(l); 271 uint cs = getCsum4List(l);
271 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 272 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
272 setCsum( dev, QString::number (cs )); 273 setCsum( dev, QString::number (cs ));
273} 274}
275
276void Addressee::mergeContact( Addressee ad )
277{
278#if 0
279 if ( !mData->name.isEmpty() ) l.append(mData->name);
280 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
281 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
282 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
283 if ( !mData->additionalName ) l.append( mData->additionalName );
284 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
285 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
286 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
287 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
288 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
289 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
290 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
291 if ( !mData->title .isEmpty() ) l.append( mData->title );
292 if ( !mData->role.isEmpty() ) l.append( mData->role );
293 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
294 if ( !mData->note.isEmpty() ) l.append( mData->note );
295 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
296 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
297 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
298#endif
299}
300
274void Addressee::removeID(const QString &prof) 301void Addressee::removeID(const QString &prof)
275{ 302{
276 detach(); 303 detach();
277 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 304 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
278 305
279} 306}
280void Addressee::setID( const QString & prof , const QString & id ) 307void Addressee::setID( const QString & prof , const QString & id )
281{ 308{
282 detach(); 309 detach();
283 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 310 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
284 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 311 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
285} 312}
286void Addressee::setTempSyncStat( int id ) 313void Addressee::setTempSyncStat( int id )
287{ 314{
288 if ( mData->mTempSyncStat == id ) return; 315 if ( mData->mTempSyncStat == id ) return;
289 detach(); 316 detach();
290 mData->mTempSyncStat = id; 317 mData->mTempSyncStat = id;
291} 318}
292int Addressee::tempSyncStat() const 319int Addressee::tempSyncStat() const
293{ 320{
294 return mData->mTempSyncStat; 321 return mData->mTempSyncStat;
295} 322}
296 323
297QString Addressee::getID( const QString & prof) 324QString Addressee::getID( const QString & prof)
298{ 325{
299 return KIdManager::getId ( mData->mExternalId, prof ); 326 return KIdManager::getId ( mData->mExternalId, prof );
300} 327}
301 328
302void Addressee::setCsum( const QString & prof , const QString & id ) 329void Addressee::setCsum( const QString & prof , const QString & id )
303{ 330{
304 detach(); 331 detach();
305 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 332 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
306 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 333 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
307 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 334 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
308} 335}
309 336
310QString Addressee::getCsum( const QString & prof) 337QString Addressee::getCsum( const QString & prof)
311{ 338{
312 return KIdManager::getCsum ( mData->mExternalId, prof ); 339 return KIdManager::getCsum ( mData->mExternalId, prof );
313} 340}
314 341
315void Addressee::setIDStr( const QString & s ) 342void Addressee::setIDStr( const QString & s )
316{ 343{
317 detach(); 344 detach();
318 mData->mExternalId = s; 345 mData->mExternalId = s;
319} 346}
320 347
321QString Addressee::IDStr() const 348QString Addressee::IDStr() const
322{ 349{
323 return mData->mExternalId; 350 return mData->mExternalId;
324} 351}
325 352
353void Addressee::setExternalUID( const QString &id )
354{
355 if ( id == mData->externalUID ) return;
356 detach();
357 mData->empty = false;
358 mData->externalUID = id;
359}
360
361QString Addressee::externalUID() const
362{
363 return mData->externalUID;
364}
326 365
327void Addressee::setUid( const QString &id ) 366void Addressee::setUid( const QString &id )
328{ 367{
329 if ( id == mData->uid ) return; 368 if ( id == mData->uid ) return;
330 detach(); 369 detach();
331 mData->empty = false; 370 mData->empty = false;
332 mData->uid = id; 371 mData->uid = id;
333} 372}
334 373
335QString Addressee::uid() const 374QString Addressee::uid() const
336{ 375{
337 if ( mData->uid.isEmpty() ) 376 if ( mData->uid.isEmpty() )
338 mData->uid = KApplication::randomString( 10 ); 377 mData->uid = KApplication::randomString( 10 );
339 378
340 return mData->uid; 379 return mData->uid;
341} 380}
342 381
343QString Addressee::uidLabel() 382QString Addressee::uidLabel()
344{ 383{
345 return i18n("Unique Identifier"); 384 return i18n("Unique Identifier");
346} 385}
347 386
348void Addressee::setName( const QString &name ) 387void Addressee::setName( const QString &name )
349{ 388{
350 if ( name == mData->name ) return; 389 if ( name == mData->name ) return;
351 detach(); 390 detach();
352 mData->empty = false; 391 mData->empty = false;
353 mData->name = name; 392 mData->name = name;
354} 393}
355 394
356QString Addressee::name() const 395QString Addressee::name() const
357{ 396{
358 return mData->name; 397 return mData->name;
359} 398}
360 399
361QString Addressee::nameLabel() 400QString Addressee::nameLabel()
362{ 401{
363 return i18n("Name"); 402 return i18n("Name");
364} 403}
365 404
366 405
367void Addressee::setFormattedName( const QString &formattedName ) 406void Addressee::setFormattedName( const QString &formattedName )
368{ 407{
369 if ( formattedName == mData->formattedName ) return; 408 if ( formattedName == mData->formattedName ) return;
370 detach(); 409 detach();
371 mData->empty = false; 410 mData->empty = false;
372 mData->formattedName = formattedName; 411 mData->formattedName = formattedName;
373} 412}
374 413
375QString Addressee::formattedName() const 414QString Addressee::formattedName() const
376{ 415{
377 return mData->formattedName; 416 return mData->formattedName;
378} 417}
379 418
380QString Addressee::formattedNameLabel() 419QString Addressee::formattedNameLabel()
381{ 420{
382 return i18n("Formatted Name"); 421 return i18n("Formatted Name");
383} 422}
384 423
385 424
386void Addressee::setFamilyName( const QString &familyName ) 425void Addressee::setFamilyName( const QString &familyName )
387{ 426{
388 if ( familyName == mData->familyName ) return; 427 if ( familyName == mData->familyName ) return;
389 detach(); 428 detach();
390 mData->empty = false; 429 mData->empty = false;
391 mData->familyName = familyName; 430 mData->familyName = familyName;
392} 431}
393 432
394QString Addressee::familyName() const 433QString Addressee::familyName() const
395{ 434{
396 return mData->familyName; 435 return mData->familyName;
397} 436}
398 437
399QString Addressee::familyNameLabel() 438QString Addressee::familyNameLabel()
400{ 439{
401 return i18n("Family Name"); 440 return i18n("Family Name");
402} 441}
403 442
404 443
405void Addressee::setGivenName( const QString &givenName ) 444void Addressee::setGivenName( const QString &givenName )
406{ 445{
407 if ( givenName == mData->givenName ) return; 446 if ( givenName == mData->givenName ) return;
408 detach(); 447 detach();
409 mData->empty = false; 448 mData->empty = false;
410 mData->givenName = givenName; 449 mData->givenName = givenName;
411} 450}
412 451
413QString Addressee::givenName() const 452QString Addressee::givenName() const
414{ 453{
415 return mData->givenName; 454 return mData->givenName;
416} 455}
417 456
418QString Addressee::givenNameLabel() 457QString Addressee::givenNameLabel()
419{ 458{
420 return i18n("Given Name"); 459 return i18n("Given Name");
421} 460}
422 461
423 462
424void Addressee::setAdditionalName( const QString &additionalName ) 463void Addressee::setAdditionalName( const QString &additionalName )
425{ 464{
426 if ( additionalName == mData->additionalName ) return; 465 if ( additionalName == mData->additionalName ) return;
427 detach(); 466 detach();
428 mData->empty = false; 467 mData->empty = false;
429 mData->additionalName = additionalName; 468 mData->additionalName = additionalName;
430} 469}
431 470
432QString Addressee::additionalName() const 471QString Addressee::additionalName() const
433{ 472{
434 return mData->additionalName; 473 return mData->additionalName;
435} 474}
436 475
437QString Addressee::additionalNameLabel() 476QString Addressee::additionalNameLabel()
438{ 477{
439 return i18n("Additional Names"); 478 return i18n("Additional Names");
440} 479}
441 480
442 481
443void Addressee::setPrefix( const QString &prefix ) 482void Addressee::setPrefix( const QString &prefix )
444{ 483{
445 if ( prefix == mData->prefix ) return; 484 if ( prefix == mData->prefix ) return;
446 detach(); 485 detach();
447 mData->empty = false; 486 mData->empty = false;
448 mData->prefix = prefix; 487 mData->prefix = prefix;
449} 488}
450 489
451QString Addressee::prefix() const 490QString Addressee::prefix() const
452{ 491{
453 return mData->prefix; 492 return mData->prefix;
454} 493}
455 494
456QString Addressee::prefixLabel() 495QString Addressee::prefixLabel()
457{ 496{
458 return i18n("Honorific Prefixes"); 497 return i18n("Honorific Prefixes");
459} 498}
460 499
461 500
462void Addressee::setSuffix( const QString &suffix ) 501void Addressee::setSuffix( const QString &suffix )
463{ 502{
464 if ( suffix == mData->suffix ) return; 503 if ( suffix == mData->suffix ) return;
465 detach(); 504 detach();
466 mData->empty = false; 505 mData->empty = false;
467 mData->suffix = suffix; 506 mData->suffix = suffix;
468} 507}
469 508
470QString Addressee::suffix() const 509QString Addressee::suffix() const
471{ 510{
472 return mData->suffix; 511 return mData->suffix;
473} 512}
474 513
475QString Addressee::suffixLabel() 514QString Addressee::suffixLabel()
476{ 515{
477 return i18n("Honorific Suffixes"); 516 return i18n("Honorific Suffixes");
478} 517}
479 518
480 519
481void Addressee::setNickName( const QString &nickName ) 520void Addressee::setNickName( const QString &nickName )
482{ 521{
483 if ( nickName == mData->nickName ) return; 522 if ( nickName == mData->nickName ) return;
484 detach(); 523 detach();
485 mData->empty = false; 524 mData->empty = false;
486 mData->nickName = nickName; 525 mData->nickName = nickName;
487} 526}
488 527
489QString Addressee::nickName() const 528QString Addressee::nickName() const
490{ 529{
491 return mData->nickName; 530 return mData->nickName;
492} 531}
493 532
494QString Addressee::nickNameLabel() 533QString Addressee::nickNameLabel()
495{ 534{
496 return i18n("Nick Name"); 535 return i18n("Nick Name");
497} 536}
498 537
499 538
500void Addressee::setBirthday( const QDateTime &birthday ) 539void Addressee::setBirthday( const QDateTime &birthday )
501{ 540{
502 if ( birthday == mData->birthday ) return; 541 if ( birthday == mData->birthday ) return;
503 detach(); 542 detach();
504 mData->empty = false; 543 mData->empty = false;
505 mData->birthday = birthday; 544 mData->birthday = birthday;
506} 545}
507 546
508QDateTime Addressee::birthday() const 547QDateTime Addressee::birthday() const
509{ 548{
510 return mData->birthday; 549 return mData->birthday;
511} 550}
512 551
513QString Addressee::birthdayLabel() 552QString Addressee::birthdayLabel()
514{ 553{
515 return i18n("Birthday"); 554 return i18n("Birthday");
516} 555}
517 556
518 557
519QString Addressee::homeAddressStreetLabel() 558QString Addressee::homeAddressStreetLabel()
520{ 559{
521 return i18n("Home Address Street"); 560 return i18n("Home Address Street");
522} 561}
523 562
524 563
525QString Addressee::homeAddressLocalityLabel() 564QString Addressee::homeAddressLocalityLabel()
526{ 565{
527 return i18n("Home Address Locality"); 566 return i18n("Home Address Locality");
528} 567}
529 568
530 569
531QString Addressee::homeAddressRegionLabel() 570QString Addressee::homeAddressRegionLabel()
532{ 571{
533 return i18n("Home Address Region"); 572 return i18n("Home Address Region");
534} 573}
535 574
536 575
537QString Addressee::homeAddressPostalCodeLabel() 576QString Addressee::homeAddressPostalCodeLabel()
538{ 577{
539 return i18n("Home Address Postal Code"); 578 return i18n("Home Address Postal Code");
540} 579}
541 580
542 581
543QString Addressee::homeAddressCountryLabel() 582QString Addressee::homeAddressCountryLabel()
544{ 583{
545 return i18n("Home Address Country"); 584 return i18n("Home Address Country");
546} 585}
547 586
548 587
549QString Addressee::homeAddressLabelLabel() 588QString Addressee::homeAddressLabelLabel()
550{ 589{
551 return i18n("Home Address Label"); 590 return i18n("Home Address Label");
552} 591}
553 592
554 593
555QString Addressee::businessAddressStreetLabel() 594QString Addressee::businessAddressStreetLabel()
556{ 595{
557 return i18n("Business Address Street"); 596 return i18n("Business Address Street");
558} 597}
559 598
560 599
561QString Addressee::businessAddressLocalityLabel() 600QString Addressee::businessAddressLocalityLabel()
562{ 601{
563 return i18n("Business Address Locality"); 602 return i18n("Business Address Locality");
564} 603}
565 604
566 605
567QString Addressee::businessAddressRegionLabel() 606QString Addressee::businessAddressRegionLabel()
568{ 607{
569 return i18n("Business Address Region"); 608 return i18n("Business Address Region");
570} 609}
571 610
572 611
573QString Addressee::businessAddressPostalCodeLabel() 612QString Addressee::businessAddressPostalCodeLabel()
574{ 613{
575 return i18n("Business Address Postal Code"); 614 return i18n("Business Address Postal Code");
576} 615}
577 616
578 617
579QString Addressee::businessAddressCountryLabel() 618QString Addressee::businessAddressCountryLabel()
580{ 619{
581 return i18n("Business Address Country"); 620 return i18n("Business Address Country");
diff --git a/kabc/addressee.h b/kabc/addressee.h
index bfb0840..59fcbd8 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,371 +1,373 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 115 void setExternalUID( const QString &id );
116 QString externalUID() const;
117 void mergeContact( Addressee ad );
116 /** 118 /**
117 Set unique identifier. 119 Set unique identifier.
118 */ 120 */
119 void setUid( const QString &uid ); 121 void setUid( const QString &uid );
120 /** 122 /**
121 Return unique identifier. 123 Return unique identifier.
122 */ 124 */
123 QString uid() const; 125 QString uid() const;
124 /** 126 /**
125 Return translated label for uid field. 127 Return translated label for uid field.
126 */ 128 */
127 static QString uidLabel(); 129 static QString uidLabel();
128 130
129 /** 131 /**
130 Set name. 132 Set name.
131 */ 133 */
132 void setName( const QString &name ); 134 void setName( const QString &name );
133 /** 135 /**
134 Return name. 136 Return name.
135 */ 137 */
136 QString name() const; 138 QString name() const;
137 /** 139 /**
138 Return translated label for name field. 140 Return translated label for name field.
139 */ 141 */
140 static QString nameLabel(); 142 static QString nameLabel();
141 143
142 /** 144 /**
143 Set formatted name. 145 Set formatted name.
144 */ 146 */
145 void setFormattedName( const QString &formattedName ); 147 void setFormattedName( const QString &formattedName );
146 /** 148 /**
147 Return formatted name. 149 Return formatted name.
148 */ 150 */
149 QString formattedName() const; 151 QString formattedName() const;
150 /** 152 /**
151 Return translated label for formattedName field. 153 Return translated label for formattedName field.
152 */ 154 */
153 static QString formattedNameLabel(); 155 static QString formattedNameLabel();
154 156
155 /** 157 /**
156 Set family name. 158 Set family name.
157 */ 159 */
158 void setFamilyName( const QString &familyName ); 160 void setFamilyName( const QString &familyName );
159 /** 161 /**
160 Return family name. 162 Return family name.
161 */ 163 */
162 QString familyName() const; 164 QString familyName() const;
163 /** 165 /**
164 Return translated label for familyName field. 166 Return translated label for familyName field.
165 */ 167 */
166 static QString familyNameLabel(); 168 static QString familyNameLabel();
167 169
168 /** 170 /**
169 Set given name. 171 Set given name.
170 */ 172 */
171 void setGivenName( const QString &givenName ); 173 void setGivenName( const QString &givenName );
172 /** 174 /**
173 Return given name. 175 Return given name.
174 */ 176 */
175 QString givenName() const; 177 QString givenName() const;
176 /** 178 /**
177 Return translated label for givenName field. 179 Return translated label for givenName field.
178 */ 180 */
179 static QString givenNameLabel(); 181 static QString givenNameLabel();
180 182
181 /** 183 /**
182 Set additional names. 184 Set additional names.
183 */ 185 */
184 void setAdditionalName( const QString &additionalName ); 186 void setAdditionalName( const QString &additionalName );
185 /** 187 /**
186 Return additional names. 188 Return additional names.
187 */ 189 */
188 QString additionalName() const; 190 QString additionalName() const;
189 /** 191 /**
190 Return translated label for additionalName field. 192 Return translated label for additionalName field.
191 */ 193 */
192 static QString additionalNameLabel(); 194 static QString additionalNameLabel();
193 195
194 /** 196 /**
195 Set honorific prefixes. 197 Set honorific prefixes.
196 */ 198 */
197 void setPrefix( const QString &prefix ); 199 void setPrefix( const QString &prefix );
198 /** 200 /**
199 Return honorific prefixes. 201 Return honorific prefixes.
200 */ 202 */
201 QString prefix() const; 203 QString prefix() const;
202 /** 204 /**
203 Return translated label for prefix field. 205 Return translated label for prefix field.
204 */ 206 */
205 static QString prefixLabel(); 207 static QString prefixLabel();
206 208
207 /** 209 /**
208 Set honorific suffixes. 210 Set honorific suffixes.
209 */ 211 */
210 void setSuffix( const QString &suffix ); 212 void setSuffix( const QString &suffix );
211 /** 213 /**
212 Return honorific suffixes. 214 Return honorific suffixes.
213 */ 215 */
214 QString suffix() const; 216 QString suffix() const;
215 /** 217 /**
216 Return translated label for suffix field. 218 Return translated label for suffix field.
217 */ 219 */
218 static QString suffixLabel(); 220 static QString suffixLabel();
219 221
220 /** 222 /**
221 Set nick name. 223 Set nick name.
222 */ 224 */
223 void setNickName( const QString &nickName ); 225 void setNickName( const QString &nickName );
224 /** 226 /**
225 Return nick name. 227 Return nick name.
226 */ 228 */
227 QString nickName() const; 229 QString nickName() const;
228 /** 230 /**
229 Return translated label for nickName field. 231 Return translated label for nickName field.
230 */ 232 */
231 static QString nickNameLabel(); 233 static QString nickNameLabel();
232 234
233 /** 235 /**
234 Set birthday. 236 Set birthday.
235 */ 237 */
236 void setBirthday( const QDateTime &birthday ); 238 void setBirthday( const QDateTime &birthday );
237 /** 239 /**
238 Return birthday. 240 Return birthday.
239 */ 241 */
240 QDateTime birthday() const; 242 QDateTime birthday() const;
241 /** 243 /**
242 Return translated label for birthday field. 244 Return translated label for birthday field.
243 */ 245 */
244 static QString birthdayLabel(); 246 static QString birthdayLabel();
245 247
246 /** 248 /**
247 Return translated label for homeAddressStreet field. 249 Return translated label for homeAddressStreet field.
248 */ 250 */
249 static QString homeAddressStreetLabel(); 251 static QString homeAddressStreetLabel();
250 252
251 /** 253 /**
252 Return translated label for homeAddressLocality field. 254 Return translated label for homeAddressLocality field.
253 */ 255 */
254 static QString homeAddressLocalityLabel(); 256 static QString homeAddressLocalityLabel();
255 257
256 /** 258 /**
257 Return translated label for homeAddressRegion field. 259 Return translated label for homeAddressRegion field.
258 */ 260 */
259 static QString homeAddressRegionLabel(); 261 static QString homeAddressRegionLabel();
260 262
261 /** 263 /**
262 Return translated label for homeAddressPostalCode field. 264 Return translated label for homeAddressPostalCode field.
263 */ 265 */
264 static QString homeAddressPostalCodeLabel(); 266 static QString homeAddressPostalCodeLabel();
265 267
266 /** 268 /**
267 Return translated label for homeAddressCountry field. 269 Return translated label for homeAddressCountry field.
268 */ 270 */
269 static QString homeAddressCountryLabel(); 271 static QString homeAddressCountryLabel();
270 272
271 /** 273 /**
272 Return translated label for homeAddressLabel field. 274 Return translated label for homeAddressLabel field.
273 */ 275 */
274 static QString homeAddressLabelLabel(); 276 static QString homeAddressLabelLabel();
275 277
276 /** 278 /**
277 Return translated label for businessAddressStreet field. 279 Return translated label for businessAddressStreet field.
278 */ 280 */
279 static QString businessAddressStreetLabel(); 281 static QString businessAddressStreetLabel();
280 282
281 /** 283 /**
282 Return translated label for businessAddressLocality field. 284 Return translated label for businessAddressLocality field.
283 */ 285 */
284 static QString businessAddressLocalityLabel(); 286 static QString businessAddressLocalityLabel();
285 287
286 /** 288 /**
287 Return translated label for businessAddressRegion field. 289 Return translated label for businessAddressRegion field.
288 */ 290 */
289 static QString businessAddressRegionLabel(); 291 static QString businessAddressRegionLabel();
290 292
291 /** 293 /**
292 Return translated label for businessAddressPostalCode field. 294 Return translated label for businessAddressPostalCode field.
293 */ 295 */
294 static QString businessAddressPostalCodeLabel(); 296 static QString businessAddressPostalCodeLabel();
295 297
296 /** 298 /**
297 Return translated label for businessAddressCountry field. 299 Return translated label for businessAddressCountry field.
298 */ 300 */
299 static QString businessAddressCountryLabel(); 301 static QString businessAddressCountryLabel();
300 302
301 /** 303 /**
302 Return translated label for businessAddressLabel field. 304 Return translated label for businessAddressLabel field.
303 */ 305 */
304 static QString businessAddressLabelLabel(); 306 static QString businessAddressLabelLabel();
305 307
306 /** 308 /**
307 Return translated label for homePhone field. 309 Return translated label for homePhone field.
308 */ 310 */
309 static QString homePhoneLabel(); 311 static QString homePhoneLabel();
310 312
311 /** 313 /**
312 Return translated label for businessPhone field. 314 Return translated label for businessPhone field.
313 */ 315 */
314 static QString businessPhoneLabel(); 316 static QString businessPhoneLabel();
315 317
316 /** 318 /**
317 Return translated label for mobilePhone field. 319 Return translated label for mobilePhone field.
318 */ 320 */
319 static QString mobilePhoneLabel(); 321 static QString mobilePhoneLabel();
320 322
321 /** 323 /**
322 Return translated label for homeFax field. 324 Return translated label for homeFax field.
323 */ 325 */
324 static QString homeFaxLabel(); 326 static QString homeFaxLabel();
325 327
326 /** 328 /**
327 Return translated label for businessFax field. 329 Return translated label for businessFax field.
328 */ 330 */
329 static QString businessFaxLabel(); 331 static QString businessFaxLabel();
330 332
331 /** 333 /**
332 Return translated label for carPhone field. 334 Return translated label for carPhone field.
333 */ 335 */
334 static QString carPhoneLabel(); 336 static QString carPhoneLabel();
335 337
336 /** 338 /**
337 Return translated label for isdn field. 339 Return translated label for isdn field.
338 */ 340 */
339 static QString isdnLabel(); 341 static QString isdnLabel();
340 342
341 /** 343 /**
342 Return translated label for pager field. 344 Return translated label for pager field.
343 */ 345 */
344 static QString pagerLabel(); 346 static QString pagerLabel();
345 347
346 /** 348 /**
347 Return translated label for sip field. 349 Return translated label for sip field.
348 */ 350 */
349 static QString sipLabel(); 351 static QString sipLabel();
350 352
351 /** 353 /**
352 Return translated label for email field. 354 Return translated label for email field.
353 */ 355 */
354 static QString emailLabel(); 356 static QString emailLabel();
355 357
356 /** 358 /**
357 Set mail client. 359 Set mail client.
358 */ 360 */
359 void setMailer( const QString &mailer ); 361 void setMailer( const QString &mailer );
360 /** 362 /**
361 Return mail client. 363 Return mail client.
362 */ 364 */
363 QString mailer() const; 365 QString mailer() const;
364 /** 366 /**
365 Return translated label for mailer field. 367 Return translated label for mailer field.
366 */ 368 */
367 static QString mailerLabel(); 369 static QString mailerLabel();
368 370
369 /** 371 /**
370 Set time zone. 372 Set time zone.
371 */ 373 */
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index ac513b6..7d00a3f 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -1,334 +1,341 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@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//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30 30
31 31
32#include "qtopiaconverter.h" 32#include "qtopiaconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35//US #include <qpe/categoryselect.h> 35//US #include <qpe/categoryselect.h>
36 36
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40QtopiaConverter::QtopiaConverter() : catDB(0) 40QtopiaConverter::QtopiaConverter() : catDB(0)
41{ 41{
42} 42}
43 43
44QtopiaConverter::~QtopiaConverter() 44QtopiaConverter::~QtopiaConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
49bool QtopiaConverter::init() 49bool QtopiaConverter::init()
50{ 50{
51 catDB = new Categories(); 51 catDB = new Categories();
52 52
53 if (!catDB) 53 if (!catDB)
54 return false; 54 return false;
55 55
56 catDB->load( categoryFileName() ); 56 catDB->load( categoryFileName() );
57 return true; 57 return true;
58} 58}
59 59
60void QtopiaConverter::deinit() 60void QtopiaConverter::deinit()
61{ 61{
62 if (catDB) 62 if (catDB)
63 { 63 {
64 delete catDB; 64 delete catDB;
65 catDB = 0; 65 catDB = 0;
66 } 66 }
67} 67}
68 68
69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) 69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr )
70{ 70{
71 // name 71 // name
72 addr.setFormattedName(contact.fileAs()); 72 addr.setFormattedName(contact.fileAs());
73 addr.setFamilyName( contact.lastName() ); 73 addr.setFamilyName( contact.lastName() );
74 addr.setGivenName( contact.firstName() ); 74 addr.setGivenName( contact.firstName() );
75 addr.setAdditionalName( contact.middleName() ); 75 addr.setAdditionalName( contact.middleName() );
76 addr.setPrefix( contact.nameTitle() ); 76 addr.setPrefix( contact.nameTitle() );
77 addr.setSuffix( contact.suffix() ); 77 addr.setSuffix( contact.suffix() );
78 78 QString exuid = contact.uid().toString();
79 int ente = exuid.find( "-0000");
80 if ( exuid.left(1) == "{" )
81 exuid = exuid.mid(1);
82 if ( ente > -1 )
83 exuid = exuid.left( ente-1 );
84 addr.setExternalUID( exuid );
85 //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() );
79 86
80 // email 87 // email
81 QStringList emails = contact.emailList(); 88 QStringList emails = contact.emailList();
82 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 89 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
83 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 90 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
84 } 91 }
85 92
86 if (!contact.defaultEmail().isEmpty()) 93 if (!contact.defaultEmail().isEmpty())
87 addr.insertEmail(contact.defaultEmail(), true); 94 addr.insertEmail(contact.defaultEmail(), true);
88 95
89 // home 96 // home
90 if ((!contact.homeStreet().isEmpty()) || 97 if ((!contact.homeStreet().isEmpty()) ||
91 (!contact.homeCity().isEmpty()) || 98 (!contact.homeCity().isEmpty()) ||
92 (!contact.homeState().isEmpty()) || 99 (!contact.homeState().isEmpty()) ||
93 (!contact.homeZip().isEmpty()) || 100 (!contact.homeZip().isEmpty()) ||
94 (!contact.homeCountry().isEmpty())) 101 (!contact.homeCountry().isEmpty()))
95 { 102 {
96 Address homeaddress; 103 Address homeaddress;
97 homeaddress.setType(Address::Home); 104 homeaddress.setType(Address::Home);
98//US homeaddress.setPostOfficeBox( "" ); 105//US homeaddress.setPostOfficeBox( "" );
99//US homeaddress.setExtended( "" ); 106//US homeaddress.setExtended( "" );
100 homeaddress.setStreet( contact.homeStreet() ); 107 homeaddress.setStreet( contact.homeStreet() );
101 homeaddress.setLocality( contact.homeCity() ); 108 homeaddress.setLocality( contact.homeCity() );
102 homeaddress.setRegion( contact.homeState() ); 109 homeaddress.setRegion( contact.homeState() );
103 homeaddress.setPostalCode( contact.homeZip() ); 110 homeaddress.setPostalCode( contact.homeZip() );
104 homeaddress.setCountry( contact.homeCountry() ); 111 homeaddress.setCountry( contact.homeCountry() );
105 112
106 addr.insertAddress( homeaddress ); 113 addr.insertAddress( homeaddress );
107 } 114 }
108 115
109 if (!contact.homePhone().isEmpty()) 116 if (!contact.homePhone().isEmpty())
110 { 117 {
111 PhoneNumber homephone; 118 PhoneNumber homephone;
112 homephone.setType( PhoneNumber::Home ); 119 homephone.setType( PhoneNumber::Home );
113 homephone.setNumber( contact.homePhone() ); 120 homephone.setNumber( contact.homePhone() );
114 addr.insertPhoneNumber( homephone ); 121 addr.insertPhoneNumber( homephone );
115 } 122 }
116 123
117 if (!contact.homeFax().isEmpty()) 124 if (!contact.homeFax().isEmpty())
118 { 125 {
119 PhoneNumber homefax; 126 PhoneNumber homefax;
120 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 127 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
121 homefax.setNumber( contact.homeFax() ); 128 homefax.setNumber( contact.homeFax() );
122 addr.insertPhoneNumber( homefax ); 129 addr.insertPhoneNumber( homefax );
123 } 130 }
124 131
125 if (!contact.homeMobile().isEmpty()) 132 if (!contact.homeMobile().isEmpty())
126 { 133 {
127 PhoneNumber homemobile; 134 PhoneNumber homemobile;
128 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 135 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
129 homemobile.setNumber( contact.homeMobile() ); 136 homemobile.setNumber( contact.homeMobile() );
130 addr.insertPhoneNumber( homemobile ); 137 addr.insertPhoneNumber( homemobile );
131 } 138 }
132 139
133 addr.setUrl( contact.homeWebpage() ); 140 addr.setUrl( contact.homeWebpage() );
134 141
135 142
136 // business 143 // business
137 if ((!contact.businessStreet().isEmpty()) || 144 if ((!contact.businessStreet().isEmpty()) ||
138 (!contact.businessCity().isEmpty()) || 145 (!contact.businessCity().isEmpty()) ||
139 (!contact.businessState().isEmpty()) || 146 (!contact.businessState().isEmpty()) ||
140 (!contact.businessZip().isEmpty()) || 147 (!contact.businessZip().isEmpty()) ||
141 (!contact.businessCountry().isEmpty())) 148 (!contact.businessCountry().isEmpty()))
142 { 149 {
143 Address businessaddress; 150 Address businessaddress;
144 businessaddress.setType(Address::Work); 151 businessaddress.setType(Address::Work);
145//US businessaddress.setPostOfficeBox( "" ); 152//US businessaddress.setPostOfficeBox( "" );
146//US businessaddress.setExtended( "" ); 153//US businessaddress.setExtended( "" );
147 businessaddress.setStreet( contact.businessStreet() ); 154 businessaddress.setStreet( contact.businessStreet() );
148 businessaddress.setLocality( contact.businessCity() ); 155 businessaddress.setLocality( contact.businessCity() );
149 businessaddress.setRegion( contact.businessState() ); 156 businessaddress.setRegion( contact.businessState() );
150 businessaddress.setPostalCode( contact.businessZip() ); 157 businessaddress.setPostalCode( contact.businessZip() );
151 businessaddress.setCountry( contact.businessCountry() ); 158 businessaddress.setCountry( contact.businessCountry() );
152 159
153 addr.insertAddress( businessaddress ); 160 addr.insertAddress( businessaddress );
154 } 161 }
155 162
156 163
157 if (!contact.businessPhone().isEmpty()) 164 if (!contact.businessPhone().isEmpty())
158 { 165 {
159 PhoneNumber businessphone; 166 PhoneNumber businessphone;
160 businessphone.setType( PhoneNumber::Work ); 167 businessphone.setType( PhoneNumber::Work );
161 businessphone.setNumber( contact.businessPhone() ); 168 businessphone.setNumber( contact.businessPhone() );
162 addr.insertPhoneNumber( businessphone ); 169 addr.insertPhoneNumber( businessphone );
163 } 170 }
164 171
165 if (!contact.businessFax().isEmpty()) 172 if (!contact.businessFax().isEmpty())
166 { 173 {
167 PhoneNumber businessfax; 174 PhoneNumber businessfax;
168 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 175 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
169 businessfax.setNumber( contact.businessFax() ); 176 businessfax.setNumber( contact.businessFax() );
170 addr.insertPhoneNumber( businessfax ); 177 addr.insertPhoneNumber( businessfax );
171 } 178 }
172 179
173 if (!contact.businessMobile().isEmpty()) 180 if (!contact.businessMobile().isEmpty())
174 { 181 {
175 PhoneNumber businessmobile; 182 PhoneNumber businessmobile;
176 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 183 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
177 businessmobile.setNumber( contact.businessMobile() ); 184 businessmobile.setNumber( contact.businessMobile() );
178 addr.insertPhoneNumber( businessmobile ); 185 addr.insertPhoneNumber( businessmobile );
179 } 186 }
180 187
181 if (!contact.businessPager().isEmpty()) 188 if (!contact.businessPager().isEmpty())
182 { 189 {
183 PhoneNumber businesspager; 190 PhoneNumber businesspager;
184 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 191 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
185 businesspager.setNumber( contact.businessPager() ); 192 businesspager.setNumber( contact.businessPager() );
186 addr.insertPhoneNumber( businesspager ); 193 addr.insertPhoneNumber( businesspager );
187 } 194 }
188 195
189 addr.setRole( contact.jobTitle() ); //? 196 addr.setRole( contact.jobTitle() ); //?
190 addr.setOrganization( contact.company() ); 197 addr.setOrganization( contact.company() );
191 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
192 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 199 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
193 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 200 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
194 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 201 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
195 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 202 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
196 203
197 //personal 204 //personal
198 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 205 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
199 // qtopia uses this categorization: 206 // qtopia uses this categorization:
200 // enum GenderType { UnspecifiedGender=0, Male, Female }; 207 // enum GenderType { UnspecifiedGender=0, Male, Female };
201 if (contact.gender() == PimContact::Male) 208 if (contact.gender() == PimContact::Male)
202 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 209 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
203 else if (contact.gender() == PimContact::Female) 210 else if (contact.gender() == PimContact::Female)
204 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 211 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
205 212
206 if (contact.anniversary().isValid()) { 213 if (contact.anniversary().isValid()) {
207 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 214 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
208//US 215//US
209// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); 216// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
210 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 217 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
211 } 218 }
212 219
213 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 220 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
214 if (contact.birthday().isValid()) 221 if (contact.birthday().isValid())
215 addr.setBirthday( contact.birthday() ); 222 addr.setBirthday( contact.birthday() );
216 223
217 addr.setNickName( contact.nickname() ); 224 addr.setNickName( contact.nickname() );
218 225
219 // others 226 // others
220 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 227 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
221 QString notes = contact.notes(); 228 QString notes = contact.notes();
222 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 229 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
223 230
224 addr.setNote( contact.notes() ); 231 addr.setNote( contact.notes() );
225 232
226 233
227 234
228//US QString groups() const { return find( Qtopia::Groups ); } 235//US QString groups() const { return find( Qtopia::Groups ); }
229//US QStringList groupList() const; 236//US QStringList groupList() const;
230 237
231 QArray<int> catArray = contact.categories(); 238 QArray<int> catArray = contact.categories();
232 QString cat; 239 QString cat;
233 240
234 for ( unsigned int i=0; i < catArray.size(); i++ ) { 241 for ( unsigned int i=0; i < catArray.size(); i++ ) {
235 cat = catDB->label("contact", catArray[i]); 242 cat = catDB->label("contact", catArray[i]);
236 if ( cat.isEmpty() ) 243 if ( cat.isEmpty() )
237 addr.insertCategory(QString::number(catArray[i])); 244 addr.insertCategory(QString::number(catArray[i]));
238 else 245 else
239 addr.insertCategory( cat ); 246 addr.insertCategory( cat );
240 } 247 }
241 248
242 return true; 249 return true;
243} 250}
244 251
245bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) 252bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
246{ 253{
247 // name 254 // name
248 contact.setLastName(addr.familyName()); 255 contact.setLastName(addr.familyName());
249 contact.setFirstName(addr.givenName()); 256 contact.setFirstName(addr.givenName());
250 contact.setMiddleName(addr.additionalName()); 257 contact.setMiddleName(addr.additionalName());
251 contact.setNameTitle(addr.prefix()); 258 contact.setNameTitle(addr.prefix());
252 contact.setSuffix(addr.suffix()); 259 contact.setSuffix(addr.suffix());
253 contact.setFileAs(); 260 contact.setFileAs();
254 261
255 262
256 // email 263 // email
257 QStringList emails = addr.emails(); 264 QStringList emails = addr.emails();
258 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 265 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
259 contact.insertEmail(*it); 266 contact.insertEmail(*it);
260 } 267 }
261 contact.setDefaultEmail( addr.preferredEmail() ); 268 contact.setDefaultEmail( addr.preferredEmail() );
262 269
263 270
264 // home 271 // home
265 const Address homeaddress = addr.address(Address::Home); 272 const Address homeaddress = addr.address(Address::Home);
266 if (!homeaddress.isEmpty()) { 273 if (!homeaddress.isEmpty()) {
267 contact.setHomeStreet(homeaddress.street()); 274 contact.setHomeStreet(homeaddress.street());
268 contact.setHomeCity(homeaddress.locality()); 275 contact.setHomeCity(homeaddress.locality());
269 contact.setHomeState(homeaddress.region()); 276 contact.setHomeState(homeaddress.region());
270 contact.setHomeZip(homeaddress.postalCode()); 277 contact.setHomeZip(homeaddress.postalCode());
271 contact.setHomeCountry(homeaddress.country()); 278 contact.setHomeCountry(homeaddress.country());
272 } 279 }
273 280
274 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 281 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
275 if (!homephone.number().isEmpty()) 282 if (!homephone.number().isEmpty())
276 contact.setHomePhone(homephone.number()); 283 contact.setHomePhone(homephone.number());
277 284
278 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 285 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
279 if (!homefax.number().isEmpty()) 286 if (!homefax.number().isEmpty())
280 contact.setHomeFax(homefax.number()); 287 contact.setHomeFax(homefax.number());
281 288
282 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 289 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
283 if (!homemobile.number().isEmpty()) 290 if (!homemobile.number().isEmpty())
284 contact.setHomeMobile(homemobile.number()); 291 contact.setHomeMobile(homemobile.number());
285 292
286 contact.setHomeWebpage(addr.url().url()); 293 contact.setHomeWebpage(addr.url().url());
287 294
288 295
289 // business 296 // business
290 const Address businessaddress = addr.address(Address::Work); 297 const Address businessaddress = addr.address(Address::Work);
291 if (!businessaddress.isEmpty()) { 298 if (!businessaddress.isEmpty()) {
292 contact.setBusinessStreet(businessaddress.street()); 299 contact.setBusinessStreet(businessaddress.street());
293 contact.setBusinessCity(businessaddress.locality()); 300 contact.setBusinessCity(businessaddress.locality());
294 contact.setBusinessState(businessaddress.region()); 301 contact.setBusinessState(businessaddress.region());
295 contact.setBusinessZip(businessaddress.postalCode()); 302 contact.setBusinessZip(businessaddress.postalCode());
296 contact.setBusinessCountry(businessaddress.country()); 303 contact.setBusinessCountry(businessaddress.country());
297 } 304 }
298 305
299 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 306 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
300 if (!businessphone.number().isEmpty()) 307 if (!businessphone.number().isEmpty())
301 contact.setBusinessPhone(businessphone.number()); 308 contact.setBusinessPhone(businessphone.number());
302 309
303 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 310 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
304 if (!businessfax.number().isEmpty()) 311 if (!businessfax.number().isEmpty())
305 contact.setBusinessFax(businessfax.number()); 312 contact.setBusinessFax(businessfax.number());
306 313
307 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 314 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
308 if (!businessmobile.number().isEmpty()) 315 if (!businessmobile.number().isEmpty())
309 contact.setBusinessMobile(businessmobile.number()); 316 contact.setBusinessMobile(businessmobile.number());
310 317
311 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 318 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
312 if (!businesspager.number().isEmpty()) 319 if (!businesspager.number().isEmpty())
313 contact.setBusinessPager(businesspager.number()); 320 contact.setBusinessPager(businesspager.number());
314 321
315 contact.setJobTitle(addr.role()); 322 contact.setJobTitle(addr.role());
316 contact.setCompany(addr.organization()); 323 contact.setCompany(addr.organization());
317 324
318 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 325 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
319 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 326 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
320 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 327 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
321 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 328 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
322 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 329 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
323 330
324 //personal 331 //personal
325 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 332 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
326 // qtopia uses this categorization: 333 // qtopia uses this categorization:
327 // enum GenderType { UnspecifiedGender=0, Male, Female }; 334 // enum GenderType { UnspecifiedGender=0, Male, Female };
328 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 335 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
329 if (gt = "male") 336 if (gt = "male")
330 contact.setGender(PimContact::Male); 337 contact.setGender(PimContact::Male);
331 else if (gt = "female") 338 else if (gt = "female")
332 contact.setGender(PimContact::Female); 339 contact.setGender(PimContact::Female);
333 else 340 else
334 contact.setGender(PimContact::UnspecifiedGender); 341 contact.setGender(PimContact::UnspecifiedGender);
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index fa0c51f..d6482fb 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2697,326 +2697,328 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2697 addresseeRSync.setRevision( mLastAddressbookSync ); 2697 addresseeRSync.setRevision( mLastAddressbookSync );
2698 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2698 addresseeRSync.setCategories( i18n("SyncAddressee") );
2699 } 2699 }
2700 } 2700 }
2701 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2701 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2702 qDebug("FULLDATE 2"); 2702 qDebug("FULLDATE 2");
2703 fullDateRange = true; 2703 fullDateRange = true;
2704 } 2704 }
2705 if ( ! fullDateRange ) { 2705 if ( ! fullDateRange ) {
2706 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2706 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2707 2707
2708 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2708 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2709 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2709 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2710 fullDateRange = true; 2710 fullDateRange = true;
2711 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2711 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2712 } 2712 }
2713 } 2713 }
2714 // fullDateRange = true; // debug only! 2714 // fullDateRange = true; // debug only!
2715 if ( fullDateRange ) 2715 if ( fullDateRange )
2716 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2716 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2717 else 2717 else
2718 mLastAddressbookSync = addresseeLSync.revision(); 2718 mLastAddressbookSync = addresseeLSync.revision();
2719 // for resyncing if own file has changed 2719 // for resyncing if own file has changed
2720 // PENDING fixme later when implemented 2720 // PENDING fixme later when implemented
2721#if 0 2721#if 0
2722 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2722 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2723 mLastAddressbookSync = loadedFileVersion; 2723 mLastAddressbookSync = loadedFileVersion;
2724 qDebug("setting mLastAddressbookSync "); 2724 qDebug("setting mLastAddressbookSync ");
2725 } 2725 }
2726#endif 2726#endif
2727 2727
2728 //qDebug("*************************** "); 2728 //qDebug("*************************** ");
2729 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2729 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2730 QStringList er = remote->uidList(); 2730 QStringList er = remote->uidList();
2731 Addressee inR ;//= er.first(); 2731 Addressee inR ;//= er.first();
2732 Addressee inL; 2732 Addressee inL;
2733 QProgressBar bar( er.count(),0 ); 2733 QProgressBar bar( er.count(),0 );
2734 bar.setCaption (i18n("Syncing - close to abort!") ); 2734 bar.setCaption (i18n("Syncing - close to abort!") );
2735 2735
2736 int w = 300; 2736 int w = 300;
2737 if ( QApplication::desktop()->width() < 320 ) 2737 if ( QApplication::desktop()->width() < 320 )
2738 w = 220; 2738 w = 220;
2739 int h = bar.sizeHint().height() ; 2739 int h = bar.sizeHint().height() ;
2740 int dw = QApplication::desktop()->width(); 2740 int dw = QApplication::desktop()->width();
2741 int dh = QApplication::desktop()->height(); 2741 int dh = QApplication::desktop()->height();
2742 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2742 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2743 bar.show(); 2743 bar.show();
2744 int modulo = (er.count()/10)+1; 2744 int modulo = (er.count()/10)+1;
2745 int incCounter = 0; 2745 int incCounter = 0;
2746 while ( incCounter < er.count()) { 2746 while ( incCounter < er.count()) {
2747 if ( ! bar.isVisible() ) 2747 if ( ! bar.isVisible() )
2748 return false; 2748 return false;
2749 if ( incCounter % modulo == 0 ) 2749 if ( incCounter % modulo == 0 )
2750 bar.setProgress( incCounter ); 2750 bar.setProgress( incCounter );
2751 uid = er[ incCounter ]; 2751 uid = er[ incCounter ];
2752 bool skipIncidence = false; 2752 bool skipIncidence = false;
2753 if ( uid.left(19) == QString("last-syncAddressee-") ) 2753 if ( uid.left(19) == QString("last-syncAddressee-") )
2754 skipIncidence = true; 2754 skipIncidence = true;
2755 QString idS; 2755 QString idS;
2756 qApp->processEvents(); 2756 qApp->processEvents();
2757 if ( !skipIncidence ) { 2757 if ( !skipIncidence ) {
2758 inL = local->findByUid( uid ); 2758 inL = local->findByUid( uid );
2759 inR = remote->findByUid( uid ); 2759 inR = remote->findByUid( uid );
2760 //inL.setResource( 0 ); 2760 //inL.setResource( 0 );
2761 //inR.setResource( 0 ); 2761 //inR.setResource( 0 );
2762 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2762 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2763 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2763 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2764 //qDebug("take %d %s ", take, inL.summary().latin1()); 2764 //qDebug("take %d %s ", take, inL.summary().latin1());
2765 if ( take == 3 ) 2765 if ( take == 3 )
2766 return false; 2766 return false;
2767 if ( take == 1 ) {// take local 2767 if ( take == 1 ) {// take local
2768 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2768 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2769 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2769 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2770 local->insertAddressee( inL, false ); 2770 local->insertAddressee( inL, false );
2771 } 2771 }
2772 else 2772 else
2773 idS = inR.IDStr(); 2773 idS = inR.IDStr();
2774 remote->removeAddressee( inR ); 2774 remote->removeAddressee( inR );
2775 inR = inL; 2775 inR = inL;
2776 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2776 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2777 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 2777 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
2778 inR.setIDStr( idS ); 2778 inR.setIDStr( idS );
2779 inR.setResource( 0 ); 2779 inR.setResource( 0 );
2780 remote->insertAddressee( inR , false); 2780 remote->insertAddressee( inR , false);
2781 ++changedRemote; 2781 ++changedRemote;
2782 } else { 2782 } else {
2783 idS = inL.IDStr(); 2783 idS = inL.IDStr();
2784 local->removeAddressee( inL ); 2784 local->removeAddressee( inL );
2785 inL = inR; 2785 inL = inR;
2786 inL.setIDStr( idS ); 2786 inL.setIDStr( idS );
2787 inL.setResource( 0 ); 2787 inL.setResource( 0 );
2788 local->insertAddressee( inL , false ); 2788 local->insertAddressee( inL , false );
2789 ++changedLocal; 2789 ++changedLocal;
2790 } 2790 }
2791 } 2791 }
2792 } else { // no conflict 2792 } else { // no conflict
2793 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2793 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2794 QString des = addresseeLSync.note(); 2794 QString des = addresseeLSync.note();
2795 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2795 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2796 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2796 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2797 remote->insertAddressee( inR, false ); 2797 remote->insertAddressee( inR, false );
2798 ++deletedAddresseeR; 2798 ++deletedAddresseeR;
2799 } else { 2799 } else {
2800 inR.setRevision( modifiedCalendar ); 2800 inR.setRevision( modifiedCalendar );
2801 remote->insertAddressee( inR, false ); 2801 remote->insertAddressee( inR, false );
2802 inL = inR; 2802 inL = inR;
2803 inL.setResource( 0 ); 2803 inL.setResource( 0 );
2804 local->insertAddressee( inL , false); 2804 local->insertAddressee( inL , false);
2805 ++addedAddressee; 2805 ++addedAddressee;
2806 } 2806 }
2807 } else { 2807 } else {
2808 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2808 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2809 inR.setRevision( modifiedCalendar ); 2809 inR.setRevision( modifiedCalendar );
2810 remote->insertAddressee( inR, false ); 2810 remote->insertAddressee( inR, false );
2811 inR.setResource( 0 ); 2811 inR.setResource( 0 );
2812 local->insertAddressee( inR, false ); 2812 local->insertAddressee( inR, false );
2813 ++addedAddressee; 2813 ++addedAddressee;
2814 } else { 2814 } else {
2815 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2815 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2816 remote->removeAddressee( inR ); 2816 remote->removeAddressee( inR );
2817 ++deletedAddresseeR; 2817 ++deletedAddresseeR;
2818 } 2818 }
2819 } 2819 }
2820 } 2820 }
2821 } 2821 }
2822 ++incCounter; 2822 ++incCounter;
2823 } 2823 }
2824 er.clear(); 2824 er.clear();
2825 QStringList el = local->uidList(); 2825 QStringList el = local->uidList();
2826 modulo = (el.count()/10)+1; 2826 modulo = (el.count()/10)+1;
2827 bar.setCaption (i18n("Add / remove addressees") ); 2827 bar.setCaption (i18n("Add / remove addressees") );
2828 bar.setTotalSteps ( el.count() ) ; 2828 bar.setTotalSteps ( el.count() ) ;
2829 bar.show(); 2829 bar.show();
2830 incCounter = 0; 2830 incCounter = 0;
2831 while ( incCounter < el.count()) { 2831 while ( incCounter < el.count()) {
2832 qApp->processEvents(); 2832 qApp->processEvents();
2833 if ( ! bar.isVisible() ) 2833 if ( ! bar.isVisible() )
2834 return false; 2834 return false;
2835 if ( incCounter % modulo == 0 ) 2835 if ( incCounter % modulo == 0 )
2836 bar.setProgress( incCounter ); 2836 bar.setProgress( incCounter );
2837 uid = el[ incCounter ]; 2837 uid = el[ incCounter ];
2838 bool skipIncidence = false; 2838 bool skipIncidence = false;
2839 if ( uid.left(19) == QString("last-syncAddressee-") ) 2839 if ( uid.left(19) == QString("last-syncAddressee-") )
2840 skipIncidence = true; 2840 skipIncidence = true;
2841 if ( !skipIncidence ) { 2841 if ( !skipIncidence ) {
2842 inL = local->findByUid( uid ); 2842 inL = local->findByUid( uid );
2843 inR = remote->findByUid( uid ); 2843 inR = remote->findByUid( uid );
2844 if ( inR.isEmpty() ) { 2844 if ( inR.isEmpty() ) {
2845 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2845 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2846 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2846 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2847 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2847 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2848 local->removeAddressee( inL ); 2848 local->removeAddressee( inL );
2849 ++deletedAddresseeL; 2849 ++deletedAddresseeL;
2850 } else { 2850 } else {
2851 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2851 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2852 inL.removeID(mCurrentSyncDevice ); 2852 inL.removeID(mCurrentSyncDevice );
2853 ++addedAddresseeR; 2853 ++addedAddresseeR;
2854 inL.setRevision( modifiedCalendar ); 2854 inL.setRevision( modifiedCalendar );
2855 local->insertAddressee( inL, false ); 2855 local->insertAddressee( inL, false );
2856 inR = inL; 2856 inR = inL;
2857 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2857 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2858 inR.setResource( 0 ); 2858 inR.setResource( 0 );
2859 remote->insertAddressee( inR, false ); 2859 remote->insertAddressee( inR, false );
2860 } 2860 }
2861 } 2861 }
2862 } else { 2862 } else {
2863 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2863 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2864 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2864 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2865 local->removeAddressee( inL ); 2865 local->removeAddressee( inL );
2866 ++deletedAddresseeL; 2866 ++deletedAddresseeL;
2867 } else { 2867 } else {
2868 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2868 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2869 ++addedAddresseeR; 2869 ++addedAddresseeR;
2870 inL.setRevision( modifiedCalendar ); 2870 inL.setRevision( modifiedCalendar );
2871 local->insertAddressee( inL, false ); 2871 local->insertAddressee( inL, false );
2872 inR = inL; 2872 inR = inL;
2873 inR.setResource( 0 ); 2873 inR.setResource( 0 );
2874 remote->insertAddressee( inR, false ); 2874 remote->insertAddressee( inR, false );
2875 } 2875 }
2876 } 2876 }
2877 } 2877 }
2878 } 2878 }
2879 } 2879 }
2880 ++incCounter; 2880 ++incCounter;
2881 } 2881 }
2882 el.clear(); 2882 el.clear();
2883 bar.hide(); 2883 bar.hide();
2884 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2884 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2885 // get rid of micro seconds 2885 // get rid of micro seconds
2886 QTime t = mLastAddressbookSync.time(); 2886 QTime t = mLastAddressbookSync.time();
2887 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2887 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2888 addresseeLSync.setRevision( mLastAddressbookSync ); 2888 addresseeLSync.setRevision( mLastAddressbookSync );
2889 addresseeRSync.setRevision( mLastAddressbookSync ); 2889 addresseeRSync.setRevision( mLastAddressbookSync );
2890 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2890 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2891 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2891 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2892 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2892 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2893 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2893 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2894 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2894 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2895 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2895 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2896 addresseeRSync.setNote( "" ) ; 2896 addresseeRSync.setNote( "" ) ;
2897 addresseeLSync.setNote( "" ); 2897 addresseeLSync.setNote( "" );
2898 2898
2899 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2899 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2900 remote->insertAddressee( addresseeRSync, false ); 2900 remote->insertAddressee( addresseeRSync, false );
2901 local->insertAddressee( addresseeLSync, false ); 2901 local->insertAddressee( addresseeLSync, false );
2902 QString mes; 2902 QString mes;
2903 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2903 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2904 if ( KABPrefs::instance()->mShowSyncSummary ) { 2904 if ( KABPrefs::instance()->mShowSyncSummary ) {
2905 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2905 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2906 } 2906 }
2907 qDebug( mes ); 2907 qDebug( mes );
2908 return syncOK; 2908 return syncOK;
2909} 2909}
2910 2910
2911bool KABCore::syncAB(QString filename, int mode) 2911bool KABCore::syncAB(QString filename, int mode)
2912{ 2912{
2913 2913
2914 //pending prepare addresseeview for output 2914 //pending prepare addresseeview for output
2915 //pending detect, if remote file has REV field. if not switch to external sync 2915 //pending detect, if remote file has REV field. if not switch to external sync
2916 mGlobalSyncMode = SYNC_MODE_NORMAL; 2916 mGlobalSyncMode = SYNC_MODE_NORMAL;
2917 AddressBook abLocal(filename,"syncContact"); 2917 AddressBook abLocal(filename,"syncContact");
2918 bool syncOK = false; 2918 bool syncOK = false;
2919 if ( abLocal.load() ) { 2919 if ( abLocal.load() ) {
2920 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2920 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2921 bool external = false; 2921 bool external = false;
2922 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2922 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2923 if ( ! lse.isEmpty() ) { 2923 if ( ! lse.isEmpty() ) {
2924 if ( lse.familyName().left(4) == "!E: " ) 2924 if ( lse.familyName().left(4) == "!E: " )
2925 external = true; 2925 external = true;
2926 } else { 2926 } else {
2927 bool found = false; 2927 bool found = false;
2928 QDateTime dt( QDate( 2004,1,1)); 2928 QDateTime dt( QDate( 2004,1,1));
2929 AddressBook::Iterator it; 2929 AddressBook::Iterator it;
2930 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2930 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2931 if ( (*it).revision() != dt ) { 2931 if ( (*it).revision() != dt ) {
2932 found = true; 2932 found = true;
2933 break; 2933 break;
2934 } 2934 }
2935 } 2935 }
2936 external = ! found; 2936 external = ! found;
2937 } 2937 }
2938 2938
2939 if ( external ) { 2939 if ( external ) {
2940 qDebug("Setting vcf mode to external "); 2940 qDebug("Setting vcf mode to external ");
2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2942 AddressBook::Iterator it; 2942 AddressBook::Iterator it;
2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2944 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2944 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2945 (*it).computeCsum( mCurrentSyncDevice ); 2945 (*it).computeCsum( mCurrentSyncDevice );
2946 } 2946 }
2947 } 2947 }
2948 //AddressBook::Iterator it; 2948 //AddressBook::Iterator it;
2949 //QStringList vcards; 2949 //QStringList vcards;
2950 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2950 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2951 // qDebug("Name %s ", (*it).familyName().latin1()); 2951 // qDebug("Name %s ", (*it).familyName().latin1());
2952 //} 2952 //}
2953 if ( filename.right(4) == ".xml")
2954 abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
2953 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2955 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2954 if ( syncOK ) { 2956 if ( syncOK ) {
2955 if ( KABPrefs::instance()->mWriteBackFile ) 2957 if ( KABPrefs::instance()->mWriteBackFile )
2956 { 2958 {
2957 if ( external ) 2959 if ( external )
2958 abLocal.removeDeletedAddressees(); 2960 abLocal.removeDeletedAddressees();
2959 qDebug("Saving remote AB "); 2961 qDebug("Saving remote AB ");
2960 abLocal.saveAB(); 2962 abLocal.saveAB();
2961 } 2963 }
2962 } 2964 }
2963 setModified(); 2965 setModified();
2964 2966
2965 } 2967 }
2966 if ( syncOK ) 2968 if ( syncOK )
2967 mViewManager->refreshView(); 2969 mViewManager->refreshView();
2968 return syncOK; 2970 return syncOK;
2969#if 0 2971#if 0
2970 2972
2971 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2973 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2972 getEventViewerDialog()->setSyncMode( true ); 2974 getEventViewerDialog()->setSyncMode( true );
2973 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2975 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2974 getEventViewerDialog()->setSyncMode( false ); 2976 getEventViewerDialog()->setSyncMode( false );
2975 if ( syncOK ) { 2977 if ( syncOK ) {
2976 if ( KOPrefs::instance()->mWriteBackFile ) 2978 if ( KOPrefs::instance()->mWriteBackFile )
2977 { 2979 {
2978 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2980 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2979 storage->save(); 2981 storage->save();
2980 } 2982 }
2981 } 2983 }
2982 setModified(); 2984 setModified();
2983 } 2985 }
2984 2986
2985#endif 2987#endif
2986} 2988}
2987 2989
2988void KABCore::confSync() 2990void KABCore::confSync()
2989{ 2991{
2990 static KSyncPrefsDialog* sp = 0; 2992 static KSyncPrefsDialog* sp = 0;
2991 if ( ! sp ) { 2993 if ( ! sp ) {
2992 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 2994 sp = new KSyncPrefsDialog( this, "syncprefs", true );
2993 } 2995 }
2994 sp->usrReadConfig(); 2996 sp->usrReadConfig();
2995#ifndef DESKTOP_VERSION 2997#ifndef DESKTOP_VERSION
2996 sp->showMaximized(); 2998 sp->showMaximized();
2997#else 2999#else
2998 sp->show(); 3000 sp->show();
2999#endif 3001#endif
3000 sp->exec(); 3002 sp->exec();
3001 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 3003 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
3002 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 3004 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
3003 fillSyncMenu(); 3005 fillSyncMenu();
3004} 3006}
3005void KABCore::syncSharp() 3007void KABCore::syncSharp()
3006{ 3008{
3007 if ( mModified ) 3009 if ( mModified )
3008 save(); 3010 save();
3009 qDebug("pending syncSharp() "); 3011 qDebug("pending syncSharp() ");
3010 //mView->syncSharp(); 3012 //mView->syncSharp();
3011 setModified(); 3013 setModified();
3012 3014
3013} 3015}
3014void KABCore::syncPhone() 3016void KABCore::syncPhone()
3015{ 3017{
3016 if ( mModified ) 3018 if ( mModified )
3017 save(); 3019 save();
3018 qDebug("pending syncPhone(); "); 3020 qDebug("pending syncPhone(); ");
3019 //mView->syncPhone(); 3021 //mView->syncPhone();
3020 setModified(); 3022 setModified();
3021 3023
3022} 3024}