summaryrefslogtreecommitdiff
path: root/libopie/pim
authorzecke <zecke>2002-11-03 17:56:17 (UTC)
committer zecke <zecke>2002-11-03 17:56:17 (UTC)
commit2981b8f55f4a33860452f4571ef9f04781267489 (patch) (unidiff)
tree3d0fe68318c23efdbcf72acfae94b3e76e2b4a14 /libopie/pim
parent3bc2ff91e60f23dd235599b3d83471bde8be1c8a (diff)
downloadopie-2981b8f55f4a33860452f4571ef9f04781267489.zip
opie-2981b8f55f4a33860452f4571ef9f04781267489.tar.gz
opie-2981b8f55f4a33860452f4571ef9f04781267489.tar.bz2
Oh OContact what a sucker ;)
first of all UID generation belongs to OPimRecord and was removed from OContact then setUid now actually calls OPimRecord::setUid instead of Record::setUid This finally fixes the problem with wrong uids after beaming... At least locally on my machine
Diffstat (limited to 'libopie/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp5
-rw-r--r--libopie/pim/ocontact.h6
-rw-r--r--libopie/pim/opimrecord.cpp2
3 files changed, 4 insertions, 9 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index cd238ef..8a0930b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,1662 +1,1663 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of the Qtopia Environment. 5** This file is part of the Qtopia Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#define QTOPIA_INTERNAL_CONTACT_MRE 22#define QTOPIA_INTERNAL_CONTACT_MRE
23 23
24#include "ocontact.h" 24#include "ocontact.h"
25#include "../../library/backend/vobject_p.h" 25#include "../../library/backend/vobject_p.h"
26#include "../../library/backend/qfiledirect_p.h" 26#include "../../library/backend/qfiledirect_p.h"
27 27
28#include <qpe/stringutil.h> 28#include <qpe/stringutil.h>
29#include <qpe/timeconversion.h> 29#include <qpe/timeconversion.h>
30#include <qpe/timestring.h> 30#include <qpe/timestring.h>
31 31
32#include <qobject.h> 32#include <qobject.h>
33#include <qregexp.h> 33#include <qregexp.h>
34#include <qstylesheet.h> 34#include <qstylesheet.h>
35#include <qfileinfo.h> 35#include <qfileinfo.h>
36#include <qmap.h> 36#include <qmap.h>
37 37
38#include <stdio.h> 38#include <stdio.h>
39 39
40/*! 40/*!
41 \class Contact contact.h 41 \class Contact contact.h
42 \brief The Contact class holds the data of an address book entry. 42 \brief The Contact class holds the data of an address book entry.
43 43
44 This data includes information the name of the person, contact 44 This data includes information the name of the person, contact
45 information, and business information such as deparment and job title. 45 information, and business information such as deparment and job title.
46 46
47 \ingroup qtopiaemb 47 \ingroup qtopiaemb
48 \ingroup qtopiadesktop 48 \ingroup qtopiadesktop
49*/ 49*/
50 50
51Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia );
52 51
53/*! 52/*!
54 Creates a new, empty contact. 53 Creates a new, empty contact.
55*/ 54*/
56OContact::OContact() 55OContact::OContact()
57 : OPimRecord(), mMap(), d( 0 ) 56 : OPimRecord(), mMap(), d( 0 )
58{ 57{
59} 58}
60 59
61/*! 60/*!
62 \internal 61 \internal
63 Creates a new contact. The properties of the contact are 62 Creates a new contact. The properties of the contact are
64 set from \a fromMap. 63 set from \a fromMap.
65*/ 64*/
66OContact::OContact( const QMap<int, QString> &fromMap ) : 65OContact::OContact( const QMap<int, QString> &fromMap ) :
67 OPimRecord(), mMap( fromMap ), d( 0 ) 66 OPimRecord(), mMap( fromMap ), d( 0 )
68{ 67{
69 QString cats = mMap[ Qtopia::AddressCategory ]; 68 QString cats = mMap[ Qtopia::AddressCategory ];
70 if ( !cats.isEmpty() ) 69 if ( !cats.isEmpty() )
71 setCategories( idsFromString( cats ) ); 70 setCategories( idsFromString( cats ) );
72 71
73 QString uidStr = find( Qtopia::AddressUid ); 72 QString uidStr = find( Qtopia::AddressUid );
74 73
75 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 74 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
76 qWarning( "Invalid UID found. Generate new one.." ); 75 qWarning( "Invalid UID found. Generate new one.." );
77 setUid( uidGen().generate() ); 76 setUid( uidGen().generate() );
78 }else 77 }else
79 setUid( uidStr.toInt() ); 78 setUid( uidStr.toInt() );
80 79
81// if ( !uidStr.isEmpty() ) 80// if ( !uidStr.isEmpty() )
82 // setUid( uidStr.toInt() ); 81 // setUid( uidStr.toInt() );
83} 82}
84 83
85/*! 84/*!
86 Destroys a contact. 85 Destroys a contact.
87*/ 86*/
88OContact::~OContact() 87OContact::~OContact()
89{ 88{
90} 89}
91 90
92/*! \fn void OContact::setTitle( const QString &str ) 91/*! \fn void OContact::setTitle( const QString &str )
93 Sets the title of the contact to \a str. 92 Sets the title of the contact to \a str.
94*/ 93*/
95 94
96/*! \fn void OContact::setFirstName( const QString &str ) 95/*! \fn void OContact::setFirstName( const QString &str )
97 Sets the first name of the contact to \a str. 96 Sets the first name of the contact to \a str.
98*/ 97*/
99 98
100/*! \fn void OContact::setMiddleName( const QString &str ) 99/*! \fn void OContact::setMiddleName( const QString &str )
101 Sets the middle name of the contact to \a str. 100 Sets the middle name of the contact to \a str.
102*/ 101*/
103 102
104/*! \fn void OContact::setLastName( const QString &str ) 103/*! \fn void OContact::setLastName( const QString &str )
105 Sets the last name of the contact to \a str. 104 Sets the last name of the contact to \a str.
106*/ 105*/
107 106
108/*! \fn void OContact::setSuffix( const QString &str ) 107/*! \fn void OContact::setSuffix( const QString &str )
109 Sets the suffix of the contact to \a str. 108 Sets the suffix of the contact to \a str.
110*/ 109*/
111 110
112/*! \fn void OContact::setFileAs( const QString &str ) 111/*! \fn void OContact::setFileAs( const QString &str )
113 Sets the contact to filed as \a str. 112 Sets the contact to filed as \a str.
114*/ 113*/
115 114
116/*! \fn void OContact::setDefaultEmail( const QString &str ) 115/*! \fn void OContact::setDefaultEmail( const QString &str )
117 Sets the default email of the contact to \a str. 116 Sets the default email of the contact to \a str.
118*/ 117*/
119 118
120/*! \fn void OContact::setHomeStreet( const QString &str ) 119/*! \fn void OContact::setHomeStreet( const QString &str )
121 Sets the home street address of the contact to \a str. 120 Sets the home street address of the contact to \a str.
122*/ 121*/
123 122
124/*! \fn void OContact::setHomeCity( const QString &str ) 123/*! \fn void OContact::setHomeCity( const QString &str )
125 Sets the home city of the contact to \a str. 124 Sets the home city of the contact to \a str.
126*/ 125*/
127 126
128/*! \fn void OContact::setHomeState( const QString &str ) 127/*! \fn void OContact::setHomeState( const QString &str )
129 Sets the home state of the contact to \a str. 128 Sets the home state of the contact to \a str.
130*/ 129*/
131 130
132/*! \fn void OContact::setHomeZip( const QString &str ) 131/*! \fn void OContact::setHomeZip( const QString &str )
133 Sets the home zip code of the contact to \a str. 132 Sets the home zip code of the contact to \a str.
134*/ 133*/
135 134
136/*! \fn void OContact::setHomeCountry( const QString &str ) 135/*! \fn void OContact::setHomeCountry( const QString &str )
137 Sets the home country of the contact to \a str. 136 Sets the home country of the contact to \a str.
138*/ 137*/
139 138
140/*! \fn void OContact::setHomePhone( const QString &str ) 139/*! \fn void OContact::setHomePhone( const QString &str )
141 Sets the home phone number of the contact to \a str. 140 Sets the home phone number of the contact to \a str.
142*/ 141*/
143 142
144/*! \fn void OContact::setHomeFax( const QString &str ) 143/*! \fn void OContact::setHomeFax( const QString &str )
145 Sets the home fax number of the contact to \a str. 144 Sets the home fax number of the contact to \a str.
146*/ 145*/
147 146
148/*! \fn void OContact::setHomeMobile( const QString &str ) 147/*! \fn void OContact::setHomeMobile( const QString &str )
149 Sets the home mobile phone number of the contact to \a str. 148 Sets the home mobile phone number of the contact to \a str.
150*/ 149*/
151 150
152/*! \fn void OContact::setHomeWebpage( const QString &str ) 151/*! \fn void OContact::setHomeWebpage( const QString &str )
153 Sets the home webpage of the contact to \a str. 152 Sets the home webpage of the contact to \a str.
154*/ 153*/
155 154
156/*! \fn void OContact::setCompany( const QString &str ) 155/*! \fn void OContact::setCompany( const QString &str )
157 Sets the company for contact to \a str. 156 Sets the company for contact to \a str.
158*/ 157*/
159 158
160/*! \fn void OContact::setJobTitle( const QString &str ) 159/*! \fn void OContact::setJobTitle( const QString &str )
161 Sets the job title of the contact to \a str. 160 Sets the job title of the contact to \a str.
162*/ 161*/
163 162
164/*! \fn void OContact::setDepartment( const QString &str ) 163/*! \fn void OContact::setDepartment( const QString &str )
165 Sets the department for contact to \a str. 164 Sets the department for contact to \a str.
166*/ 165*/
167 166
168/*! \fn void OContact::setOffice( const QString &str ) 167/*! \fn void OContact::setOffice( const QString &str )
169 Sets the office for contact to \a str. 168 Sets the office for contact to \a str.
170*/ 169*/
171 170
172/*! \fn void OContact::setBusinessStreet( const QString &str ) 171/*! \fn void OContact::setBusinessStreet( const QString &str )
173 Sets the business street address of the contact to \a str. 172 Sets the business street address of the contact to \a str.
174*/ 173*/
175 174
176/*! \fn void OContact::setBusinessCity( const QString &str ) 175/*! \fn void OContact::setBusinessCity( const QString &str )
177 Sets the business city of the contact to \a str. 176 Sets the business city of the contact to \a str.
178*/ 177*/
179 178
180/*! \fn void OContact::setBusinessState( const QString &str ) 179/*! \fn void OContact::setBusinessState( const QString &str )
181 Sets the business state of the contact to \a str. 180 Sets the business state of the contact to \a str.
182*/ 181*/
183 182
184/*! \fn void OContact::setBusinessZip( const QString &str ) 183/*! \fn void OContact::setBusinessZip( const QString &str )
185 Sets the business zip code of the contact to \a str. 184 Sets the business zip code of the contact to \a str.
186*/ 185*/
187 186
188/*! \fn void OContact::setBusinessCountry( const QString &str ) 187/*! \fn void OContact::setBusinessCountry( const QString &str )
189 Sets the business country of the contact to \a str. 188 Sets the business country of the contact to \a str.
190*/ 189*/
191 190
192/*! \fn void OContact::setBusinessPhone( const QString &str ) 191/*! \fn void OContact::setBusinessPhone( const QString &str )
193 Sets the business phone number of the contact to \a str. 192 Sets the business phone number of the contact to \a str.
194*/ 193*/
195 194
196/*! \fn void OContact::setBusinessFax( const QString &str ) 195/*! \fn void OContact::setBusinessFax( const QString &str )
197 Sets the business fax number of the contact to \a str. 196 Sets the business fax number of the contact to \a str.
198*/ 197*/
199 198
200/*! \fn void OContact::setBusinessMobile( const QString &str ) 199/*! \fn void OContact::setBusinessMobile( const QString &str )
201 Sets the business mobile phone number of the contact to \a str. 200 Sets the business mobile phone number of the contact to \a str.
202*/ 201*/
203 202
204/*! \fn void OContact::setBusinessPager( const QString &str ) 203/*! \fn void OContact::setBusinessPager( const QString &str )
205 Sets the business pager number of the contact to \a str. 204 Sets the business pager number of the contact to \a str.
206*/ 205*/
207 206
208/*! \fn void OContact::setBusinessWebpage( const QString &str ) 207/*! \fn void OContact::setBusinessWebpage( const QString &str )
209 Sets the business webpage of the contact to \a str. 208 Sets the business webpage of the contact to \a str.
210*/ 209*/
211 210
212/*! \fn void OContact::setProfession( const QString &str ) 211/*! \fn void OContact::setProfession( const QString &str )
213 Sets the profession of the contact to \a str. 212 Sets the profession of the contact to \a str.
214*/ 213*/
215 214
216/*! \fn void OContact::setAssistant( const QString &str ) 215/*! \fn void OContact::setAssistant( const QString &str )
217 Sets the assistant of the contact to \a str. 216 Sets the assistant of the contact to \a str.
218*/ 217*/
219 218
220/*! \fn void OContact::setManager( const QString &str ) 219/*! \fn void OContact::setManager( const QString &str )
221 Sets the manager of the contact to \a str. 220 Sets the manager of the contact to \a str.
222*/ 221*/
223 222
224/*! \fn void OContact::setSpouse( const QString &str ) 223/*! \fn void OContact::setSpouse( const QString &str )
225 Sets the spouse of the contact to \a str. 224 Sets the spouse of the contact to \a str.
226*/ 225*/
227 226
228/*! \fn void OContact::setGender( const QString &str ) 227/*! \fn void OContact::setGender( const QString &str )
229 Sets the gender of the contact to \a str. 228 Sets the gender of the contact to \a str.
230*/ 229*/
231 230
232/*! \fn void OContact::setNickname( const QString &str ) 231/*! \fn void OContact::setNickname( const QString &str )
233 Sets the nickname of the contact to \a str. 232 Sets the nickname of the contact to \a str.
234*/ 233*/
235 234
236/*! \fn void OContact::setNotes( const QString &str ) 235/*! \fn void OContact::setNotes( const QString &str )
237 Sets the notes about the contact to \a str. 236 Sets the notes about the contact to \a str.
238*/ 237*/
239 238
240/*! \fn QString OContact::title() const 239/*! \fn QString OContact::title() const
241 Returns the title of the contact. 240 Returns the title of the contact.
242*/ 241*/
243 242
244/*! \fn QString OContact::firstName() const 243/*! \fn QString OContact::firstName() const
245 Returns the first name of the contact. 244 Returns the first name of the contact.
246*/ 245*/
247 246
248/*! \fn QString OContact::middleName() const 247/*! \fn QString OContact::middleName() const
249 Returns the middle name of the contact. 248 Returns the middle name of the contact.
250*/ 249*/
251 250
252/*! \fn QString OContact::lastName() const 251/*! \fn QString OContact::lastName() const
253 Returns the last name of the contact. 252 Returns the last name of the contact.
254*/ 253*/
255 254
256/*! \fn QString OContact::suffix() const 255/*! \fn QString OContact::suffix() const
257 Returns the suffix of the contact. 256 Returns the suffix of the contact.
258*/ 257*/
259 258
260/*! \fn QString OContact::fileAs() const 259/*! \fn QString OContact::fileAs() const
261 Returns the string the contact is filed as. 260 Returns the string the contact is filed as.
262*/ 261*/
263 262
264/*! \fn QString OContact::defaultEmail() const 263/*! \fn QString OContact::defaultEmail() const
265 Returns the default email address of the contact. 264 Returns the default email address of the contact.
266*/ 265*/
267 266
268/*! \fn QString OContact::emails() const 267/*! \fn QString OContact::emails() const
269 Returns the list of email address for a contact separated by ';'s in a single 268 Returns the list of email address for a contact separated by ';'s in a single
270 string. 269 string.
271*/ 270*/
272 271
273/*! \fn QString OContact::homeStreet() const 272/*! \fn QString OContact::homeStreet() const
274 Returns the home street address of the contact. 273 Returns the home street address of the contact.
275*/ 274*/
276 275
277/*! \fn QString OContact::homeCity() const 276/*! \fn QString OContact::homeCity() const
278 Returns the home city of the contact. 277 Returns the home city of the contact.
279*/ 278*/
280 279
281/*! \fn QString OContact::homeState() const 280/*! \fn QString OContact::homeState() const
282 Returns the home state of the contact. 281 Returns the home state of the contact.
283*/ 282*/
284 283
285/*! \fn QString OContact::homeZip() const 284/*! \fn QString OContact::homeZip() const
286 Returns the home zip of the contact. 285 Returns the home zip of the contact.
287*/ 286*/
288 287
289/*! \fn QString OContact::homeCountry() const 288/*! \fn QString OContact::homeCountry() const
290 Returns the home country of the contact. 289 Returns the home country of the contact.
291*/ 290*/
292 291
293/*! \fn QString OContact::homePhone() const 292/*! \fn QString OContact::homePhone() const
294 Returns the home phone number of the contact. 293 Returns the home phone number of the contact.
295*/ 294*/
296 295
297/*! \fn QString OContact::homeFax() const 296/*! \fn QString OContact::homeFax() const
298 Returns the home fax number of the contact. 297 Returns the home fax number of the contact.
299*/ 298*/
300 299
301/*! \fn QString OContact::homeMobile() const 300/*! \fn QString OContact::homeMobile() const
302 Returns the home mobile number of the contact. 301 Returns the home mobile number of the contact.
303*/ 302*/
304 303
305/*! \fn QString OContact::homeWebpage() const 304/*! \fn QString OContact::homeWebpage() const
306 Returns the home webpage of the contact. 305 Returns the home webpage of the contact.
307*/ 306*/
308 307
309/*! \fn QString OContact::company() const 308/*! \fn QString OContact::company() const
310 Returns the company for the contact. 309 Returns the company for the contact.
311*/ 310*/
312 311
313/*! \fn QString OContact::department() const 312/*! \fn QString OContact::department() const
314 Returns the department for the contact. 313 Returns the department for the contact.
315*/ 314*/
316 315
317/*! \fn QString OContact::office() const 316/*! \fn QString OContact::office() const
318 Returns the office for the contact. 317 Returns the office for the contact.
319*/ 318*/
320 319
321/*! \fn QString OContact::jobTitle() const 320/*! \fn QString OContact::jobTitle() const
322 Returns the job title of the contact. 321 Returns the job title of the contact.
323*/ 322*/
324 323
325/*! \fn QString OContact::profession() const 324/*! \fn QString OContact::profession() const
326 Returns the profession of the contact. 325 Returns the profession of the contact.
327*/ 326*/
328 327
329/*! \fn QString OContact::assistant() const 328/*! \fn QString OContact::assistant() const
330 Returns the assistant of the contact. 329 Returns the assistant of the contact.
331*/ 330*/
332 331
333/*! \fn QString OContact::manager() const 332/*! \fn QString OContact::manager() const
334 Returns the manager of the contact. 333 Returns the manager of the contact.
335*/ 334*/
336 335
337/*! \fn QString OContact::businessStreet() const 336/*! \fn QString OContact::businessStreet() const
338 Returns the business street address of the contact. 337 Returns the business street address of the contact.
339*/ 338*/
340 339
341/*! \fn QString OContact::businessCity() const 340/*! \fn QString OContact::businessCity() const
342 Returns the business city of the contact. 341 Returns the business city of the contact.
343*/ 342*/
344 343
345/*! \fn QString OContact::businessState() const 344/*! \fn QString OContact::businessState() const
346 Returns the business state of the contact. 345 Returns the business state of the contact.
347*/ 346*/
348 347
349/*! \fn QString OContact::businessZip() const 348/*! \fn QString OContact::businessZip() const
350 Returns the business zip of the contact. 349 Returns the business zip of the contact.
351*/ 350*/
352 351
353/*! \fn QString OContact::businessCountry() const 352/*! \fn QString OContact::businessCountry() const
354 Returns the business country of the contact. 353 Returns the business country of the contact.
355*/ 354*/
356 355
357/*! \fn QString OContact::businessPhone() const 356/*! \fn QString OContact::businessPhone() const
358 Returns the business phone number of the contact. 357 Returns the business phone number of the contact.
359*/ 358*/
360 359
361/*! \fn QString OContact::businessFax() const 360/*! \fn QString OContact::businessFax() const
362 Returns the business fax number of the contact. 361 Returns the business fax number of the contact.
363*/ 362*/
364 363
365/*! \fn QString OContact::businessMobile() const 364/*! \fn QString OContact::businessMobile() const
366 Returns the business mobile number of the contact. 365 Returns the business mobile number of the contact.
367*/ 366*/
368 367
369/*! \fn QString OContact::businessPager() const 368/*! \fn QString OContact::businessPager() const
370 Returns the business pager number of the contact. 369 Returns the business pager number of the contact.
371*/ 370*/
372 371
373/*! \fn QString OContact::businessWebpage() const 372/*! \fn QString OContact::businessWebpage() const
374 Returns the business webpage of the contact. 373 Returns the business webpage of the contact.
375*/ 374*/
376 375
377/*! \fn QString OContact::spouse() const 376/*! \fn QString OContact::spouse() const
378 Returns the spouse of the contact. 377 Returns the spouse of the contact.
379*/ 378*/
380 379
381/*! \fn QString OContact::gender() const 380/*! \fn QString OContact::gender() const
382 Returns the gender of the contact. 381 Returns the gender of the contact.
383*/ 382*/
384 383
385/*! \fn QString OContact::nickname() const 384/*! \fn QString OContact::nickname() const
386 Returns the nickname of the contact. 385 Returns the nickname of the contact.
387*/ 386*/
388 387
389/*! \fn QString OContact::children() const 388/*! \fn QString OContact::children() const
390 Returns the children of the contact. 389 Returns the children of the contact.
391*/ 390*/
392 391
393/*! \fn QString OContact::notes() const 392/*! \fn QString OContact::notes() const
394 Returns the notes relating to the the contact. 393 Returns the notes relating to the the contact.
395*/ 394*/
396 395
397/*! \fn QString OContact::groups() const 396/*! \fn QString OContact::groups() const
398 \internal 397 \internal
399 Returns the groups for the contact. 398 Returns the groups for the contact.
400*/ 399*/
401 400
402/*! \fn QStringList OContact::groupList() const 401/*! \fn QStringList OContact::groupList() const
403 \internal 402 \internal
404*/ 403*/
405 404
406/*! \fn QString OContact::field(int) const 405/*! \fn QString OContact::field(int) const
407 \internal 406 \internal
408*/ 407*/
409 408
410/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 409/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
411 \internal 410 \internal
412*/ 411*/
413 412
414/*! \fn void OContact::setUid( int id ) 413/*! \fn void OContact::setUid( int id )
415 \internal 414 \internal
416 Sets the uid for this record to \a id. 415 Sets the uid for this record to \a id.
417*/ 416*/
418 417
419/*! \enum OContact::journal_action 418/*! \enum OContact::journal_action
420 \internal 419 \internal
421*/ 420*/
422 421
423/*! 422/*!
424 \internal 423 \internal
425*/ 424*/
426QMap<int, QString> OContact::toMap() const 425QMap<int, QString> OContact::toMap() const
427{ 426{
428 QMap<int, QString> map = mMap; 427 QMap<int, QString> map = mMap;
429 QString cats = idsToString( categories() ); 428 QString cats = idsToString( categories() );
430 if ( !cats.isEmpty() ) 429 if ( !cats.isEmpty() )
431 map.insert( Qtopia::AddressCategory, cats ); 430 map.insert( Qtopia::AddressCategory, cats );
432 return map; 431 return map;
433} 432}
434 433
435/*! 434/*!
436 Returns a rich text formatted QString representing the contents the contact. 435 Returns a rich text formatted QString representing the contents the contact.
437*/ 436*/
438QString OContact::toRichText() const 437QString OContact::toRichText() const
439{ 438{
440 QString text; 439 QString text;
441 QString value, comp, state; 440 QString value, comp, state;
442 441
443 // name, jobtitle and company 442 // name, jobtitle and company
444 if ( !(value = fullName()).isEmpty() ) 443 if ( !(value = fullName()).isEmpty() )
445 text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; 444 text += "<b>" + Qtopia::escapeString(value) + "</b><br>";
446 if ( !(value = jobTitle()).isEmpty() ) 445 if ( !(value = jobTitle()).isEmpty() )
447 text += Qtopia::escapeString(value) + "<br>"; 446 text += Qtopia::escapeString(value) + "<br>";
448 447
449 comp = company(); 448 comp = company();
450 if ( !(value = department()).isEmpty() ) { 449 if ( !(value = department()).isEmpty() ) {
451 text += Qtopia::escapeString(value); 450 text += Qtopia::escapeString(value);
452 if ( comp ) 451 if ( comp )
453 text += ", "; 452 text += ", ";
454 else 453 else
455 text += "<br>"; 454 text += "<br>";
456 } 455 }
457 if ( !comp.isEmpty() ) 456 if ( !comp.isEmpty() )
458 text += Qtopia::escapeString(comp) + "<br>"; 457 text += Qtopia::escapeString(comp) + "<br>";
459 458
460 // business address 459 // business address
461 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 460 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
462 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 461 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
463 text += "<br>"; 462 text += "<br>";
464 text += QObject::tr( "<b>Work Address:</b>" ); 463 text += QObject::tr( "<b>Work Address:</b>" );
465 text += "<br>"; 464 text += "<br>";
466 } 465 }
467 466
468 if ( !(value = businessStreet()).isEmpty() ) 467 if ( !(value = businessStreet()).isEmpty() )
469 text += Qtopia::escapeString(value) + "<br>"; 468 text += Qtopia::escapeString(value) + "<br>";
470 state = businessState(); 469 state = businessState();
471 if ( !(value = businessCity()).isEmpty() ) { 470 if ( !(value = businessCity()).isEmpty() ) {
472 text += Qtopia::escapeString(value); 471 text += Qtopia::escapeString(value);
473 if ( state ) 472 if ( state )
474 text += ", " + Qtopia::escapeString(state); 473 text += ", " + Qtopia::escapeString(state);
475 text += "<br>"; 474 text += "<br>";
476 } else if ( !state.isEmpty() ) 475 } else if ( !state.isEmpty() )
477 text += Qtopia::escapeString(state) + "<br>"; 476 text += Qtopia::escapeString(state) + "<br>";
478 if ( !(value = businessZip()).isEmpty() ) 477 if ( !(value = businessZip()).isEmpty() )
479 text += Qtopia::escapeString(value) + "<br>"; 478 text += Qtopia::escapeString(value) + "<br>";
480 if ( !(value = businessCountry()).isEmpty() ) 479 if ( !(value = businessCountry()).isEmpty() )
481 text += Qtopia::escapeString(value) + "<br>"; 480 text += Qtopia::escapeString(value) + "<br>";
482 481
483 // home address 482 // home address
484 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 483 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
485 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 484 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
486 text += "<br>"; 485 text += "<br>";
487 text += QObject::tr( "<b>Home Address:</b>" ); 486 text += QObject::tr( "<b>Home Address:</b>" );
488 text += "<br>"; 487 text += "<br>";
489 } 488 }
490 489
491 if ( !(value = homeStreet()).isEmpty() ) 490 if ( !(value = homeStreet()).isEmpty() )
492 text += Qtopia::escapeString(value) + "<br>"; 491 text += Qtopia::escapeString(value) + "<br>";
493 state = homeState(); 492 state = homeState();
494 if ( !(value = homeCity()).isEmpty() ) { 493 if ( !(value = homeCity()).isEmpty() ) {
495 text += Qtopia::escapeString(value); 494 text += Qtopia::escapeString(value);
496 if ( !state.isEmpty() ) 495 if ( !state.isEmpty() )
497 text += ", " + Qtopia::escapeString(state); 496 text += ", " + Qtopia::escapeString(state);
498 text += "<br>"; 497 text += "<br>";
499 } else if (!state.isEmpty()) 498 } else if (!state.isEmpty())
500 text += Qtopia::escapeString(state) + "<br>"; 499 text += Qtopia::escapeString(state) + "<br>";
501 if ( !(value = homeZip()).isEmpty() ) 500 if ( !(value = homeZip()).isEmpty() )
502 text += Qtopia::escapeString(value) + "<br>"; 501 text += Qtopia::escapeString(value) + "<br>";
503 if ( !(value = homeCountry()).isEmpty() ) 502 if ( !(value = homeCountry()).isEmpty() )
504 text += Qtopia::escapeString(value) + "<br>"; 503 text += Qtopia::escapeString(value) + "<br>";
505 504
506 // the others... 505 // the others...
507 QString str; 506 QString str;
508 str = emails(); 507 str = emails();
509 if ( !str.isEmpty() ) 508 if ( !str.isEmpty() )
510 text += "<b>" + QObject::tr("Email Addresses: ") + "</b>" 509 text += "<b>" + QObject::tr("Email Addresses: ") + "</b>"
511 + Qtopia::escapeString(str) + "<br>"; 510 + Qtopia::escapeString(str) + "<br>";
512 str = homePhone(); 511 str = homePhone();
513 if ( !str.isEmpty() ) 512 if ( !str.isEmpty() )
514 text += "<b>" + QObject::tr("Home Phone: ") + "</b>" 513 text += "<b>" + QObject::tr("Home Phone: ") + "</b>"
515 + Qtopia::escapeString(str) + "<br>"; 514 + Qtopia::escapeString(str) + "<br>";
516 str = homeFax(); 515 str = homeFax();
517 if ( !str.isEmpty() ) 516 if ( !str.isEmpty() )
518 text += "<b>" + QObject::tr("Home Fax: ") + "</b>" 517 text += "<b>" + QObject::tr("Home Fax: ") + "</b>"
519 + Qtopia::escapeString(str) + "<br>"; 518 + Qtopia::escapeString(str) + "<br>";
520 str = homeMobile(); 519 str = homeMobile();
521 if ( !str.isEmpty() ) 520 if ( !str.isEmpty() )
522 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" 521 text += "<b>" + QObject::tr("Home Mobile: ") + "</b>"
523 + Qtopia::escapeString(str) + "<br>"; 522 + Qtopia::escapeString(str) + "<br>";
524 str = homeWebpage(); 523 str = homeWebpage();
525 if ( !str.isEmpty() ) 524 if ( !str.isEmpty() )
526 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" 525 text += "<b>" + QObject::tr("Home Web Page: ") + "</b>"
527 + Qtopia::escapeString(str) + "<br>"; 526 + Qtopia::escapeString(str) + "<br>";
528 str = businessWebpage(); 527 str = businessWebpage();
529 if ( !str.isEmpty() ) 528 if ( !str.isEmpty() )
530 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" 529 text += "<b>" + QObject::tr("Business Web Page: ") + "</b>"
531 + Qtopia::escapeString(str) + "<br>"; 530 + Qtopia::escapeString(str) + "<br>";
532 str = office(); 531 str = office();
533 if ( !str.isEmpty() ) 532 if ( !str.isEmpty() )
534 text += "<b>" + QObject::tr("Office: ") + "</b>" 533 text += "<b>" + QObject::tr("Office: ") + "</b>"
535 + Qtopia::escapeString(str) + "<br>"; 534 + Qtopia::escapeString(str) + "<br>";
536 str = businessPhone(); 535 str = businessPhone();
537 if ( !str.isEmpty() ) 536 if ( !str.isEmpty() )
538 text += "<b>" + QObject::tr("Business Phone: ") + "</b>" 537 text += "<b>" + QObject::tr("Business Phone: ") + "</b>"
539 + Qtopia::escapeString(str) + "<br>"; 538 + Qtopia::escapeString(str) + "<br>";
540 str = businessFax(); 539 str = businessFax();
541 if ( !str.isEmpty() ) 540 if ( !str.isEmpty() )
542 text += "<b>" + QObject::tr("Business Fax: ") + "</b>" 541 text += "<b>" + QObject::tr("Business Fax: ") + "</b>"
543 + Qtopia::escapeString(str) + "<br>"; 542 + Qtopia::escapeString(str) + "<br>";
544 str = businessMobile(); 543 str = businessMobile();
545 if ( !str.isEmpty() ) 544 if ( !str.isEmpty() )
546 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" 545 text += "<b>" + QObject::tr("Business Mobile: ") + "</b>"
547 + Qtopia::escapeString(str) + "<br>"; 546 + Qtopia::escapeString(str) + "<br>";
548 str = businessPager(); 547 str = businessPager();
549 if ( !str.isEmpty() ) 548 if ( !str.isEmpty() )
550 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 549 text += "<b>" + QObject::tr("Business Pager: ") + "</b>"
551 + Qtopia::escapeString(str) + "<br>"; 550 + Qtopia::escapeString(str) + "<br>";
552 str = profession(); 551 str = profession();
553 if ( !str.isEmpty() ) 552 if ( !str.isEmpty() )
554 text += "<b>" + QObject::tr("Profession: ") + "</b>" 553 text += "<b>" + QObject::tr("Profession: ") + "</b>"
555 + Qtopia::escapeString(str) + "<br>"; 554 + Qtopia::escapeString(str) + "<br>";
556 str = assistant(); 555 str = assistant();
557 if ( !str.isEmpty() ) 556 if ( !str.isEmpty() )
558 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 557 text += "<b>" + QObject::tr("Assistant: ") + "</b>"
559 + Qtopia::escapeString(str) + "<br>"; 558 + Qtopia::escapeString(str) + "<br>";
560 str = manager(); 559 str = manager();
561 if ( !str.isEmpty() ) 560 if ( !str.isEmpty() )
562 text += "<b>" + QObject::tr("Manager: ") + "</b>" 561 text += "<b>" + QObject::tr("Manager: ") + "</b>"
563 + Qtopia::escapeString(str) + "<br>"; 562 + Qtopia::escapeString(str) + "<br>";
564 str = gender(); 563 str = gender();
565 if ( !str.isEmpty() && str.toInt() != 0 ) { 564 if ( !str.isEmpty() && str.toInt() != 0 ) {
566 if ( str.toInt() == 1 ) 565 if ( str.toInt() == 1 )
567 str = QObject::tr( "Male" ); 566 str = QObject::tr( "Male" );
568 else if ( str.toInt() == 2 ) 567 else if ( str.toInt() == 2 )
569 str = QObject::tr( "Female" ); 568 str = QObject::tr( "Female" );
570 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 569 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
571 } 570 }
572 str = spouse(); 571 str = spouse();
573 if ( !str.isEmpty() ) 572 if ( !str.isEmpty() )
574 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 573 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
575 + Qtopia::escapeString(str) + "<br>"; 574 + Qtopia::escapeString(str) + "<br>";
576 if ( birthday().isValid() ){ 575 if ( birthday().isValid() ){
577 str = TimeString::numberDateString( birthday() ); 576 str = TimeString::numberDateString( birthday() );
578 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 577 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
579 + Qtopia::escapeString(str) + "<br>"; 578 + Qtopia::escapeString(str) + "<br>";
580 } 579 }
581 if ( anniversary().isValid() ){ 580 if ( anniversary().isValid() ){
582 str = TimeString::numberDateString( anniversary() ); 581 str = TimeString::numberDateString( anniversary() );
583 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 582 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
584 + Qtopia::escapeString(str) + "<br>"; 583 + Qtopia::escapeString(str) + "<br>";
585 } 584 }
586 str = nickname(); 585 str = nickname();
587 if ( !str.isEmpty() ) 586 if ( !str.isEmpty() )
588 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 587 text += "<b>" + QObject::tr("Nickname: ") + "</b>"
589 + Qtopia::escapeString(str) + "<br>"; 588 + Qtopia::escapeString(str) + "<br>";
590 589
591 // notes last 590 // notes last
592 if ( (value = notes()) ) { 591 if ( (value = notes()) ) {
593 QRegExp reg("\n"); 592 QRegExp reg("\n");
594 593
595 //QString tmp = Qtopia::escapeString(value); 594 //QString tmp = Qtopia::escapeString(value);
596 QString tmp = QStyleSheet::convertFromPlainText(value); 595 QString tmp = QStyleSheet::convertFromPlainText(value);
597 //tmp.replace( reg, "<br>" ); 596 //tmp.replace( reg, "<br>" );
598 text += "<br>" + tmp + "<br>"; 597 text += "<br>" + tmp + "<br>";
599 } 598 }
600 return text; 599 return text;
601} 600}
602 601
603/*! 602/*!
604 \internal 603 \internal
605*/ 604*/
606void OContact::insert( int key, const QString &v ) 605void OContact::insert( int key, const QString &v )
607{ 606{
608 QString value = v.stripWhiteSpace(); 607 QString value = v.stripWhiteSpace();
609 if ( value.isEmpty() ) 608 if ( value.isEmpty() )
610 mMap.remove( key ); 609 mMap.remove( key );
611 else 610 else
612 mMap.insert( key, value ); 611 mMap.insert( key, value );
613} 612}
614 613
615/*! 614/*!
616 \internal 615 \internal
617*/ 616*/
618void OContact::replace( int key, const QString & v ) 617void OContact::replace( int key, const QString & v )
619{ 618{
620 QString value = v.stripWhiteSpace(); 619 QString value = v.stripWhiteSpace();
621 if ( value.isEmpty() ) 620 if ( value.isEmpty() )
622 mMap.remove( key ); 621 mMap.remove( key );
623 else 622 else
624 mMap.replace( key, value ); 623 mMap.replace( key, value );
625} 624}
626 625
627/*! 626/*!
628 \internal 627 \internal
629*/ 628*/
630QString OContact::find( int key ) const 629QString OContact::find( int key ) const
631{ 630{
632 return mMap[key]; 631 return mMap[key];
633} 632}
634 633
635/*! 634/*!
636 \internal 635 \internal
637*/ 636*/
638QString OContact::displayAddress( const QString &street, 637QString OContact::displayAddress( const QString &street,
639 const QString &city, 638 const QString &city,
640 const QString &state, 639 const QString &state,
641 const QString &zip, 640 const QString &zip,
642 const QString &country ) const 641 const QString &country ) const
643{ 642{
644 QString s = street; 643 QString s = street;
645 if ( !street.isEmpty() ) 644 if ( !street.isEmpty() )
646 s+= "\n"; 645 s+= "\n";
647 s += city; 646 s += city;
648 if ( !city.isEmpty() && !state.isEmpty() ) 647 if ( !city.isEmpty() && !state.isEmpty() )
649 s += ", "; 648 s += ", ";
650 s += state; 649 s += state;
651 if ( !state.isEmpty() && !zip.isEmpty() ) 650 if ( !state.isEmpty() && !zip.isEmpty() )
652 s += " "; 651 s += " ";
653 s += zip; 652 s += zip;
654 if ( !country.isEmpty() && !s.isEmpty() ) 653 if ( !country.isEmpty() && !s.isEmpty() )
655 s += "\n"; 654 s += "\n";
656 s += country; 655 s += country;
657 return s; 656 return s;
658} 657}
659 658
660/*! 659/*!
661 \internal 660 \internal
662*/ 661*/
663QString OContact::displayBusinessAddress() const 662QString OContact::displayBusinessAddress() const
664{ 663{
665 return displayAddress( businessStreet(), businessCity(), 664 return displayAddress( businessStreet(), businessCity(),
666 businessState(), businessZip(), 665 businessState(), businessZip(),
667 businessCountry() ); 666 businessCountry() );
668} 667}
669 668
670/*! 669/*!
671 \internal 670 \internal
672*/ 671*/
673QString OContact::displayHomeAddress() const 672QString OContact::displayHomeAddress() const
674{ 673{
675 return displayAddress( homeStreet(), homeCity(), 674 return displayAddress( homeStreet(), homeCity(),
676 homeState(), homeZip(), 675 homeState(), homeZip(),
677 homeCountry() ); 676 homeCountry() );
678} 677}
679 678
680/*! 679/*!
681 Returns the full name of the contact 680 Returns the full name of the contact
682*/ 681*/
683QString OContact::fullName() const 682QString OContact::fullName() const
684{ 683{
685 QString title = find( Qtopia::Title ); 684 QString title = find( Qtopia::Title );
686 QString firstName = find( Qtopia::FirstName ); 685 QString firstName = find( Qtopia::FirstName );
687 QString middleName = find( Qtopia::MiddleName ); 686 QString middleName = find( Qtopia::MiddleName );
688 QString lastName = find( Qtopia::LastName ); 687 QString lastName = find( Qtopia::LastName );
689 QString suffix = find( Qtopia::Suffix ); 688 QString suffix = find( Qtopia::Suffix );
690 689
691 QString name = title; 690 QString name = title;
692 if ( !firstName.isEmpty() ) { 691 if ( !firstName.isEmpty() ) {
693 if ( !name.isEmpty() ) 692 if ( !name.isEmpty() )
694 name += " "; 693 name += " ";
695 name += firstName; 694 name += firstName;
696 } 695 }
697 if ( !middleName.isEmpty() ) { 696 if ( !middleName.isEmpty() ) {
698 if ( !name.isEmpty() ) 697 if ( !name.isEmpty() )
699 name += " "; 698 name += " ";
700 name += middleName; 699 name += middleName;
701 } 700 }
702 if ( !lastName.isEmpty() ) { 701 if ( !lastName.isEmpty() ) {
703 if ( !name.isEmpty() ) 702 if ( !name.isEmpty() )
704 name += " "; 703 name += " ";
705 name += lastName; 704 name += lastName;
706 } 705 }
707 if ( !suffix.isEmpty() ) { 706 if ( !suffix.isEmpty() ) {
708 if ( !name.isEmpty() ) 707 if ( !name.isEmpty() )
709 name += " "; 708 name += " ";
710 name += suffix; 709 name += suffix;
711 } 710 }
712 return name.simplifyWhiteSpace(); 711 return name.simplifyWhiteSpace();
713} 712}
714 713
715/*! 714/*!
716 Returns a list of the names of the children of the contact. 715 Returns a list of the names of the children of the contact.
717*/ 716*/
718QStringList OContact::childrenList() const 717QStringList OContact::childrenList() const
719{ 718{
720 return QStringList::split( " ", find( Qtopia::Children ) ); 719 return QStringList::split( " ", find( Qtopia::Children ) );
721} 720}
722 721
723/*! \fn void OContact::insertEmail( const QString &email ) 722/*! \fn void OContact::insertEmail( const QString &email )
724 723
725 Insert \a email into the email list. Ensures \a email can only be added 724 Insert \a email into the email list. Ensures \a email can only be added
726 once. If there is no default email address set, it sets it to the \a email. 725 once. If there is no default email address set, it sets it to the \a email.
727*/ 726*/
728 727
729/*! \fn void OContact::removeEmail( const QString &email ) 728/*! \fn void OContact::removeEmail( const QString &email )
730 729
731 Removes the \a email from the email list. If the default email was \a email, 730 Removes the \a email from the email list. If the default email was \a email,
732 then the default email address is assigned to the first email in the 731 then the default email address is assigned to the first email in the
733 email list 732 email list
734*/ 733*/
735 734
736/*! \fn void OContact::clearEmails() 735/*! \fn void OContact::clearEmails()
737 736
738 Clears the email list. 737 Clears the email list.
739 */ 738 */
740 739
741/*! \fn void OContact::insertEmails( const QStringList &emailList ) 740/*! \fn void OContact::insertEmails( const QStringList &emailList )
742 741
743 Appends the \a emailList to the exiting email list 742 Appends the \a emailList to the exiting email list
744 */ 743 */
745 744
746/*! 745/*!
747 Returns a list of email addresses belonging to the contact, including 746 Returns a list of email addresses belonging to the contact, including
748 the default email address. 747 the default email address.
749*/ 748*/
750QStringList OContact::emailList() const 749QStringList OContact::emailList() const
751{ 750{
752 QString emailStr = emails(); 751 QString emailStr = emails();
753 752
754 QStringList r; 753 QStringList r;
755 if ( !emailStr.isEmpty() ) { 754 if ( !emailStr.isEmpty() ) {
756 qDebug(" emailstr "); 755 qDebug(" emailstr ");
757 QStringList l = QStringList::split( emailSeparator(), emailStr ); 756 QStringList l = QStringList::split( emailSeparator(), emailStr );
758 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 757 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
759 r += (*it).simplifyWhiteSpace(); 758 r += (*it).simplifyWhiteSpace();
760 } 759 }
761 760
762 return r; 761 return r;
763} 762}
764 763
765/*! 764/*!
766 \overload 765 \overload
767 766
768 Generates the string for the contact to be filed as from the first, 767 Generates the string for the contact to be filed as from the first,
769 middle and last name of the contact. 768 middle and last name of the contact.
770*/ 769*/
771void OContact::setFileAs() 770void OContact::setFileAs()
772{ 771{
773 QString lastName, firstName, middleName, fileas; 772 QString lastName, firstName, middleName, fileas;
774 773
775 lastName = find( Qtopia::LastName ); 774 lastName = find( Qtopia::LastName );
776 firstName = find( Qtopia::FirstName ); 775 firstName = find( Qtopia::FirstName );
777 middleName = find( Qtopia::MiddleName ); 776 middleName = find( Qtopia::MiddleName );
778 if ( !lastName.isEmpty() && !firstName.isEmpty() 777 if ( !lastName.isEmpty() && !firstName.isEmpty()
779 && !middleName.isEmpty() ) 778 && !middleName.isEmpty() )
780 fileas = lastName + ", " + firstName + " " + middleName; 779 fileas = lastName + ", " + firstName + " " + middleName;
781 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 780 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
782 fileas = lastName + ", " + firstName; 781 fileas = lastName + ", " + firstName;
783 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 782 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
784 !middleName.isEmpty() ) 783 !middleName.isEmpty() )
785 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 784 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
786 + middleName + ( middleName.isEmpty() ? "" : " " ) 785 + middleName + ( middleName.isEmpty() ? "" : " " )
787 + lastName; 786 + lastName;
788 787
789 replace( Qtopia::FileAs, fileas ); 788 replace( Qtopia::FileAs, fileas );
790} 789}
791 790
792/*! 791/*!
793 \internal 792 \internal
794 Appends the contact information to \a buf. 793 Appends the contact information to \a buf.
795*/ 794*/
796void OContact::save( QString &buf ) const 795void OContact::save( QString &buf ) const
797{ 796{
798 static const QStringList SLFIELDS = fields(); 797 static const QStringList SLFIELDS = fields();
799 // I'm expecting "<Contact " in front of this... 798 // I'm expecting "<Contact " in front of this...
800 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 799 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
801 it != mMap.end(); ++it ) { 800 it != mMap.end(); ++it ) {
802 const QString &value = it.data(); 801 const QString &value = it.data();
803 int key = it.key(); 802 int key = it.key();
804 if ( !value.isEmpty() ) { 803 if ( !value.isEmpty() ) {
805 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 804 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
806 continue; 805 continue;
807 806
808 key -= Qtopia::AddressCategory+1; 807 key -= Qtopia::AddressCategory+1;
809 buf += SLFIELDS[key]; 808 buf += SLFIELDS[key];
810 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 809 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
811 } 810 }
812 } 811 }
813 buf += customToXml(); 812 buf += customToXml();
814 if ( categories().count() > 0 ) 813 if ( categories().count() > 0 )
815 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 814 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
816 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 815 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
817 // You need to close this yourself 816 // You need to close this yourself
818} 817}
819 818
820/*! 819/*!
821 \internal 820 \internal
822 Returns the list of fields belonging to a contact 821 Returns the list of fields belonging to a contact
823*/ 822*/
824QStringList OContact::fields() 823QStringList OContact::fields()
825{ 824{
826 QStringList list; 825 QStringList list;
827 826
828 list.append( "Title" ); // Not Used! 827 list.append( "Title" ); // Not Used!
829 list.append( "FirstName" ); 828 list.append( "FirstName" );
830 list.append( "MiddleName" ); 829 list.append( "MiddleName" );
831 list.append( "LastName" ); 830 list.append( "LastName" );
832 list.append( "Suffix" ); 831 list.append( "Suffix" );
833 list.append( "FileAs" ); 832 list.append( "FileAs" );
834 833
835 list.append( "JobTitle" ); 834 list.append( "JobTitle" );
836 list.append( "Department" ); 835 list.append( "Department" );
837 list.append( "Company" ); 836 list.append( "Company" );
838 list.append( "BusinessPhone" ); 837 list.append( "BusinessPhone" );
839 list.append( "BusinessFax" ); 838 list.append( "BusinessFax" );
840 list.append( "BusinessMobile" ); 839 list.append( "BusinessMobile" );
841 840
842 list.append( "DefaultEmail" ); 841 list.append( "DefaultEmail" );
843 list.append( "Emails" ); 842 list.append( "Emails" );
844 843
845 list.append( "HomePhone" ); 844 list.append( "HomePhone" );
846 list.append( "HomeFax" ); 845 list.append( "HomeFax" );
847 list.append( "HomeMobile" ); 846 list.append( "HomeMobile" );
848 847
849 list.append( "BusinessStreet" ); 848 list.append( "BusinessStreet" );
850 list.append( "BusinessCity" ); 849 list.append( "BusinessCity" );
851 list.append( "BusinessState" ); 850 list.append( "BusinessState" );
852 list.append( "BusinessZip" ); 851 list.append( "BusinessZip" );
853 list.append( "BusinessCountry" ); 852 list.append( "BusinessCountry" );
854 list.append( "BusinessPager" ); 853 list.append( "BusinessPager" );
855 list.append( "BusinessWebPage" ); 854 list.append( "BusinessWebPage" );
856 855
857 list.append( "Office" ); 856 list.append( "Office" );
858 list.append( "Profession" ); 857 list.append( "Profession" );
859 list.append( "Assistant" ); 858 list.append( "Assistant" );
860 list.append( "Manager" ); 859 list.append( "Manager" );
861 860
862 list.append( "HomeStreet" ); 861 list.append( "HomeStreet" );
863 list.append( "HomeCity" ); 862 list.append( "HomeCity" );
864 list.append( "HomeState" ); 863 list.append( "HomeState" );
865 list.append( "HomeZip" ); 864 list.append( "HomeZip" );
866 list.append( "HomeCountry" ); 865 list.append( "HomeCountry" );
867 list.append( "HomeWebPage" ); 866 list.append( "HomeWebPage" );
868 867
869 list.append( "Spouse" ); 868 list.append( "Spouse" );
870 list.append( "Gender" ); 869 list.append( "Gender" );
871 list.append( "Birthday" ); 870 list.append( "Birthday" );
872 list.append( "Anniversary" ); 871 list.append( "Anniversary" );
873 list.append( "Nickname" ); 872 list.append( "Nickname" );
874 list.append( "Children" ); 873 list.append( "Children" );
875 874
876 list.append( "Notes" ); 875 list.append( "Notes" );
877 list.append( "Groups" ); 876 list.append( "Groups" );
878 877
879 return list; 878 return list;
880} 879}
881 880
882/*! 881/*!
883 \internal 882 \internal
884 Returns a translated list of field names for a contact. 883 Returns a translated list of field names for a contact.
885*/ 884*/
886QStringList OContact::trfields() 885QStringList OContact::trfields()
887{ 886{
888 QStringList list; 887 QStringList list;
889 888
890 list.append( QObject::tr( "Name Title") ); 889 list.append( QObject::tr( "Name Title") );
891 list.append( QObject::tr( "First Name" ) ); 890 list.append( QObject::tr( "First Name" ) );
892 list.append( QObject::tr( "Middle Name" ) ); 891 list.append( QObject::tr( "Middle Name" ) );
893 list.append( QObject::tr( "Last Name" ) ); 892 list.append( QObject::tr( "Last Name" ) );
894 list.append( QObject::tr( "Suffix" ) ); 893 list.append( QObject::tr( "Suffix" ) );
895 list.append( QObject::tr( "File As" ) ); 894 list.append( QObject::tr( "File As" ) );
896 895
897 list.append( QObject::tr( "Job Title" ) ); 896 list.append( QObject::tr( "Job Title" ) );
898 list.append( QObject::tr( "Department" ) ); 897 list.append( QObject::tr( "Department" ) );
899 list.append( QObject::tr( "Company" ) ); 898 list.append( QObject::tr( "Company" ) );
900 list.append( QObject::tr( "Business Phone" ) ); 899 list.append( QObject::tr( "Business Phone" ) );
901 list.append( QObject::tr( "Business Fax" ) ); 900 list.append( QObject::tr( "Business Fax" ) );
902 list.append( QObject::tr( "Business Mobile" ) ); 901 list.append( QObject::tr( "Business Mobile" ) );
903 902
904 list.append( QObject::tr( "Default Email" ) ); 903 list.append( QObject::tr( "Default Email" ) );
905 list.append( QObject::tr( "Emails" ) ); 904 list.append( QObject::tr( "Emails" ) );
906 905
907 list.append( QObject::tr( "Home Phone" ) ); 906 list.append( QObject::tr( "Home Phone" ) );
908 list.append( QObject::tr( "Home Fax" ) ); 907 list.append( QObject::tr( "Home Fax" ) );
909 list.append( QObject::tr( "Home Mobile" ) ); 908 list.append( QObject::tr( "Home Mobile" ) );
910 909
911 list.append( QObject::tr( "Business Street" ) ); 910 list.append( QObject::tr( "Business Street" ) );
912 list.append( QObject::tr( "Business City" ) ); 911 list.append( QObject::tr( "Business City" ) );
913 list.append( QObject::tr( "Business State" ) ); 912 list.append( QObject::tr( "Business State" ) );
914 list.append( QObject::tr( "Business Zip" ) ); 913 list.append( QObject::tr( "Business Zip" ) );
915 list.append( QObject::tr( "Business Country" ) ); 914 list.append( QObject::tr( "Business Country" ) );
916 list.append( QObject::tr( "Business Pager" ) ); 915 list.append( QObject::tr( "Business Pager" ) );
917 list.append( QObject::tr( "Business WebPage" ) ); 916 list.append( QObject::tr( "Business WebPage" ) );
918 917
919 list.append( QObject::tr( "Office" ) ); 918 list.append( QObject::tr( "Office" ) );
920 list.append( QObject::tr( "Profession" ) ); 919 list.append( QObject::tr( "Profession" ) );
921 list.append( QObject::tr( "Assistant" ) ); 920 list.append( QObject::tr( "Assistant" ) );
922 list.append( QObject::tr( "Manager" ) ); 921 list.append( QObject::tr( "Manager" ) );
923 922
924 list.append( QObject::tr( "Home Street" ) ); 923 list.append( QObject::tr( "Home Street" ) );
925 list.append( QObject::tr( "Home City" ) ); 924 list.append( QObject::tr( "Home City" ) );
926 list.append( QObject::tr( "Home State" ) ); 925 list.append( QObject::tr( "Home State" ) );
927 list.append( QObject::tr( "Home Zip" ) ); 926 list.append( QObject::tr( "Home Zip" ) );
928 list.append( QObject::tr( "Home Country" ) ); 927 list.append( QObject::tr( "Home Country" ) );
929 list.append( QObject::tr( "Home Web Page" ) ); 928 list.append( QObject::tr( "Home Web Page" ) );
930 929
931 list.append( QObject::tr( "Spouse" ) ); 930 list.append( QObject::tr( "Spouse" ) );
932 list.append( QObject::tr( "Gender" ) ); 931 list.append( QObject::tr( "Gender" ) );
933 list.append( QObject::tr( "Birthday" ) ); 932 list.append( QObject::tr( "Birthday" ) );
934 list.append( QObject::tr( "Anniversary" ) ); 933 list.append( QObject::tr( "Anniversary" ) );
935 list.append( QObject::tr( "Nickname" ) ); 934 list.append( QObject::tr( "Nickname" ) );
936 list.append( QObject::tr( "Children" ) ); 935 list.append( QObject::tr( "Children" ) );
937 936
938 list.append( QObject::tr( "Notes" ) ); 937 list.append( QObject::tr( "Notes" ) );
939 list.append( QObject::tr( "Groups" ) ); 938 list.append( QObject::tr( "Groups" ) );
940 939
941 return list; 940 return list;
942} 941}
943 942
944/*! 943/*!
945 \internal 944 \internal
946 Returns an untranslated list of field names for a contact. 945 Returns an untranslated list of field names for a contact.
947*/ 946*/
948QStringList OContact::untrfields() 947QStringList OContact::untrfields()
949{ 948{
950 QStringList list; 949 QStringList list;
951 950
952 list.append( "Name Title" ); 951 list.append( "Name Title" );
953 list.append( "First Name" ); 952 list.append( "First Name" );
954 list.append( "Middle Name" ); 953 list.append( "Middle Name" );
955 list.append( "Last Name" ); 954 list.append( "Last Name" );
956 list.append( "Suffix" ); 955 list.append( "Suffix" );
957 list.append( "File As" ); 956 list.append( "File As" );
958 957
959 list.append( "Job Title" ); 958 list.append( "Job Title" );
960 list.append( "Department" ); 959 list.append( "Department" );
961 list.append( "Company" ); 960 list.append( "Company" );
962 list.append( "Business Phone" ); 961 list.append( "Business Phone" );
963 list.append( "Business Fax" ); 962 list.append( "Business Fax" );
964 list.append( "Business Mobile" ); 963 list.append( "Business Mobile" );
965 964
966 list.append( "Default Email" ); 965 list.append( "Default Email" );
967 list.append( "Emails" ); 966 list.append( "Emails" );
968 967
969 list.append( "Home Phone" ); 968 list.append( "Home Phone" );
970 list.append( "Home Fax" ); 969 list.append( "Home Fax" );
971 list.append( "Home Mobile" ); 970 list.append( "Home Mobile" );
972 971
973 list.append( "Business Street" ); 972 list.append( "Business Street" );
974 list.append( "Business City" ); 973 list.append( "Business City" );
975 list.append( "Business State" ); 974 list.append( "Business State" );
976 list.append( "Business Zip" ); 975 list.append( "Business Zip" );
977 list.append( "Business Country" ); 976 list.append( "Business Country" );
978 list.append( "Business Pager" ); 977 list.append( "Business Pager" );
979 list.append( "Business WebPage" ); 978 list.append( "Business WebPage" );
980 979
981 list.append( "Office" ); 980 list.append( "Office" );
982 list.append( "Profession" ); 981 list.append( "Profession" );
983 list.append( "Assistant" ); 982 list.append( "Assistant" );
984 list.append( "Manager" ); 983 list.append( "Manager" );
985 984
986 list.append( "Home Street" ); 985 list.append( "Home Street" );
987 list.append( "Home City" ); 986 list.append( "Home City" );
988 list.append( "Home State" ); 987 list.append( "Home State" );
989 list.append( "Home Zip" ); 988 list.append( "Home Zip" );
990 list.append( "Home Country" ); 989 list.append( "Home Country" );
991 list.append( "Home Web Page" ); 990 list.append( "Home Web Page" );
992 991
993 list.append( "Spouse" ); 992 list.append( "Spouse" );
994 list.append( "Gender" ); 993 list.append( "Gender" );
995 list.append( "Birthday" ); 994 list.append( "Birthday" );
996 list.append( "Anniversary" ); 995 list.append( "Anniversary" );
997 list.append( "Nickname" ); 996 list.append( "Nickname" );
998 list.append( "Children" ); 997 list.append( "Children" );
999 998
1000 list.append( "Notes" ); 999 list.append( "Notes" );
1001 list.append( "Groups" ); 1000 list.append( "Groups" );
1002 1001
1003 return list; 1002 return list;
1004} 1003}
1005 1004
1006/*! 1005/*!
1007 Sets the list of email address for contact to those contained in \a str. 1006 Sets the list of email address for contact to those contained in \a str.
1008 Email address should be separated by ';'s. 1007 Email address should be separated by ';'s.
1009*/ 1008*/
1010void OContact::setEmails( const QString &str ) 1009void OContact::setEmails( const QString &str )
1011{ 1010{
1012 replace( Qtopia::Emails, str ); 1011 replace( Qtopia::Emails, str );
1013 if ( str.isEmpty() ) 1012 if ( str.isEmpty() )
1014 setDefaultEmail( QString::null ); 1013 setDefaultEmail( QString::null );
1015} 1014}
1016 1015
1017/*! 1016/*!
1018 Sets the list of children for the contact to those contained in \a str. 1017 Sets the list of children for the contact to those contained in \a str.
1019*/ 1018*/
1020void OContact::setChildren( const QString &str ) 1019void OContact::setChildren( const QString &str )
1021{ 1020{
1022 replace( Qtopia::Children, str ); 1021 replace( Qtopia::Children, str );
1023} 1022}
1024 1023
1025// vcard conversion code 1024// vcard conversion code
1026/*! 1025/*!
1027 \internal 1026 \internal
1028*/ 1027*/
1029static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 1028static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
1030{ 1029{
1031 VObject *ret = 0; 1030 VObject *ret = 0;
1032 if ( o && !value.isEmpty() ) 1031 if ( o && !value.isEmpty() )
1033 ret = addPropValue( o, prop, value.latin1() ); 1032 ret = addPropValue( o, prop, value.latin1() );
1034 return ret; 1033 return ret;
1035} 1034}
1036 1035
1037/*! 1036/*!
1038 \internal 1037 \internal
1039*/ 1038*/
1040static inline VObject *safeAddProp( VObject *o, const char *prop) 1039static inline VObject *safeAddProp( VObject *o, const char *prop)
1041{ 1040{
1042 VObject *ret = 0; 1041 VObject *ret = 0;
1043 if ( o ) 1042 if ( o )
1044 ret = addProp( o, prop ); 1043 ret = addProp( o, prop );
1045 return ret; 1044 return ret;
1046} 1045}
1047 1046
1048/*! 1047/*!
1049 \internal 1048 \internal
1050*/ 1049*/
1051static VObject *createVObject( const OContact &c ) 1050static VObject *createVObject( const OContact &c )
1052{ 1051{
1053 VObject *vcard = newVObject( VCCardProp ); 1052 VObject *vcard = newVObject( VCCardProp );
1054 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 1053 safeAddPropValue( vcard, VCVersionProp, "2.1" );
1055 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 1054 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
1056 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 1055 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
1057 1056
1058 // full name 1057 // full name
1059 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 1058 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
1060 1059
1061 // name properties 1060 // name properties
1062 VObject *name = safeAddProp( vcard, VCNameProp ); 1061 VObject *name = safeAddProp( vcard, VCNameProp );
1063 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 1062 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
1064 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 1063 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
1065 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 1064 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
1066 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 1065 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
1067 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 1066 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
1068 1067
1069 // home properties 1068 // home properties
1070 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 1069 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
1071 safeAddProp( home_adr, VCHomeProp ); 1070 safeAddProp( home_adr, VCHomeProp );
1072 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 1071 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
1073 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 1072 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
1074 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 1073 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
1075 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 1074 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
1076 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 1075 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
1077 1076
1078 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 1077 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
1079 safeAddProp( home_phone, VCHomeProp ); 1078 safeAddProp( home_phone, VCHomeProp );
1080 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 1079 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
1081 safeAddProp( home_phone, VCHomeProp ); 1080 safeAddProp( home_phone, VCHomeProp );
1082 safeAddProp( home_phone, VCCellularProp ); 1081 safeAddProp( home_phone, VCCellularProp );
1083 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 1082 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
1084 safeAddProp( home_phone, VCHomeProp ); 1083 safeAddProp( home_phone, VCHomeProp );
1085 safeAddProp( home_phone, VCFaxProp ); 1084 safeAddProp( home_phone, VCFaxProp );
1086 1085
1087 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 1086 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
1088 safeAddProp( url, VCHomeProp ); 1087 safeAddProp( url, VCHomeProp );
1089 1088
1090 // work properties 1089 // work properties
1091 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 1090 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
1092 safeAddProp( work_adr, VCWorkProp ); 1091 safeAddProp( work_adr, VCWorkProp );
1093 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 1092 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
1094 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 1093 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
1095 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 1094 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
1096 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 1095 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
1097 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 1096 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
1098 1097
1099 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 1098 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
1100 safeAddProp( work_phone, VCWorkProp ); 1099 safeAddProp( work_phone, VCWorkProp );
1101 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 1100 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
1102 safeAddProp( work_phone, VCWorkProp ); 1101 safeAddProp( work_phone, VCWorkProp );
1103 safeAddProp( work_phone, VCCellularProp ); 1102 safeAddProp( work_phone, VCCellularProp );
1104 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 1103 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
1105 safeAddProp( work_phone, VCWorkProp ); 1104 safeAddProp( work_phone, VCWorkProp );
1106 safeAddProp( work_phone, VCFaxProp ); 1105 safeAddProp( work_phone, VCFaxProp );
1107 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 1106 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
1108 safeAddProp( work_phone, VCWorkProp ); 1107 safeAddProp( work_phone, VCWorkProp );
1109 safeAddProp( work_phone, VCPagerProp ); 1108 safeAddProp( work_phone, VCPagerProp );
1110 1109
1111 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 1110 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
1112 safeAddProp( url, VCWorkProp ); 1111 safeAddProp( url, VCWorkProp );
1113 1112
1114 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 1113 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
1115 safeAddProp( title, VCWorkProp ); 1114 safeAddProp( title, VCWorkProp );
1116 1115
1117 1116
1118 QStringList emails = c.emailList(); 1117 QStringList emails = c.emailList();
1119 emails.prepend( c.defaultEmail() ); 1118 emails.prepend( c.defaultEmail() );
1120 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 1119 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
1121 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 1120 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
1122 safeAddProp( email, VCInternetProp ); 1121 safeAddProp( email, VCInternetProp );
1123 } 1122 }
1124 1123
1125 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1124 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1126 1125
1127 // Exporting Birthday regarding RFC 2425 (5.8.4) 1126 // Exporting Birthday regarding RFC 2425 (5.8.4)
1128 if ( c.birthday().isValid() ){ 1127 if ( c.birthday().isValid() ){
1129 QString birthd_rfc2425 = QString("%1-%2-%3") 1128 QString birthd_rfc2425 = QString("%1-%2-%3")
1130 .arg( c.birthday().year() ) 1129 .arg( c.birthday().year() )
1131 .arg( c.birthday().month(), 2 ) 1130 .arg( c.birthday().month(), 2 )
1132 .arg( c.birthday().day(), 2 ); 1131 .arg( c.birthday().day(), 2 );
1133 // Now replace spaces with "0"... 1132 // Now replace spaces with "0"...
1134 int pos = 0; 1133 int pos = 0;
1135 while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) 1134 while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
1136 birthd_rfc2425.replace( pos, 1, "0" ); 1135 birthd_rfc2425.replace( pos, 1, "0" );
1137 1136
1138 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); 1137 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
1139 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); 1138 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
1140 } 1139 }
1141 1140
1142 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1141 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1143 VObject *org = safeAddProp( vcard, VCOrgProp ); 1142 VObject *org = safeAddProp( vcard, VCOrgProp );
1144 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1143 safeAddPropValue( org, VCOrgNameProp, c.company() );
1145 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1144 safeAddPropValue( org, VCOrgUnitProp, c.department() );
1146 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 1145 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
1147 } 1146 }
1148 1147
1149 // some values we have to export as custom fields 1148 // some values we have to export as custom fields
1150 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 1149 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
1151 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 1150 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
1152 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 1151 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
1153 1152
1154 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 1153 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
1155 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 1154 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
1156 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); 1155 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
1157 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 1156 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
1158 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 1157 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
1159 1158
1160 return vcard; 1159 return vcard;
1161} 1160}
1162 1161
1163 1162
1164/*! 1163/*!
1165 \internal 1164 \internal
1166*/ 1165*/
1167static QDate convVCardDateToDate( const QString& datestr ) 1166static QDate convVCardDateToDate( const QString& datestr )
1168{ 1167{
1169 int monthPos = datestr.find('-'); 1168 int monthPos = datestr.find('-');
1170 int dayPos = datestr.find('-', monthPos+1 ); 1169 int dayPos = datestr.find('-', monthPos+1 );
1171 int sep_ignore = 1; 1170 int sep_ignore = 1;
1172 if ( monthPos == -1 || dayPos == -1 ) { 1171 if ( monthPos == -1 || dayPos == -1 ) {
1173 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 1172 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1174 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 1173 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
1175 if ( datestr.length() == 8 ){ 1174 if ( datestr.length() == 8 ){
1176 monthPos = 4; 1175 monthPos = 4;
1177 dayPos = 6; 1176 dayPos = 6;
1178 sep_ignore = 0; 1177 sep_ignore = 0;
1179 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 1178 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1180 } else { 1179 } else {
1181 return QDate(); 1180 return QDate();
1182 } 1181 }
1183 } 1182 }
1184 int y = datestr.left( monthPos ).toInt(); 1183 int y = datestr.left( monthPos ).toInt();
1185 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 1184 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
1186 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 1185 int d = datestr.mid( dayPos + sep_ignore ).toInt();
1187 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 1186 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
1188 QDate date ( y,m,d ); 1187 QDate date ( y,m,d );
1189 return date; 1188 return date;
1190} 1189}
1191 1190
1192static OContact parseVObject( VObject *obj ) 1191static OContact parseVObject( VObject *obj )
1193{ 1192{
1194 OContact c; 1193 OContact c;
1195 1194
1196 VObjectIterator it; 1195 VObjectIterator it;
1197 initPropIterator( &it, obj ); 1196 initPropIterator( &it, obj );
1198 while( moreIteration( &it ) ) { 1197 while( moreIteration( &it ) ) {
1199 VObject *o = nextVObject( &it ); 1198 VObject *o = nextVObject( &it );
1200 QCString name = vObjectName( o ); 1199 QCString name = vObjectName( o );
1201 QCString value = vObjectStringZValue( o ); 1200 QCString value = vObjectStringZValue( o );
1202 if ( name == VCNameProp ) { 1201 if ( name == VCNameProp ) {
1203 VObjectIterator nit; 1202 VObjectIterator nit;
1204 initPropIterator( &nit, o ); 1203 initPropIterator( &nit, o );
1205 while( moreIteration( &nit ) ) { 1204 while( moreIteration( &nit ) ) {
1206 VObject *o = nextVObject( &nit ); 1205 VObject *o = nextVObject( &nit );
1207 QCString name = vObjectTypeInfo( o ); 1206 QCString name = vObjectTypeInfo( o );
1208 QString value = vObjectStringZValue( o ); 1207 QString value = vObjectStringZValue( o );
1209 if ( name == VCNamePrefixesProp ) 1208 if ( name == VCNamePrefixesProp )
1210 c.setTitle( value ); 1209 c.setTitle( value );
1211 else if ( name == VCNameSuffixesProp ) 1210 else if ( name == VCNameSuffixesProp )
1212 c.setSuffix( value ); 1211 c.setSuffix( value );
1213 else if ( name == VCFamilyNameProp ) 1212 else if ( name == VCFamilyNameProp )
1214 c.setLastName( value ); 1213 c.setLastName( value );
1215 else if ( name == VCGivenNameProp ) 1214 else if ( name == VCGivenNameProp )
1216 c.setFirstName( value ); 1215 c.setFirstName( value );
1217 else if ( name == VCAdditionalNamesProp ) 1216 else if ( name == VCAdditionalNamesProp )
1218 c.setMiddleName( value ); 1217 c.setMiddleName( value );
1219 } 1218 }
1220 } 1219 }
1221 else if ( name == VCAdrProp ) { 1220 else if ( name == VCAdrProp ) {
1222 bool work = TRUE; // default address is work address 1221 bool work = TRUE; // default address is work address
1223 QString street; 1222 QString street;
1224 QString city; 1223 QString city;
1225 QString region; 1224 QString region;
1226 QString postal; 1225 QString postal;
1227 QString country; 1226 QString country;
1228 1227
1229 VObjectIterator nit; 1228 VObjectIterator nit;
1230 initPropIterator( &nit, o ); 1229 initPropIterator( &nit, o );
1231 while( moreIteration( &nit ) ) { 1230 while( moreIteration( &nit ) ) {
1232 VObject *o = nextVObject( &nit ); 1231 VObject *o = nextVObject( &nit );
1233 QCString name = vObjectName( o ); 1232 QCString name = vObjectName( o );
1234 QString value = vObjectStringZValue( o ); 1233 QString value = vObjectStringZValue( o );
1235 if ( name == VCHomeProp ) 1234 if ( name == VCHomeProp )
1236 work = FALSE; 1235 work = FALSE;
1237 else if ( name == VCWorkProp ) 1236 else if ( name == VCWorkProp )
1238 work = TRUE; 1237 work = TRUE;
1239 else if ( name == VCStreetAddressProp ) 1238 else if ( name == VCStreetAddressProp )
1240 street = value; 1239 street = value;
1241 else if ( name == VCCityProp ) 1240 else if ( name == VCCityProp )
1242 city = value; 1241 city = value;
1243 else if ( name == VCRegionProp ) 1242 else if ( name == VCRegionProp )
1244 region = value; 1243 region = value;
1245 else if ( name == VCPostalCodeProp ) 1244 else if ( name == VCPostalCodeProp )
1246 postal = value; 1245 postal = value;
1247 else if ( name == VCCountryNameProp ) 1246 else if ( name == VCCountryNameProp )
1248 country = value; 1247 country = value;
1249 } 1248 }
1250 if ( work ) { 1249 if ( work ) {
1251 c.setBusinessStreet( street ); 1250 c.setBusinessStreet( street );
1252 c.setBusinessCity( city ); 1251 c.setBusinessCity( city );
1253 c.setBusinessCountry( country ); 1252 c.setBusinessCountry( country );
1254 c.setBusinessZip( postal ); 1253 c.setBusinessZip( postal );
1255 c.setBusinessState( region ); 1254 c.setBusinessState( region );
1256 } else { 1255 } else {
1257 c.setHomeStreet( street ); 1256 c.setHomeStreet( street );
1258 c.setHomeCity( city ); 1257 c.setHomeCity( city );
1259 c.setHomeCountry( country ); 1258 c.setHomeCountry( country );
1260 c.setHomeZip( postal ); 1259 c.setHomeZip( postal );
1261 c.setHomeState( region ); 1260 c.setHomeState( region );
1262 } 1261 }
1263 } 1262 }
1264 else if ( name == VCTelephoneProp ) { 1263 else if ( name == VCTelephoneProp ) {
1265 enum { 1264 enum {
1266 HOME = 0x01, 1265 HOME = 0x01,
1267 WORK = 0x02, 1266 WORK = 0x02,
1268 VOICE = 0x04, 1267 VOICE = 0x04,
1269 CELL = 0x08, 1268 CELL = 0x08,
1270 FAX = 0x10, 1269 FAX = 0x10,
1271 PAGER = 0x20, 1270 PAGER = 0x20,
1272 UNKNOWN = 0x80 1271 UNKNOWN = 0x80
1273 }; 1272 };
1274 int type = 0; 1273 int type = 0;
1275 1274
1276 VObjectIterator nit; 1275 VObjectIterator nit;
1277 initPropIterator( &nit, o ); 1276 initPropIterator( &nit, o );
1278 while( moreIteration( &nit ) ) { 1277 while( moreIteration( &nit ) ) {
1279 VObject *o = nextVObject( &nit ); 1278 VObject *o = nextVObject( &nit );
1280 QCString name = vObjectTypeInfo( o ); 1279 QCString name = vObjectTypeInfo( o );
1281 if ( name == VCHomeProp ) 1280 if ( name == VCHomeProp )
1282 type |= HOME; 1281 type |= HOME;
1283 else if ( name == VCWorkProp ) 1282 else if ( name == VCWorkProp )
1284 type |= WORK; 1283 type |= WORK;
1285 else if ( name == VCVoiceProp ) 1284 else if ( name == VCVoiceProp )
1286 type |= VOICE; 1285 type |= VOICE;
1287 else if ( name == VCCellularProp ) 1286 else if ( name == VCCellularProp )
1288 type |= CELL; 1287 type |= CELL;
1289 else if ( name == VCFaxProp ) 1288 else if ( name == VCFaxProp )
1290 type |= FAX; 1289 type |= FAX;
1291 else if ( name == VCPagerProp ) 1290 else if ( name == VCPagerProp )
1292 type |= PAGER; 1291 type |= PAGER;
1293 else if ( name == VCPreferredProp ) 1292 else if ( name == VCPreferredProp )
1294 ; 1293 ;
1295 else 1294 else
1296 type |= UNKNOWN; 1295 type |= UNKNOWN;
1297 } 1296 }
1298 if ( (type & UNKNOWN) != UNKNOWN ) { 1297 if ( (type & UNKNOWN) != UNKNOWN ) {
1299 if ( ( type & (HOME|WORK) ) == 0 ) // default 1298 if ( ( type & (HOME|WORK) ) == 0 ) // default
1300 type |= HOME; 1299 type |= HOME;
1301 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 1300 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
1302 type |= VOICE; 1301 type |= VOICE;
1303 1302
1304 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 1303 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
1305 c.setHomePhone( value ); 1304 c.setHomePhone( value );
1306 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 1305 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
1307 c.setHomeFax( value ); 1306 c.setHomeFax( value );
1308 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 1307 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
1309 c.setHomeMobile( value ); 1308 c.setHomeMobile( value );
1310 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 1309 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
1311 c.setBusinessPhone( value ); 1310 c.setBusinessPhone( value );
1312 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 1311 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
1313 c.setBusinessFax( value ); 1312 c.setBusinessFax( value );
1314 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 1313 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
1315 c.setBusinessMobile( value ); 1314 c.setBusinessMobile( value );
1316 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 1315 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
1317 c.setBusinessPager( value ); 1316 c.setBusinessPager( value );
1318 } 1317 }
1319 } 1318 }
1320 else if ( name == VCEmailAddressProp ) { 1319 else if ( name == VCEmailAddressProp ) {
1321 QString email = vObjectStringZValue( o ); 1320 QString email = vObjectStringZValue( o );
1322 bool valid = TRUE; 1321 bool valid = TRUE;
1323 VObjectIterator nit; 1322 VObjectIterator nit;
1324 initPropIterator( &nit, o ); 1323 initPropIterator( &nit, o );
1325 while( moreIteration( &nit ) ) { 1324 while( moreIteration( &nit ) ) {
1326 VObject *o = nextVObject( &nit ); 1325 VObject *o = nextVObject( &nit );
1327 QCString name = vObjectTypeInfo( o ); 1326 QCString name = vObjectTypeInfo( o );
1328 if ( name != VCInternetProp && name != VCHomeProp && 1327 if ( name != VCInternetProp && name != VCHomeProp &&
1329 name != VCWorkProp && 1328 name != VCWorkProp &&
1330 name != VCPreferredProp ) 1329 name != VCPreferredProp )
1331 // ### preffered should map to default email 1330 // ### preffered should map to default email
1332 valid = FALSE; 1331 valid = FALSE;
1333 } 1332 }
1334 if ( valid ) { 1333 if ( valid ) {
1335 c.insertEmail( email ); 1334 c.insertEmail( email );
1336 } 1335 }
1337 } 1336 }
1338 else if ( name == VCURLProp ) { 1337 else if ( name == VCURLProp ) {
1339 VObjectIterator nit; 1338 VObjectIterator nit;
1340 initPropIterator( &nit, o ); 1339 initPropIterator( &nit, o );
1341 while( moreIteration( &nit ) ) { 1340 while( moreIteration( &nit ) ) {
1342 VObject *o = nextVObject( &nit ); 1341 VObject *o = nextVObject( &nit );
1343 QCString name = vObjectTypeInfo( o ); 1342 QCString name = vObjectTypeInfo( o );
1344 if ( name == VCHomeProp ) 1343 if ( name == VCHomeProp )
1345 c.setHomeWebpage( value ); 1344 c.setHomeWebpage( value );
1346 else if ( name == VCWorkProp ) 1345 else if ( name == VCWorkProp )
1347 c.setBusinessWebpage( value ); 1346 c.setBusinessWebpage( value );
1348 } 1347 }
1349 } 1348 }
1350 else if ( name == VCOrgProp ) { 1349 else if ( name == VCOrgProp ) {
1351 VObjectIterator nit; 1350 VObjectIterator nit;
1352 initPropIterator( &nit, o ); 1351 initPropIterator( &nit, o );
1353 while( moreIteration( &nit ) ) { 1352 while( moreIteration( &nit ) ) {
1354 VObject *o = nextVObject( &nit ); 1353 VObject *o = nextVObject( &nit );
1355 QCString name = vObjectName( o ); 1354 QCString name = vObjectName( o );
1356 QString value = vObjectStringZValue( o ); 1355 QString value = vObjectStringZValue( o );
1357 if ( name == VCOrgNameProp ) 1356 if ( name == VCOrgNameProp )
1358 c.setCompany( value ); 1357 c.setCompany( value );
1359 else if ( name == VCOrgUnitProp ) 1358 else if ( name == VCOrgUnitProp )
1360 c.setDepartment( value ); 1359 c.setDepartment( value );
1361 else if ( name == VCOrgUnit2Prop ) 1360 else if ( name == VCOrgUnit2Prop )
1362 c.setOffice( value ); 1361 c.setOffice( value );
1363 } 1362 }
1364 } 1363 }
1365 else if ( name == VCTitleProp ) { 1364 else if ( name == VCTitleProp ) {
1366 c.setJobTitle( value ); 1365 c.setJobTitle( value );
1367 } 1366 }
1368 else if ( name == "X-Qtopia-Profession" ) { 1367 else if ( name == "X-Qtopia-Profession" ) {
1369 c.setProfession( value ); 1368 c.setProfession( value );
1370 } 1369 }
1371 else if ( name == "X-Qtopia-Manager" ) { 1370 else if ( name == "X-Qtopia-Manager" ) {
1372 c.setManager( value ); 1371 c.setManager( value );
1373 } 1372 }
1374 else if ( name == "X-Qtopia-Assistant" ) { 1373 else if ( name == "X-Qtopia-Assistant" ) {
1375 c.setAssistant( value ); 1374 c.setAssistant( value );
1376 } 1375 }
1377 else if ( name == "X-Qtopia-Spouse" ) { 1376 else if ( name == "X-Qtopia-Spouse" ) {
1378 c.setSpouse( value ); 1377 c.setSpouse( value );
1379 } 1378 }
1380 else if ( name == "X-Qtopia-Gender" ) { 1379 else if ( name == "X-Qtopia-Gender" ) {
1381 c.setGender( value ); 1380 c.setGender( value );
1382 } 1381 }
1383 else if ( name == "X-Qtopia-Anniversary" ) { 1382 else if ( name == "X-Qtopia-Anniversary" ) {
1384 c.setAnniversary( TimeConversion::fromString( value ) ); 1383 c.setAnniversary( TimeConversion::fromString( value ) );
1385 } 1384 }
1386 else if ( name == "X-Qtopia-Nickname" ) { 1385 else if ( name == "X-Qtopia-Nickname" ) {
1387 c.setNickname( value ); 1386 c.setNickname( value );
1388 } 1387 }
1389 else if ( name == "X-Qtopia-Children" ) { 1388 else if ( name == "X-Qtopia-Children" ) {
1390 c.setChildren( value ); 1389 c.setChildren( value );
1391 } 1390 }
1392 else if ( name == VCBirthDateProp ) { 1391 else if ( name == VCBirthDateProp ) {
1393 // Reading Birthdate regarding RFC 2425 (5.8.4) 1392 // Reading Birthdate regarding RFC 2425 (5.8.4)
1394 c.setBirthday( convVCardDateToDate( value ) ); 1393 c.setBirthday( convVCardDateToDate( value ) );
1395 1394
1396 } 1395 }
1397 1396
1398#if 0 1397#if 0
1399 else { 1398 else {
1400 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1399 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1401 VObjectIterator nit; 1400 VObjectIterator nit;
1402 initPropIterator( &nit, o ); 1401 initPropIterator( &nit, o );
1403 while( moreIteration( &nit ) ) { 1402 while( moreIteration( &nit ) ) {
1404 VObject *o = nextVObject( &nit ); 1403 VObject *o = nextVObject( &nit );
1405 QCString name = vObjectName( o ); 1404 QCString name = vObjectName( o );
1406 QString value = vObjectStringZValue( o ); 1405 QString value = vObjectStringZValue( o );
1407 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 1406 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
1408 } 1407 }
1409 } 1408 }
1410#endif 1409#endif
1411 } 1410 }
1412 c.setFileAs(); 1411 c.setFileAs();
1413 return c; 1412 return c;
1414} 1413}
1415 1414
1416/*! 1415/*!
1417 Writes the list of \a contacts as a set of VCards to the file \a filename. 1416 Writes the list of \a contacts as a set of VCards to the file \a filename.
1418*/ 1417*/
1419void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) 1418void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts)
1420{ 1419{
1421 QFileDirect f( filename.utf8().data() ); 1420 QFileDirect f( filename.utf8().data() );
1422 if ( !f.open( IO_WriteOnly ) ) { 1421 if ( !f.open( IO_WriteOnly ) ) {
1423 qWarning("Unable to open vcard write"); 1422 qWarning("Unable to open vcard write");
1424 return; 1423 return;
1425 } 1424 }
1426 1425
1427 QValueList<OContact>::ConstIterator it; 1426 QValueList<OContact>::ConstIterator it;
1428 for( it = contacts.begin(); it != contacts.end(); ++it ) { 1427 for( it = contacts.begin(); it != contacts.end(); ++it ) {
1429 VObject *obj = createVObject( *it ); 1428 VObject *obj = createVObject( *it );
1430 writeVObject(f.directHandle() , obj ); 1429 writeVObject(f.directHandle() , obj );
1431 cleanVObject( obj ); 1430 cleanVObject( obj );
1432 } 1431 }
1433 cleanStrTbl(); 1432 cleanStrTbl();
1434} 1433}
1435 1434
1436/*! 1435/*!
1437 writes \a contact as a VCard to the file \a filename. 1436 writes \a contact as a VCard to the file \a filename.
1438*/ 1437*/
1439void OContact::writeVCard( const QString &filename, const OContact &contact) 1438void OContact::writeVCard( const QString &filename, const OContact &contact)
1440{ 1439{
1441 QFileDirect f( filename.utf8().data() ); 1440 QFileDirect f( filename.utf8().data() );
1442 if ( !f.open( IO_WriteOnly ) ) { 1441 if ( !f.open( IO_WriteOnly ) ) {
1443 qWarning("Unable to open vcard write"); 1442 qWarning("Unable to open vcard write");
1444 return; 1443 return;
1445 } 1444 }
1446 1445
1447 VObject *obj = createVObject( contact ); 1446 VObject *obj = createVObject( contact );
1448 writeVObject( f.directHandle() , obj ); 1447 writeVObject( f.directHandle() , obj );
1449 cleanVObject( obj ); 1448 cleanVObject( obj );
1450 1449
1451 cleanStrTbl(); 1450 cleanStrTbl();
1452} 1451}
1453 1452
1454/*! 1453/*!
1455 Returns the set of contacts read as VCards from the file \a filename. 1454 Returns the set of contacts read as VCards from the file \a filename.
1456*/ 1455*/
1457QValueList<OContact> OContact::readVCard( const QString &filename ) 1456QValueList<OContact> OContact::readVCard( const QString &filename )
1458{ 1457{
1459 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1458 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
1460 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1459 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1461 1460
1462 qDebug("vobject = %p", obj ); 1461 qDebug("vobject = %p", obj );
1463 1462
1464 QValueList<OContact> contacts; 1463 QValueList<OContact> contacts;
1465 1464
1466 while ( obj ) { 1465 while ( obj ) {
1467 OContact con = parseVObject( obj ); 1466 OContact con = parseVObject( obj );
1468 /* 1467 /*
1469 * if uid is 0 assign a new one 1468 * if uid is 0 assign a new one
1470 * this at least happens on 1469 * this at least happens on
1471 * Nokia6210 1470 * Nokia6210
1472 */ 1471 */
1473 if ( con.uid() == 0 ) 1472 if ( con.uid() == 0 ){
1474 con.setUid( 1 ); 1473 con.setUid( 1 );
1474 qWarning("assigned new uid %d",con.uid() );
1475 }
1475 1476
1476 contacts.append(con ); 1477 contacts.append(con );
1477 1478
1478 VObject *t = obj; 1479 VObject *t = obj;
1479 obj = nextVObjectInList(obj); 1480 obj = nextVObjectInList(obj);
1480 cleanVObject( t ); 1481 cleanVObject( t );
1481 } 1482 }
1482 1483
1483 return contacts; 1484 return contacts;
1484} 1485}
1485 1486
1486/*! 1487/*!
1487 Returns TRUE if the contact matches the regular expression \a regexp. 1488 Returns TRUE if the contact matches the regular expression \a regexp.
1488 Otherwise returns FALSE. 1489 Otherwise returns FALSE.
1489*/ 1490*/
1490bool OContact::match( const QString &regexp ) const 1491bool OContact::match( const QString &regexp ) const
1491{ 1492{
1492 return match(QRegExp(regexp)); 1493 return match(QRegExp(regexp));
1493} 1494}
1494 1495
1495/*! 1496/*!
1496 \overload 1497 \overload
1497 Returns TRUE if the contact matches the regular expression \a regexp. 1498 Returns TRUE if the contact matches the regular expression \a regexp.
1498 Otherwise returns FALSE. 1499 Otherwise returns FALSE.
1499*/ 1500*/
1500bool OContact::match( const QRegExp &r ) const 1501bool OContact::match( const QRegExp &r ) const
1501{ 1502{
1502 bool match; 1503 bool match;
1503 match = false; 1504 match = false;
1504 QMap<int, QString>::ConstIterator it; 1505 QMap<int, QString>::ConstIterator it;
1505 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 1506 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
1506 if ( (*it).find( r ) > -1 ) { 1507 if ( (*it).find( r ) > -1 ) {
1507 match = true; 1508 match = true;
1508 break; 1509 break;
1509 } 1510 }
1510 } 1511 }
1511 return match; 1512 return match;
1512} 1513}
1513 1514
1514 1515
1515QString OContact::toShortText() const 1516QString OContact::toShortText() const
1516{ 1517{
1517 return ( fullName() ); 1518 return ( fullName() );
1518} 1519}
1519QString OContact::type() const 1520QString OContact::type() const
1520{ 1521{
1521 return QString::fromLatin1( "OContact" ); 1522 return QString::fromLatin1( "OContact" );
1522} 1523}
1523 1524
1524// Definition is missing ! (se) 1525// Definition is missing ! (se)
1525QMap<QString,QString> OContact::toExtraMap() const 1526QMap<QString,QString> OContact::toExtraMap() const
1526{ 1527{
1527 qWarning ("Function not implemented: OContact::toExtraMap()"); 1528 qWarning ("Function not implemented: OContact::toExtraMap()");
1528 QMap <QString,QString> useless; 1529 QMap <QString,QString> useless;
1529 return useless; 1530 return useless;
1530} 1531}
1531 1532
1532class QString OContact::recordField( int pos ) const 1533class QString OContact::recordField( int pos ) const
1533{ 1534{
1534 QStringList SLFIELDS = fields(); // ?? why this ? (se) 1535 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1535 return SLFIELDS[pos]; 1536 return SLFIELDS[pos];
1536} 1537}
1537 1538
1538// In future releases, we should store birthday and anniversary 1539// In future releases, we should store birthday and anniversary
1539// internally as QDate instead of QString ! 1540// internally as QDate instead of QString !
1540// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1541// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1541 1542
1542/*! \fn void OContact::setBirthday( const QDate& date ) 1543/*! \fn void OContact::setBirthday( const QDate& date )
1543 Sets the birthday for the contact to \a date. 1544 Sets the birthday for the contact to \a date.
1544*/ 1545*/
1545void OContact::setBirthday( const QDate &v ) 1546void OContact::setBirthday( const QDate &v )
1546{ 1547{
1547 if ( ( !v.isNull() ) && ( v.isValid() ) ) 1548 if ( ( !v.isNull() ) && ( v.isValid() ) )
1548 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1549 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
1549 1550
1550} 1551}
1551 1552
1552 1553
1553/*! \fn void OContact::setAnniversary( const QDate &date ) 1554/*! \fn void OContact::setAnniversary( const QDate &date )
1554 Sets the anniversary of the contact to \a date. 1555 Sets the anniversary of the contact to \a date.
1555*/ 1556*/
1556void OContact::setAnniversary( const QDate &v ) 1557void OContact::setAnniversary( const QDate &v )
1557{ 1558{
1558 if ( ( !v.isNull() ) && ( v.isValid() ) ) 1559 if ( ( !v.isNull() ) && ( v.isValid() ) )
1559 replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); 1560 replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
1560} 1561}
1561 1562
1562/*! \fn QDate OContact::birthday() const 1563/*! \fn QDate OContact::birthday() const
1563 Returns the birthday of the contact. 1564 Returns the birthday of the contact.
1564*/ 1565*/
1565QDate OContact::birthday() const 1566QDate OContact::birthday() const
1566{ 1567{
1567 QString str = find( Qtopia::Birthday ); 1568 QString str = find( Qtopia::Birthday );
1568 qWarning ("Birthday %s", str.latin1() ); 1569 qWarning ("Birthday %s", str.latin1() );
1569 if ( !str.isEmpty() ) 1570 if ( !str.isEmpty() )
1570 return TimeConversion::fromString ( str ); 1571 return TimeConversion::fromString ( str );
1571 else 1572 else
1572 return QDate(); 1573 return QDate();
1573} 1574}
1574 1575
1575 1576
1576/*! \fn QDate OContact::anniversary() const 1577/*! \fn QDate OContact::anniversary() const
1577 Returns the anniversary of the contact. 1578 Returns the anniversary of the contact.
1578*/ 1579*/
1579QDate OContact::anniversary() const 1580QDate OContact::anniversary() const
1580{ 1581{
1581 QDate empty; 1582 QDate empty;
1582 QString str = find( Qtopia::Anniversary ); 1583 QString str = find( Qtopia::Anniversary );
1583 qWarning ("Anniversary %s", str.latin1() ); 1584 qWarning ("Anniversary %s", str.latin1() );
1584 if ( !str.isEmpty() ) 1585 if ( !str.isEmpty() )
1585 return TimeConversion::fromString ( str ); 1586 return TimeConversion::fromString ( str );
1586 else 1587 else
1587 return empty; 1588 return empty;
1588} 1589}
1589 1590
1590 1591
1591void OContact::insertEmail( const QString &v ) 1592void OContact::insertEmail( const QString &v )
1592{ 1593{
1593 //qDebug("insertEmail %s", v.latin1()); 1594 //qDebug("insertEmail %s", v.latin1());
1594 QString e = v.simplifyWhiteSpace(); 1595 QString e = v.simplifyWhiteSpace();
1595 QString def = defaultEmail(); 1596 QString def = defaultEmail();
1596 1597
1597 // if no default, set it as the default email and don't insert 1598 // if no default, set it as the default email and don't insert
1598 if ( def.isEmpty() ) { 1599 if ( def.isEmpty() ) {
1599 setDefaultEmail( e ); // will insert into the list for us 1600 setDefaultEmail( e ); // will insert into the list for us
1600 return; 1601 return;
1601 } 1602 }
1602 1603
1603 // otherwise, insert assuming doesn't already exist 1604 // otherwise, insert assuming doesn't already exist
1604 QString emailsStr = find( Qtopia::Emails ); 1605 QString emailsStr = find( Qtopia::Emails );
1605 if ( emailsStr.contains( e )) 1606 if ( emailsStr.contains( e ))
1606 return; 1607 return;
1607 if ( !emailsStr.isEmpty() ) 1608 if ( !emailsStr.isEmpty() )
1608 emailsStr += emailSeparator(); 1609 emailsStr += emailSeparator();
1609 emailsStr += e; 1610 emailsStr += e;
1610 replace( Qtopia::Emails, emailsStr ); 1611 replace( Qtopia::Emails, emailsStr );
1611} 1612}
1612 1613
1613void OContact::removeEmail( const QString &v ) 1614void OContact::removeEmail( const QString &v )
1614{ 1615{
1615 QString e = v.simplifyWhiteSpace(); 1616 QString e = v.simplifyWhiteSpace();
1616 QString def = defaultEmail(); 1617 QString def = defaultEmail();
1617 QString emailsStr = find( Qtopia::Emails ); 1618 QString emailsStr = find( Qtopia::Emails );
1618 QStringList emails = emailList(); 1619 QStringList emails = emailList();
1619 1620
1620 // otherwise, must first contain it 1621 // otherwise, must first contain it
1621 if ( !emailsStr.contains( e ) ) 1622 if ( !emailsStr.contains( e ) )
1622 return; 1623 return;
1623 1624
1624 // remove it 1625 // remove it
1625 //qDebug(" removing email from list %s", e.latin1()); 1626 //qDebug(" removing email from list %s", e.latin1());
1626 emails.remove( e ); 1627 emails.remove( e );
1627 // reset the string 1628 // reset the string
1628 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator 1629 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
1629 replace( Qtopia::Emails, emailsStr ); 1630 replace( Qtopia::Emails, emailsStr );
1630 1631
1631 // if default, then replace the default email with the first one 1632 // if default, then replace the default email with the first one
1632 if ( def == e ) { 1633 if ( def == e ) {
1633 //qDebug("removeEmail is default; setting new default"); 1634 //qDebug("removeEmail is default; setting new default");
1634 if ( !emails.count() ) 1635 if ( !emails.count() )
1635 clearEmails(); 1636 clearEmails();
1636 else // setDefaultEmail will remove e from the list 1637 else // setDefaultEmail will remove e from the list
1637 setDefaultEmail( emails.first() ); 1638 setDefaultEmail( emails.first() );
1638 } 1639 }
1639} 1640}
1640void OContact::clearEmails() 1641void OContact::clearEmails()
1641{ 1642{
1642 mMap.remove( Qtopia::DefaultEmail ); 1643 mMap.remove( Qtopia::DefaultEmail );
1643 mMap.remove( Qtopia::Emails ); 1644 mMap.remove( Qtopia::Emails );
1644} 1645}
1645void OContact::setDefaultEmail( const QString &v ) 1646void OContact::setDefaultEmail( const QString &v )
1646{ 1647{
1647 QString e = v.simplifyWhiteSpace(); 1648 QString e = v.simplifyWhiteSpace();
1648 1649
1649 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1650 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1650 replace( Qtopia::DefaultEmail, e ); 1651 replace( Qtopia::DefaultEmail, e );
1651 1652
1652 if ( !e.isEmpty() ) 1653 if ( !e.isEmpty() )
1653 insertEmail( e ); 1654 insertEmail( e );
1654 1655
1655} 1656}
1656 1657
1657void OContact::insertEmails( const QStringList &v ) 1658void OContact::insertEmails( const QStringList &v )
1658{ 1659{
1659 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1660 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1660 insertEmail( *it ); 1661 insertEmail( *it );
1661} 1662}
1662 1663
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 038a59f..81ac1c1 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,242 +1,238 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of the Qtopia Environment. 5** This file is part of the Qtopia Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#ifndef __OCONTACT_H__ 22#ifndef __OCONTACT_H__
23#define __OCONTACT_H__ 23#define __OCONTACT_H__
24 24
25#include <opie/opimrecord.h> 25#include <opie/opimrecord.h>
26#include <qpe/recordfields.h> 26#include <qpe/recordfields.h>
27 27
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30 30
31#if defined(QPC_TEMPLATEDLL) 31#if defined(QPC_TEMPLATEDLL)
32// MOC_SKIP_BEGIN 32// MOC_SKIP_BEGIN
33QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 33QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
34// MOC_SKIP_END 34// MOC_SKIP_END
35#endif 35#endif
36 36
37class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) 37class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
38class QPC_EXPORT OContact : public OPimRecord 38class QPC_EXPORT OContact : public OPimRecord
39{ 39{
40 friend class DataSet; 40 friend class DataSet;
41public: 41public:
42 OContact(); 42 OContact();
43 OContact( const QMap<int, QString> &fromMap ); 43 OContact( const QMap<int, QString> &fromMap );
44 virtual ~OContact(); 44 virtual ~OContact();
45 45
46 static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); 46 static void writeVCard( const QString &filename, const QValueList<OContact> &contacts);
47 static void writeVCard( const QString &filename, const OContact &c ); 47 static void writeVCard( const QString &filename, const OContact &c );
48 static QValueList<OContact> readVCard( const QString &filename ); 48 static QValueList<OContact> readVCard( const QString &filename );
49 49
50 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 50 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
51 51
52 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 52 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
53 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 53 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
54 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 54 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
55 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 55 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
56 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 56 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
57 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 57 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
58 void setFileAs(); 58 void setFileAs();
59 59
60 // default email address 60 // default email address
61 void setDefaultEmail( const QString &v ); 61 void setDefaultEmail( const QString &v );
62 // inserts email to list and ensure's doesn't already exist 62 // inserts email to list and ensure's doesn't already exist
63 void insertEmail( const QString &v ); 63 void insertEmail( const QString &v );
64 void removeEmail( const QString &v ); 64 void removeEmail( const QString &v );
65 void clearEmails(); 65 void clearEmails();
66 void insertEmails( const QStringList &v ); 66 void insertEmails( const QStringList &v );
67 67
68 // home 68 // home
69 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 69 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
70 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 70 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
71 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 71 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
72 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 72 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
73 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 73 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
74 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 74 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
75 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 75 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
76 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 76 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
77 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 77 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
78 78
79 // business 79 // business
80 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 80 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
81 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 81 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
82 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 82 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
83 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 83 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
84 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 84 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
85 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 85 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
86 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 86 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
87 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 87 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
88 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 88 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
89 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 89 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
90 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 90 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
91 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 91 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
92 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 92 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
93 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 93 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
94 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 94 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
95 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 95 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
96 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 96 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
97 97
98 // personal 98 // personal
99 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 99 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
100 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 100 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
101 void setBirthday( const QDate &v ); 101 void setBirthday( const QDate &v );
102 void setAnniversary( const QDate &v ); 102 void setAnniversary( const QDate &v );
103 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 103 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
104 void setChildren( const QString &v ); 104 void setChildren( const QString &v );
105 105
106 // other 106 // other
107 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 107 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
108 108
109 bool match( const QString &regexp ) const; 109 bool match( const QString &regexp ) const;
110 bool match( const QRegExp &regexp ) const; 110 bool match( const QRegExp &regexp ) const;
111 111
112// // custom 112// // custom
113// void setCustomField( const QString &key, const QString &v ) 113// void setCustomField( const QString &key, const QString &v )
114// { replace(Custom- + key, v ); } 114// { replace(Custom- + key, v ); }
115 115
116 // name 116 // name
117 QString fullName() const; 117 QString fullName() const;
118 QString title() const { return find( Qtopia::Title ); } 118 QString title() const { return find( Qtopia::Title ); }
119 QString firstName() const { return find( Qtopia::FirstName ); } 119 QString firstName() const { return find( Qtopia::FirstName ); }
120 QString middleName() const { return find( Qtopia::MiddleName ); } 120 QString middleName() const { return find( Qtopia::MiddleName ); }
121 QString lastName() const { return find( Qtopia::LastName ); } 121 QString lastName() const { return find( Qtopia::LastName ); }
122 QString suffix() const { return find( Qtopia::Suffix ); } 122 QString suffix() const { return find( Qtopia::Suffix ); }
123 QString fileAs() const { return find( Qtopia::FileAs ); } 123 QString fileAs() const { return find( Qtopia::FileAs ); }
124 124
125 // email 125 // email
126 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 126 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
127 QStringList emailList() const; 127 QStringList emailList() const;
128 128
129 // home 129 // home
130 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 130 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
131 QString homeCity() const { return find( Qtopia::HomeCity ); } 131 QString homeCity() const { return find( Qtopia::HomeCity ); }
132 QString homeState() const { return find( Qtopia::HomeState ); } 132 QString homeState() const { return find( Qtopia::HomeState ); }
133 QString homeZip() const { return find( Qtopia::HomeZip ); } 133 QString homeZip() const { return find( Qtopia::HomeZip ); }
134 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 134 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
135 QString homePhone() const { return find( Qtopia::HomePhone ); } 135 QString homePhone() const { return find( Qtopia::HomePhone ); }
136 QString homeFax() const { return find( Qtopia::HomeFax ); } 136 QString homeFax() const { return find( Qtopia::HomeFax ); }
137 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 137 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
138 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 138 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
139 /** Multi line string containing all non-empty address info in the form 139 /** Multi line string containing all non-empty address info in the form
140 * Street 140 * Street
141 * City, State Zip 141 * City, State Zip
142 * Country 142 * Country
143 */ 143 */
144 QString displayHomeAddress() const; 144 QString displayHomeAddress() const;
145 145
146 // business 146 // business
147 QString company() const { return find( Qtopia::Company ); } 147 QString company() const { return find( Qtopia::Company ); }
148 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 148 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
149 QString businessCity() const { return find( Qtopia::BusinessCity ); } 149 QString businessCity() const { return find( Qtopia::BusinessCity ); }
150 QString businessState() const { return find( Qtopia::BusinessState ); } 150 QString businessState() const { return find( Qtopia::BusinessState ); }
151 QString businessZip() const { return find( Qtopia::BusinessZip ); } 151 QString businessZip() const { return find( Qtopia::BusinessZip ); }
152 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 152 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
153 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 153 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
154 QString jobTitle() const { return find( Qtopia::JobTitle ); } 154 QString jobTitle() const { return find( Qtopia::JobTitle ); }
155 QString department() const { return find( Qtopia::Department ); } 155 QString department() const { return find( Qtopia::Department ); }
156 QString office() const { return find( Qtopia::Office ); } 156 QString office() const { return find( Qtopia::Office ); }
157 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 157 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
158 QString businessFax() const { return find( Qtopia::BusinessFax ); } 158 QString businessFax() const { return find( Qtopia::BusinessFax ); }
159 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 159 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
160 QString businessPager() const { return find( Qtopia::BusinessPager ); } 160 QString businessPager() const { return find( Qtopia::BusinessPager ); }
161 QString profession() const { return find( Qtopia::Profession ); } 161 QString profession() const { return find( Qtopia::Profession ); }
162 QString assistant() const { return find( Qtopia::Assistant ); } 162 QString assistant() const { return find( Qtopia::Assistant ); }
163 QString manager() const { return find( Qtopia::Manager ); } 163 QString manager() const { return find( Qtopia::Manager ); }
164 /** Multi line string containing all non-empty address info in the form 164 /** Multi line string containing all non-empty address info in the form
165 * Street 165 * Street
166 * City, State Zip 166 * City, State Zip
167 * Country 167 * Country
168 */ 168 */
169 QString displayBusinessAddress() const; 169 QString displayBusinessAddress() const;
170 170
171 //personal 171 //personal
172 QString spouse() const { return find( Qtopia::Spouse ); } 172 QString spouse() const { return find( Qtopia::Spouse ); }
173 QString gender() const { return find( Qtopia::Gender ); } 173 QString gender() const { return find( Qtopia::Gender ); }
174 QDate birthday() const; 174 QDate birthday() const;
175 QDate anniversary() const; 175 QDate anniversary() const;
176 QString nickname() const { return find( Qtopia::Nickname ); } 176 QString nickname() const { return find( Qtopia::Nickname ); }
177 QString children() const { return find( Qtopia::Children ); } 177 QString children() const { return find( Qtopia::Children ); }
178 QStringList childrenList() const; 178 QStringList childrenList() const;
179 179
180 // other 180 // other
181 QString notes() const { return find( Qtopia::Notes ); } 181 QString notes() const { return find( Qtopia::Notes ); }
182 QString groups() const { return find( Qtopia::Groups ); } 182 QString groups() const { return find( Qtopia::Groups ); }
183 QStringList groupList() const; 183 QStringList groupList() const;
184 184
185// // custom 185// // custom
186// const QString &customField( const QString &key ) 186// const QString &customField( const QString &key )
187// { return find( Custom- + key ); } 187// { return find( Custom- + key ); }
188 188
189 static QStringList fields(); 189 static QStringList fields();
190 static QStringList trfields(); 190 static QStringList trfields();
191 static QStringList untrfields(); 191 static QStringList untrfields();
192 192
193 QString toRichText() const; 193 QString toRichText() const;
194 QMap<int, QString> toMap() const; 194 QMap<int, QString> toMap() const;
195 QString field( int key ) const { return find( key ); } 195 QString field( int key ) const { return find( key ); }
196 196
197 197
198 // journaling... 198 // journaling...
199 void saveJournal( journal_action action, const QString &key = QString::null ); 199 void saveJournal( journal_action action, const QString &key = QString::null );
200 void save( QString &buf ) const; 200 void save( QString &buf ) const;
201 201
202 void setUid( int i ) 202 void setUid( int i )
203{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 203{ OPimRecord::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
204 204
205 QString toShortText()const; 205 QString toShortText()const;
206 QString OContact::type()const; 206 QString OContact::type()const;
207 QMap<QString,QString> OContact::toExtraMap() const; 207 QMap<QString,QString> OContact::toExtraMap() const;
208 class QString OContact::recordField(int) const; 208 class QString OContact::recordField(int) const;
209 209
210 // Why private ? (eilers,se) 210 // Why private ? (eilers,se)
211 QString emailSeparator() const { return " "; } 211 QString emailSeparator() const { return " "; }
212 // the emails should be seperated by a comma 212 // the emails should be seperated by a comma
213 void setEmails( const QString &v ); 213 void setEmails( const QString &v );
214 QString emails() const { return find( Qtopia::Emails ); } 214 QString emails() const { return find( Qtopia::Emails ); }
215 215
216 216
217private: 217private:
218 friend class AbEditor; 218 friend class AbEditor;
219 friend class AbTable; 219 friend class AbTable;
220 friend class AddressBookAccessPrivate; 220 friend class AddressBookAccessPrivate;
221 friend class XMLIO; 221 friend class XMLIO;
222 222
223 void insert( int key, const QString &value ); 223 void insert( int key, const QString &value );
224 void replace( int key, const QString &value ); 224 void replace( int key, const QString &value );
225 QString find( int key ) const; 225 QString find( int key ) const;
226 226
227 QString displayAddress( const QString &street, 227 QString displayAddress( const QString &street,
228 const QString &city, 228 const QString &city,
229 const QString &state, 229 const QString &state,
230 const QString &zip, 230 const QString &zip,
231 const QString &country ) const; 231 const QString &country ) const;
232 232
233 Qtopia::UidGen &uidGen() { return sUidGen; }
234
235
236 static Qtopia::UidGen sUidGen;
237 QMap<int, QString> mMap; 233 QMap<int, QString> mMap;
238 ContactPrivate *d; 234 ContactPrivate *d;
239}; 235};
240 236
241 237
242#endif 238#endif
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index 62dc353..21cf131 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1,134 +1,132 @@
1#include <qpe/categories.h> 1#include <qpe/categories.h>
2#include <qpe/categoryselect.h> 2#include <qpe/categoryselect.h>
3 3
4#include "opimrecord.h" 4#include "opimrecord.h"
5 5
6Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 6Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
7 7
8 8
9OPimRecord::OPimRecord( int uid ) 9OPimRecord::OPimRecord( int uid )
10 : Qtopia::Record() { 10 : Qtopia::Record() {
11 11
12 setUid( uid ); 12 setUid( uid );
13} 13}
14OPimRecord::~OPimRecord() { 14OPimRecord::~OPimRecord() {
15} 15}
16OPimRecord::OPimRecord( const OPimRecord& rec ) 16OPimRecord::OPimRecord( const OPimRecord& rec )
17 : Qtopia::Record( rec ) 17 : Qtopia::Record( rec )
18{ 18{
19 (*this) = rec; 19 (*this) = rec;
20} 20}
21 21
22OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 22OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
23 Qtopia::Record::operator=( rec ); 23 Qtopia::Record::operator=( rec );
24 m_relations = rec.m_relations; 24 m_relations = rec.m_relations;
25 25
26 return *this; 26 return *this;
27} 27}
28/* 28/*
29 * category names 29 * category names
30 */ 30 */
31QStringList OPimRecord::categoryNames()const { 31QStringList OPimRecord::categoryNames()const {
32 QStringList list; 32 QStringList list;
33 QArray<int> cats = categories(); 33 QArray<int> cats = categories();
34 Categories catDB; 34 Categories catDB;
35 catDB.load( categoryFileName() ); 35 catDB.load( categoryFileName() );
36 36
37 for (uint i = 0; i < cats.count(); i++ ) { 37 for (uint i = 0; i < cats.count(); i++ ) {
38 list << catDB.label("Todo List", cats[i] ); 38 list << catDB.label("Todo List", cats[i] );
39 } 39 }
40 40
41 return list; 41 return list;
42} 42}
43void OPimRecord::setCategoryNames( const QStringList& ) { 43void OPimRecord::setCategoryNames( const QStringList& ) {
44 44
45} 45}
46void OPimRecord::addCategoryName( const QString& ) { 46void OPimRecord::addCategoryName( const QString& ) {
47 Categories catDB; 47 Categories catDB;
48 catDB.load( categoryFileName() ); 48 catDB.load( categoryFileName() );
49 49
50 50
51} 51}
52bool OPimRecord::isEmpty()const { 52bool OPimRecord::isEmpty()const {
53 return ( uid() == 0 ); 53 return ( uid() == 0 );
54} 54}
55QStringList OPimRecord::relatedApps()const{ 55QStringList OPimRecord::relatedApps()const{
56 QStringList list; 56 QStringList list;
57 QMap<QString, QArray<int> >::ConstIterator it; 57 QMap<QString, QArray<int> >::ConstIterator it;
58 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { 58 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
59 list << it.key(); 59 list << it.key();
60 } 60 }
61 return list; 61 return list;
62} 62}
63QArray<int> OPimRecord::relations(const QString& app )const { 63QArray<int> OPimRecord::relations(const QString& app )const {
64 QArray<int> tmp; 64 QArray<int> tmp;
65 QMap<QString, QArray<int> >::ConstIterator it; 65 QMap<QString, QArray<int> >::ConstIterator it;
66 it = m_relations.find( app); 66 it = m_relations.find( app);
67 if ( it != m_relations.end() ) 67 if ( it != m_relations.end() )
68 tmp = it.data(); 68 tmp = it.data();
69 return tmp; 69 return tmp;
70} 70}
71void OPimRecord::clearRelation( const QString& app ) { 71void OPimRecord::clearRelation( const QString& app ) {
72 m_relations.remove( app ); 72 m_relations.remove( app );
73} 73}
74void OPimRecord::addRelation( const QString& app, int id ) { 74void OPimRecord::addRelation( const QString& app, int id ) {
75 75
76 QMap<QString, QArray<int> >::Iterator it; 76 QMap<QString, QArray<int> >::Iterator it;
77 QArray<int> tmp; 77 QArray<int> tmp;
78 78
79 it = m_relations.find( app ); 79 it = m_relations.find( app );
80 if ( it == m_relations.end() ) { 80 if ( it == m_relations.end() ) {
81 tmp.resize(1 ); 81 tmp.resize(1 );
82 tmp[0] = id; 82 tmp[0] = id;
83 }else{ 83 }else{
84 tmp = it.data(); 84 tmp = it.data();
85 tmp.resize( tmp.size() + 1 ); 85 tmp.resize( tmp.size() + 1 );
86 tmp[tmp.size() - 1] = id; 86 tmp[tmp.size() - 1] = id;
87 } 87 }
88 m_relations.replace( app, tmp ); 88 m_relations.replace( app, tmp );
89} 89}
90void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { 90void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
91 91
92 QMap<QString, QArray<int> >::Iterator it; 92 QMap<QString, QArray<int> >::Iterator it;
93 QArray<int> tmp; 93 QArray<int> tmp;
94 94
95 it = m_relations.find( app); 95 it = m_relations.find( app);
96 if ( it == m_relations.end() ) { 96 if ( it == m_relations.end() ) {
97 tmp = ids; 97 tmp = ids;
98 }else{ 98 }else{
99 tmp = it.data(); 99 tmp = it.data();
100 int offset = tmp.size()-1; 100 int offset = tmp.size()-1;
101 tmp.resize( tmp.size() + ids.size() ); 101 tmp.resize( tmp.size() + ids.size() );
102 for (uint i = 0; i < ids.size(); i++ ) { 102 for (uint i = 0; i < ids.size(); i++ ) {
103 tmp[offset+i] = ids[i]; 103 tmp[offset+i] = ids[i];
104 } 104 }
105 105
106 } 106 }
107 m_relations.replace( app, tmp ); 107 m_relations.replace( app, tmp );
108} 108}
109QString OPimRecord::crossToString()const { 109QString OPimRecord::crossToString()const {
110 QString str; 110 QString str;
111 QMap<QString, QArray<int> >::ConstIterator it; 111 QMap<QString, QArray<int> >::ConstIterator it;
112 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 112 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
113 QArray<int> id = it.data(); 113 QArray<int> id = it.data();
114 for ( uint i = 0; i < id.size(); ++i ) { 114 for ( uint i = 0; i < id.size(); ++i ) {
115 str += it.key() + "," + QString::number( i ) + ";"; 115 str += it.key() + "," + QString::number( i ) + ";";
116 } 116 }
117 } 117 }
118 str = str.remove( str.length()-1, 1); // strip the ; 118 str = str.remove( str.length()-1, 1); // strip the ;
119 //qWarning("IDS " + str ); 119 //qWarning("IDS " + str );
120 120
121 return str; 121 return str;
122} 122}
123/* if uid = 1 assign a new one */ 123/* if uid = 1 assign a new one */
124void OPimRecord::setUid( int uid ) { 124void OPimRecord::setUid( int uid ) {
125// qWarning("setting uid" );
126 if ( uid == 1) 125 if ( uid == 1)
127 uid = uidGen().generate(); 126 uid = uidGen().generate();
128 127
129// qWarning(" uid %d", uid);
130 Qtopia::Record::setUid( uid ); 128 Qtopia::Record::setUid( uid );
131}; 129};
132Qtopia::UidGen &OPimRecord::uidGen() { 130Qtopia::UidGen &OPimRecord::uidGen() {
133 return m_uidGen; 131 return m_uidGen;
134} 132}