summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-11-11 16:41:09 (UTC)
committer kergoth <kergoth>2002-11-11 16:41:09 (UTC)
commit84cafc64d515c80aebd50e70b47e3da93d742c8a (patch) (unidiff)
treeafab5ebb7e27ba6d3bd6f40bc98f27ce806840b6
parent2df7c2d998c4b15dba8cefea096cce248b774703 (diff)
downloadopie-84cafc64d515c80aebd50e70b47e3da93d742c8a.zip
opie-84cafc64d515c80aebd50e70b47e3da93d742c8a.tar.gz
opie-84cafc64d515c80aebd50e70b47e3da93d742c8a.tar.bz2
no default arguments in implementation
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp5
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 013f3af..faa72b4 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -1,419 +1,422 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved. 4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.3 2002/11/11 16:41:09 kergoth
21 * no default arguments in implementation
22 *
20 * Revision 1.2 2002/11/10 15:41:53 eilers 23 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes.. 24 * Bugfixes..
22 * 25 *
23 * Revision 1.1 2002/11/09 14:34:52 eilers 26 * Revision 1.1 2002/11/09 14:34:52 eilers
24 * Added VCard Backend. 27 * Added VCard Backend.
25 * 28 *
26 */ 29 */
27#include "ocontactaccessbackend_vcard.h" 30#include "ocontactaccessbackend_vcard.h"
28#include "../../library/backend/vobject_p.h" 31#include "../../library/backend/vobject_p.h"
29#include "../../library/backend/qfiledirect_p.h" 32#include "../../library/backend/qfiledirect_p.h"
30 33
31#include <qpe/timeconversion.h> 34#include <qpe/timeconversion.h>
32 35
33#include <qfile.h> 36#include <qfile.h>
34 37
35OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ): 38OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ):
36 m_dirty( false ), 39 m_dirty( false ),
37 m_file( filename ) 40 m_file( filename )
38{ 41{
39 load(); 42 load();
40} 43}
41 44
42 45
43bool OContactAccessBackend_VCard::load () 46bool OContactAccessBackend_VCard::load ()
44{ 47{
45 m_map.clear(); 48 m_map.clear();
46 m_dirty = false; 49 m_dirty = false;
47 50
48 VObject* obj = 0l; 51 VObject* obj = 0l;
49 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 52 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
50 if ( !obj ) 53 if ( !obj )
51 return false; 54 return false;
52 55
53 while ( obj ) { 56 while ( obj ) {
54 OContact con = parseVObject( obj ); 57 OContact con = parseVObject( obj );
55 /* 58 /*
56 * if uid is 0 assign a new one 59 * if uid is 0 assign a new one
57 * this at least happens on 60 * this at least happens on
58 * Nokia6210 61 * Nokia6210
59 */ 62 */
60 if ( con.uid() == 0 ){ 63 if ( con.uid() == 0 ){
61 con.setUid( 1 ); 64 con.setUid( 1 );
62 qWarning("assigned new uid %d",con.uid() ); 65 qWarning("assigned new uid %d",con.uid() );
63 } 66 }
64 67
65 m_map.insert( con.uid(), con ); 68 m_map.insert( con.uid(), con );
66 69
67 VObject *t = obj; 70 VObject *t = obj;
68 obj = nextVObjectInList(obj); 71 obj = nextVObjectInList(obj);
69 cleanVObject( t ); 72 cleanVObject( t );
70 } 73 }
71 74
72 return true; 75 return true;
73 76
74} 77}
75bool OContactAccessBackend_VCard::reload() 78bool OContactAccessBackend_VCard::reload()
76{ 79{
77 return load(); 80 return load();
78} 81}
79bool OContactAccessBackend_VCard::save() 82bool OContactAccessBackend_VCard::save()
80{ 83{
81 if (!m_dirty ) 84 if (!m_dirty )
82 return true; 85 return true;
83 86
84 QFileDirect file( m_file ); 87 QFileDirect file( m_file );
85 if (!file.open(IO_WriteOnly ) ) 88 if (!file.open(IO_WriteOnly ) )
86 return false; 89 return false;
87 90
88 VObject *obj; 91 VObject *obj;
89 obj = newVObject( VCCalProp ); 92 obj = newVObject( VCCalProp );
90 addPropValue( obj, VCVersionProp, "1.0" ); 93 addPropValue( obj, VCVersionProp, "1.0" );
91 94
92 VObject *vo; 95 VObject *vo;
93 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 96 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
94 vo = createVObject( *it ); 97 vo = createVObject( *it );
95 writeVObject( file.directHandle() , vo ); 98 writeVObject( file.directHandle() , vo );
96 cleanVObject( vo ); 99 cleanVObject( vo );
97 } 100 }
98 cleanStrTbl(); 101 cleanStrTbl();
99 102
100 m_dirty = false; 103 m_dirty = false;
101 return true; 104 return true;
102 105
103 106
104} 107}
105void OContactAccessBackend_VCard::clear () 108void OContactAccessBackend_VCard::clear ()
106{ 109{
107 m_map.clear(); 110 m_map.clear();
108 m_dirty = true; // ??? sure ? (se) 111 m_dirty = true; // ??? sure ? (se)
109} 112}
110 113
111bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 114bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
112{ 115{
113 m_map.insert( newcontact.uid(), newcontact ); 116 m_map.insert( newcontact.uid(), newcontact );
114 m_dirty = true; 117 m_dirty = true;
115 return true; 118 return true;
116} 119}
117 120
118bool OContactAccessBackend_VCard::remove ( int uid ) 121bool OContactAccessBackend_VCard::remove ( int uid )
119{ 122{
120 m_map.remove( uid ); 123 m_map.remove( uid );
121 m_dirty = true; 124 m_dirty = true;
122 return true; 125 return true;
123} 126}
124 127
125bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 128bool OContactAccessBackend_VCard::replace ( const OContact &contact )
126{ 129{
127 m_map.replace( contact.uid(), contact ); 130 m_map.replace( contact.uid(), contact );
128 m_dirty = true; 131 m_dirty = true;
129 return true; 132 return true;
130} 133}
131 134
132OContact OContactAccessBackend_VCard::find ( int uid ) const 135OContact OContactAccessBackend_VCard::find ( int uid ) const
133{ 136{
134 return m_map[uid]; 137 return m_map[uid];
135} 138}
136 139
137QArray<int> OContactAccessBackend_VCard::allRecords() const 140QArray<int> OContactAccessBackend_VCard::allRecords() const
138{ 141{
139 QArray<int> ar( m_map.count() ); 142 QArray<int> ar( m_map.count() );
140 QMap<int, OContact>::ConstIterator it; 143 QMap<int, OContact>::ConstIterator it;
141 int i = 0; 144 int i = 0;
142 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 145 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
143 ar[i] = it.key(); 146 ar[i] = it.key();
144 i++; 147 i++;
145 } 148 }
146 return ar; 149 return ar;
147} 150}
148 151
149// Not implemented 152// Not implemented
150QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int ) 153QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int )
151{ 154{
152 QArray<int> ar(0); 155 QArray<int> ar(0);
153 return ar; 156 return ar;
154} 157}
155 158
156// Not implemented 159// Not implemented
157QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 160QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
158{ 161{
159 QArray<int> ar(0); 162 QArray<int> ar(0);
160 return ar; 163 return ar;
161} 164}
162 165
163const uint OContactAccessBackend_VCard::querySettings() 166const uint OContactAccessBackend_VCard::querySettings()
164{ 167{
165 return 0; // No search possible 168 return 0; // No search possible
166} 169}
167 170
168bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const 171bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const
169{ 172{
170 return false; // No search possible, therefore all settings invalid ;) 173 return false; // No search possible, therefore all settings invalid ;)
171} 174}
172 175
173bool OContactAccessBackend_VCard::wasChangedExternally() 176bool OContactAccessBackend_VCard::wasChangedExternally()
174{ 177{
175 return false; // Don't expect concurrent access 178 return false; // Don't expect concurrent access
176} 179}
177 180
178// *** Private stuff *** 181// *** Private stuff ***
179 182
180 183
181OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 184OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
182{ 185{
183 OContact c; 186 OContact c;
184 187
185 VObjectIterator it; 188 VObjectIterator it;
186 initPropIterator( &it, obj ); 189 initPropIterator( &it, obj );
187 while( moreIteration( &it ) ) { 190 while( moreIteration( &it ) ) {
188 VObject *o = nextVObject( &it ); 191 VObject *o = nextVObject( &it );
189 QCString name = vObjectName( o ); 192 QCString name = vObjectName( o );
190 QCString value = vObjectStringZValue( o ); 193 QCString value = vObjectStringZValue( o );
191 if ( name == VCNameProp ) { 194 if ( name == VCNameProp ) {
192 VObjectIterator nit; 195 VObjectIterator nit;
193 initPropIterator( &nit, o ); 196 initPropIterator( &nit, o );
194 while( moreIteration( &nit ) ) { 197 while( moreIteration( &nit ) ) {
195 VObject *o = nextVObject( &nit ); 198 VObject *o = nextVObject( &nit );
196 QCString name = vObjectTypeInfo( o ); 199 QCString name = vObjectTypeInfo( o );
197 QString value = vObjectStringZValue( o ); 200 QString value = vObjectStringZValue( o );
198 if ( name == VCNamePrefixesProp ) 201 if ( name == VCNamePrefixesProp )
199 c.setTitle( value ); 202 c.setTitle( value );
200 else if ( name == VCNameSuffixesProp ) 203 else if ( name == VCNameSuffixesProp )
201 c.setSuffix( value ); 204 c.setSuffix( value );
202 else if ( name == VCFamilyNameProp ) 205 else if ( name == VCFamilyNameProp )
203 c.setLastName( value ); 206 c.setLastName( value );
204 else if ( name == VCGivenNameProp ) 207 else if ( name == VCGivenNameProp )
205 c.setFirstName( value ); 208 c.setFirstName( value );
206 else if ( name == VCAdditionalNamesProp ) 209 else if ( name == VCAdditionalNamesProp )
207 c.setMiddleName( value ); 210 c.setMiddleName( value );
208 } 211 }
209 } 212 }
210 else if ( name == VCAdrProp ) { 213 else if ( name == VCAdrProp ) {
211 bool work = TRUE; // default address is work address 214 bool work = TRUE; // default address is work address
212 QString street; 215 QString street;
213 QString city; 216 QString city;
214 QString region; 217 QString region;
215 QString postal; 218 QString postal;
216 QString country; 219 QString country;
217 220
218 VObjectIterator nit; 221 VObjectIterator nit;
219 initPropIterator( &nit, o ); 222 initPropIterator( &nit, o );
220 while( moreIteration( &nit ) ) { 223 while( moreIteration( &nit ) ) {
221 VObject *o = nextVObject( &nit ); 224 VObject *o = nextVObject( &nit );
222 QCString name = vObjectName( o ); 225 QCString name = vObjectName( o );
223 QString value = vObjectStringZValue( o ); 226 QString value = vObjectStringZValue( o );
224 if ( name == VCHomeProp ) 227 if ( name == VCHomeProp )
225 work = FALSE; 228 work = FALSE;
226 else if ( name == VCWorkProp ) 229 else if ( name == VCWorkProp )
227 work = TRUE; 230 work = TRUE;
228 else if ( name == VCStreetAddressProp ) 231 else if ( name == VCStreetAddressProp )
229 street = value; 232 street = value;
230 else if ( name == VCCityProp ) 233 else if ( name == VCCityProp )
231 city = value; 234 city = value;
232 else if ( name == VCRegionProp ) 235 else if ( name == VCRegionProp )
233 region = value; 236 region = value;
234 else if ( name == VCPostalCodeProp ) 237 else if ( name == VCPostalCodeProp )
235 postal = value; 238 postal = value;
236 else if ( name == VCCountryNameProp ) 239 else if ( name == VCCountryNameProp )
237 country = value; 240 country = value;
238 } 241 }
239 if ( work ) { 242 if ( work ) {
240 c.setBusinessStreet( street ); 243 c.setBusinessStreet( street );
241 c.setBusinessCity( city ); 244 c.setBusinessCity( city );
242 c.setBusinessCountry( country ); 245 c.setBusinessCountry( country );
243 c.setBusinessZip( postal ); 246 c.setBusinessZip( postal );
244 c.setBusinessState( region ); 247 c.setBusinessState( region );
245 } else { 248 } else {
246 c.setHomeStreet( street ); 249 c.setHomeStreet( street );
247 c.setHomeCity( city ); 250 c.setHomeCity( city );
248 c.setHomeCountry( country ); 251 c.setHomeCountry( country );
249 c.setHomeZip( postal ); 252 c.setHomeZip( postal );
250 c.setHomeState( region ); 253 c.setHomeState( region );
251 } 254 }
252 } 255 }
253 else if ( name == VCTelephoneProp ) { 256 else if ( name == VCTelephoneProp ) {
254 enum { 257 enum {
255 HOME = 0x01, 258 HOME = 0x01,
256 WORK = 0x02, 259 WORK = 0x02,
257 VOICE = 0x04, 260 VOICE = 0x04,
258 CELL = 0x08, 261 CELL = 0x08,
259 FAX = 0x10, 262 FAX = 0x10,
260 PAGER = 0x20, 263 PAGER = 0x20,
261 UNKNOWN = 0x80 264 UNKNOWN = 0x80
262 }; 265 };
263 int type = 0; 266 int type = 0;
264 267
265 VObjectIterator nit; 268 VObjectIterator nit;
266 initPropIterator( &nit, o ); 269 initPropIterator( &nit, o );
267 while( moreIteration( &nit ) ) { 270 while( moreIteration( &nit ) ) {
268 VObject *o = nextVObject( &nit ); 271 VObject *o = nextVObject( &nit );
269 QCString name = vObjectTypeInfo( o ); 272 QCString name = vObjectTypeInfo( o );
270 if ( name == VCHomeProp ) 273 if ( name == VCHomeProp )
271 type |= HOME; 274 type |= HOME;
272 else if ( name == VCWorkProp ) 275 else if ( name == VCWorkProp )
273 type |= WORK; 276 type |= WORK;
274 else if ( name == VCVoiceProp ) 277 else if ( name == VCVoiceProp )
275 type |= VOICE; 278 type |= VOICE;
276 else if ( name == VCCellularProp ) 279 else if ( name == VCCellularProp )
277 type |= CELL; 280 type |= CELL;
278 else if ( name == VCFaxProp ) 281 else if ( name == VCFaxProp )
279 type |= FAX; 282 type |= FAX;
280 else if ( name == VCPagerProp ) 283 else if ( name == VCPagerProp )
281 type |= PAGER; 284 type |= PAGER;
282 else if ( name == VCPreferredProp ) 285 else if ( name == VCPreferredProp )
283 ; 286 ;
284 else 287 else
285 type |= UNKNOWN; 288 type |= UNKNOWN;
286 } 289 }
287 if ( (type & UNKNOWN) != UNKNOWN ) { 290 if ( (type & UNKNOWN) != UNKNOWN ) {
288 if ( ( type & (HOME|WORK) ) == 0 ) // default 291 if ( ( type & (HOME|WORK) ) == 0 ) // default
289 type |= HOME; 292 type |= HOME;
290 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 293 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
291 type |= VOICE; 294 type |= VOICE;
292 295
293 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 296 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
294 c.setHomePhone( value ); 297 c.setHomePhone( value );
295 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 298 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
296 c.setHomeFax( value ); 299 c.setHomeFax( value );
297 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 300 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
298 c.setHomeMobile( value ); 301 c.setHomeMobile( value );
299 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 302 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
300 c.setBusinessPhone( value ); 303 c.setBusinessPhone( value );
301 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 304 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
302 c.setBusinessFax( value ); 305 c.setBusinessFax( value );
303 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 306 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
304 c.setBusinessMobile( value ); 307 c.setBusinessMobile( value );
305 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 308 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
306 c.setBusinessPager( value ); 309 c.setBusinessPager( value );
307 } 310 }
308 } 311 }
309 else if ( name == VCEmailAddressProp ) { 312 else if ( name == VCEmailAddressProp ) {
310 QString email = vObjectStringZValue( o ); 313 QString email = vObjectStringZValue( o );
311 bool valid = TRUE; 314 bool valid = TRUE;
312 VObjectIterator nit; 315 VObjectIterator nit;
313 initPropIterator( &nit, o ); 316 initPropIterator( &nit, o );
314 while( moreIteration( &nit ) ) { 317 while( moreIteration( &nit ) ) {
315 VObject *o = nextVObject( &nit ); 318 VObject *o = nextVObject( &nit );
316 QCString name = vObjectTypeInfo( o ); 319 QCString name = vObjectTypeInfo( o );
317 if ( name != VCInternetProp && name != VCHomeProp && 320 if ( name != VCInternetProp && name != VCHomeProp &&
318 name != VCWorkProp && 321 name != VCWorkProp &&
319 name != VCPreferredProp ) 322 name != VCPreferredProp )
320 // ### preffered should map to default email 323 // ### preffered should map to default email
321 valid = FALSE; 324 valid = FALSE;
322 } 325 }
323 if ( valid ) { 326 if ( valid ) {
324 c.insertEmail( email ); 327 c.insertEmail( email );
325 } 328 }
326 } 329 }
327 else if ( name == VCURLProp ) { 330 else if ( name == VCURLProp ) {
328 VObjectIterator nit; 331 VObjectIterator nit;
329 initPropIterator( &nit, o ); 332 initPropIterator( &nit, o );
330 while( moreIteration( &nit ) ) { 333 while( moreIteration( &nit ) ) {
331 VObject *o = nextVObject( &nit ); 334 VObject *o = nextVObject( &nit );
332 QCString name = vObjectTypeInfo( o ); 335 QCString name = vObjectTypeInfo( o );
333 if ( name == VCHomeProp ) 336 if ( name == VCHomeProp )
334 c.setHomeWebpage( value ); 337 c.setHomeWebpage( value );
335 else if ( name == VCWorkProp ) 338 else if ( name == VCWorkProp )
336 c.setBusinessWebpage( value ); 339 c.setBusinessWebpage( value );
337 } 340 }
338 } 341 }
339 else if ( name == VCOrgProp ) { 342 else if ( name == VCOrgProp ) {
340 VObjectIterator nit; 343 VObjectIterator nit;
341 initPropIterator( &nit, o ); 344 initPropIterator( &nit, o );
342 while( moreIteration( &nit ) ) { 345 while( moreIteration( &nit ) ) {
343 VObject *o = nextVObject( &nit ); 346 VObject *o = nextVObject( &nit );
344 QCString name = vObjectName( o ); 347 QCString name = vObjectName( o );
345 QString value = vObjectStringZValue( o ); 348 QString value = vObjectStringZValue( o );
346 if ( name == VCOrgNameProp ) 349 if ( name == VCOrgNameProp )
347 c.setCompany( value ); 350 c.setCompany( value );
348 else if ( name == VCOrgUnitProp ) 351 else if ( name == VCOrgUnitProp )
349 c.setDepartment( value ); 352 c.setDepartment( value );
350 else if ( name == VCOrgUnit2Prop ) 353 else if ( name == VCOrgUnit2Prop )
351 c.setOffice( value ); 354 c.setOffice( value );
352 } 355 }
353 } 356 }
354 else if ( name == VCTitleProp ) { 357 else if ( name == VCTitleProp ) {
355 c.setJobTitle( value ); 358 c.setJobTitle( value );
356 } 359 }
357 else if ( name == "X-Qtopia-Profession" ) { 360 else if ( name == "X-Qtopia-Profession" ) {
358 c.setProfession( value ); 361 c.setProfession( value );
359 } 362 }
360 else if ( name == "X-Qtopia-Manager" ) { 363 else if ( name == "X-Qtopia-Manager" ) {
361 c.setManager( value ); 364 c.setManager( value );
362 } 365 }
363 else if ( name == "X-Qtopia-Assistant" ) { 366 else if ( name == "X-Qtopia-Assistant" ) {
364 c.setAssistant( value ); 367 c.setAssistant( value );
365 } 368 }
366 else if ( name == "X-Qtopia-Spouse" ) { 369 else if ( name == "X-Qtopia-Spouse" ) {
367 c.setSpouse( value ); 370 c.setSpouse( value );
368 } 371 }
369 else if ( name == "X-Qtopia-Gender" ) { 372 else if ( name == "X-Qtopia-Gender" ) {
370 c.setGender( value ); 373 c.setGender( value );
371 } 374 }
372 else if ( name == "X-Qtopia-Anniversary" ) { 375 else if ( name == "X-Qtopia-Anniversary" ) {
373 c.setAnniversary( TimeConversion::fromString( value ) ); 376 c.setAnniversary( TimeConversion::fromString( value ) );
374 } 377 }
375 else if ( name == "X-Qtopia-Nickname" ) { 378 else if ( name == "X-Qtopia-Nickname" ) {
376 c.setNickname( value ); 379 c.setNickname( value );
377 } 380 }
378 else if ( name == "X-Qtopia-Children" ) { 381 else if ( name == "X-Qtopia-Children" ) {
379 c.setChildren( value ); 382 c.setChildren( value );
380 } 383 }
381 else if ( name == VCBirthDateProp ) { 384 else if ( name == VCBirthDateProp ) {
382 // Reading Birthdate regarding RFC 2425 (5.8.4) 385 // Reading Birthdate regarding RFC 2425 (5.8.4)
383 c.setBirthday( convVCardDateToDate( value ) ); 386 c.setBirthday( convVCardDateToDate( value ) );
384 387
385 } 388 }
386 389
387#if 0 390#if 0
388 else { 391 else {
389 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 392 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
390 VObjectIterator nit; 393 VObjectIterator nit;
391 initPropIterator( &nit, o ); 394 initPropIterator( &nit, o );
392 while( moreIteration( &nit ) ) { 395 while( moreIteration( &nit ) ) {
393 VObject *o = nextVObject( &nit ); 396 VObject *o = nextVObject( &nit );
394 QCString name = vObjectName( o ); 397 QCString name = vObjectName( o );
395 QString value = vObjectStringZValue( o ); 398 QString value = vObjectStringZValue( o );
396 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 399 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
397 } 400 }
398 } 401 }
399#endif 402#endif
400 } 403 }
401 c.setFileAs(); 404 c.setFileAs();
402 return c; 405 return c;
403} 406}
404 407
405 408
406VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) 409VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
407{ 410{
408 VObject *vcard = newVObject( VCCardProp ); 411 VObject *vcard = newVObject( VCCardProp );
409 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 412 safeAddPropValue( vcard, VCVersionProp, "2.1" );
410 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 413 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
411 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 414 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
412 415
413 // full name 416 // full name
414 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 417 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
415 418
416 // name properties 419 // name properties
417 VObject *name = safeAddProp( vcard, VCNameProp ); 420 VObject *name = safeAddProp( vcard, VCNameProp );
418 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 421 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
419 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 422 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index 013f3af..faa72b4 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,419 +1,422 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved. 4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.3 2002/11/11 16:41:09 kergoth
21 * no default arguments in implementation
22 *
20 * Revision 1.2 2002/11/10 15:41:53 eilers 23 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes.. 24 * Bugfixes..
22 * 25 *
23 * Revision 1.1 2002/11/09 14:34:52 eilers 26 * Revision 1.1 2002/11/09 14:34:52 eilers
24 * Added VCard Backend. 27 * Added VCard Backend.
25 * 28 *
26 */ 29 */
27#include "ocontactaccessbackend_vcard.h" 30#include "ocontactaccessbackend_vcard.h"
28#include "../../library/backend/vobject_p.h" 31#include "../../library/backend/vobject_p.h"
29#include "../../library/backend/qfiledirect_p.h" 32#include "../../library/backend/qfiledirect_p.h"
30 33
31#include <qpe/timeconversion.h> 34#include <qpe/timeconversion.h>
32 35
33#include <qfile.h> 36#include <qfile.h>
34 37
35OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ): 38OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ):
36 m_dirty( false ), 39 m_dirty( false ),
37 m_file( filename ) 40 m_file( filename )
38{ 41{
39 load(); 42 load();
40} 43}
41 44
42 45
43bool OContactAccessBackend_VCard::load () 46bool OContactAccessBackend_VCard::load ()
44{ 47{
45 m_map.clear(); 48 m_map.clear();
46 m_dirty = false; 49 m_dirty = false;
47 50
48 VObject* obj = 0l; 51 VObject* obj = 0l;
49 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 52 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
50 if ( !obj ) 53 if ( !obj )
51 return false; 54 return false;
52 55
53 while ( obj ) { 56 while ( obj ) {
54 OContact con = parseVObject( obj ); 57 OContact con = parseVObject( obj );
55 /* 58 /*
56 * if uid is 0 assign a new one 59 * if uid is 0 assign a new one
57 * this at least happens on 60 * this at least happens on
58 * Nokia6210 61 * Nokia6210
59 */ 62 */
60 if ( con.uid() == 0 ){ 63 if ( con.uid() == 0 ){
61 con.setUid( 1 ); 64 con.setUid( 1 );
62 qWarning("assigned new uid %d",con.uid() ); 65 qWarning("assigned new uid %d",con.uid() );
63 } 66 }
64 67
65 m_map.insert( con.uid(), con ); 68 m_map.insert( con.uid(), con );
66 69
67 VObject *t = obj; 70 VObject *t = obj;
68 obj = nextVObjectInList(obj); 71 obj = nextVObjectInList(obj);
69 cleanVObject( t ); 72 cleanVObject( t );
70 } 73 }
71 74
72 return true; 75 return true;
73 76
74} 77}
75bool OContactAccessBackend_VCard::reload() 78bool OContactAccessBackend_VCard::reload()
76{ 79{
77 return load(); 80 return load();
78} 81}
79bool OContactAccessBackend_VCard::save() 82bool OContactAccessBackend_VCard::save()
80{ 83{
81 if (!m_dirty ) 84 if (!m_dirty )
82 return true; 85 return true;
83 86
84 QFileDirect file( m_file ); 87 QFileDirect file( m_file );
85 if (!file.open(IO_WriteOnly ) ) 88 if (!file.open(IO_WriteOnly ) )
86 return false; 89 return false;
87 90
88 VObject *obj; 91 VObject *obj;
89 obj = newVObject( VCCalProp ); 92 obj = newVObject( VCCalProp );
90 addPropValue( obj, VCVersionProp, "1.0" ); 93 addPropValue( obj, VCVersionProp, "1.0" );
91 94
92 VObject *vo; 95 VObject *vo;
93 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 96 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
94 vo = createVObject( *it ); 97 vo = createVObject( *it );
95 writeVObject( file.directHandle() , vo ); 98 writeVObject( file.directHandle() , vo );
96 cleanVObject( vo ); 99 cleanVObject( vo );
97 } 100 }
98 cleanStrTbl(); 101 cleanStrTbl();
99 102
100 m_dirty = false; 103 m_dirty = false;
101 return true; 104 return true;
102 105
103 106
104} 107}
105void OContactAccessBackend_VCard::clear () 108void OContactAccessBackend_VCard::clear ()
106{ 109{
107 m_map.clear(); 110 m_map.clear();
108 m_dirty = true; // ??? sure ? (se) 111 m_dirty = true; // ??? sure ? (se)
109} 112}
110 113
111bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 114bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
112{ 115{
113 m_map.insert( newcontact.uid(), newcontact ); 116 m_map.insert( newcontact.uid(), newcontact );
114 m_dirty = true; 117 m_dirty = true;
115 return true; 118 return true;
116} 119}
117 120
118bool OContactAccessBackend_VCard::remove ( int uid ) 121bool OContactAccessBackend_VCard::remove ( int uid )
119{ 122{
120 m_map.remove( uid ); 123 m_map.remove( uid );
121 m_dirty = true; 124 m_dirty = true;
122 return true; 125 return true;
123} 126}
124 127
125bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 128bool OContactAccessBackend_VCard::replace ( const OContact &contact )
126{ 129{
127 m_map.replace( contact.uid(), contact ); 130 m_map.replace( contact.uid(), contact );
128 m_dirty = true; 131 m_dirty = true;
129 return true; 132 return true;
130} 133}
131 134
132OContact OContactAccessBackend_VCard::find ( int uid ) const 135OContact OContactAccessBackend_VCard::find ( int uid ) const
133{ 136{
134 return m_map[uid]; 137 return m_map[uid];
135} 138}
136 139
137QArray<int> OContactAccessBackend_VCard::allRecords() const 140QArray<int> OContactAccessBackend_VCard::allRecords() const
138{ 141{
139 QArray<int> ar( m_map.count() ); 142 QArray<int> ar( m_map.count() );
140 QMap<int, OContact>::ConstIterator it; 143 QMap<int, OContact>::ConstIterator it;
141 int i = 0; 144 int i = 0;
142 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 145 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
143 ar[i] = it.key(); 146 ar[i] = it.key();
144 i++; 147 i++;
145 } 148 }
146 return ar; 149 return ar;
147} 150}
148 151
149// Not implemented 152// Not implemented
150QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int ) 153QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int )
151{ 154{
152 QArray<int> ar(0); 155 QArray<int> ar(0);
153 return ar; 156 return ar;
154} 157}
155 158
156// Not implemented 159// Not implemented
157QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 160QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
158{ 161{
159 QArray<int> ar(0); 162 QArray<int> ar(0);
160 return ar; 163 return ar;
161} 164}
162 165
163const uint OContactAccessBackend_VCard::querySettings() 166const uint OContactAccessBackend_VCard::querySettings()
164{ 167{
165 return 0; // No search possible 168 return 0; // No search possible
166} 169}
167 170
168bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const 171bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const
169{ 172{
170 return false; // No search possible, therefore all settings invalid ;) 173 return false; // No search possible, therefore all settings invalid ;)
171} 174}
172 175
173bool OContactAccessBackend_VCard::wasChangedExternally() 176bool OContactAccessBackend_VCard::wasChangedExternally()
174{ 177{
175 return false; // Don't expect concurrent access 178 return false; // Don't expect concurrent access
176} 179}
177 180
178// *** Private stuff *** 181// *** Private stuff ***
179 182
180 183
181OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 184OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
182{ 185{
183 OContact c; 186 OContact c;
184 187
185 VObjectIterator it; 188 VObjectIterator it;
186 initPropIterator( &it, obj ); 189 initPropIterator( &it, obj );
187 while( moreIteration( &it ) ) { 190 while( moreIteration( &it ) ) {
188 VObject *o = nextVObject( &it ); 191 VObject *o = nextVObject( &it );
189 QCString name = vObjectName( o ); 192 QCString name = vObjectName( o );
190 QCString value = vObjectStringZValue( o ); 193 QCString value = vObjectStringZValue( o );
191 if ( name == VCNameProp ) { 194 if ( name == VCNameProp ) {
192 VObjectIterator nit; 195 VObjectIterator nit;
193 initPropIterator( &nit, o ); 196 initPropIterator( &nit, o );
194 while( moreIteration( &nit ) ) { 197 while( moreIteration( &nit ) ) {
195 VObject *o = nextVObject( &nit ); 198 VObject *o = nextVObject( &nit );
196 QCString name = vObjectTypeInfo( o ); 199 QCString name = vObjectTypeInfo( o );
197 QString value = vObjectStringZValue( o ); 200 QString value = vObjectStringZValue( o );
198 if ( name == VCNamePrefixesProp ) 201 if ( name == VCNamePrefixesProp )
199 c.setTitle( value ); 202 c.setTitle( value );
200 else if ( name == VCNameSuffixesProp ) 203 else if ( name == VCNameSuffixesProp )
201 c.setSuffix( value ); 204 c.setSuffix( value );
202 else if ( name == VCFamilyNameProp ) 205 else if ( name == VCFamilyNameProp )
203 c.setLastName( value ); 206 c.setLastName( value );
204 else if ( name == VCGivenNameProp ) 207 else if ( name == VCGivenNameProp )
205 c.setFirstName( value ); 208 c.setFirstName( value );
206 else if ( name == VCAdditionalNamesProp ) 209 else if ( name == VCAdditionalNamesProp )
207 c.setMiddleName( value ); 210 c.setMiddleName( value );
208 } 211 }
209 } 212 }
210 else if ( name == VCAdrProp ) { 213 else if ( name == VCAdrProp ) {
211 bool work = TRUE; // default address is work address 214 bool work = TRUE; // default address is work address
212 QString street; 215 QString street;
213 QString city; 216 QString city;
214 QString region; 217 QString region;
215 QString postal; 218 QString postal;
216 QString country; 219 QString country;
217 220
218 VObjectIterator nit; 221 VObjectIterator nit;
219 initPropIterator( &nit, o ); 222 initPropIterator( &nit, o );
220 while( moreIteration( &nit ) ) { 223 while( moreIteration( &nit ) ) {
221 VObject *o = nextVObject( &nit ); 224 VObject *o = nextVObject( &nit );
222 QCString name = vObjectName( o ); 225 QCString name = vObjectName( o );
223 QString value = vObjectStringZValue( o ); 226 QString value = vObjectStringZValue( o );
224 if ( name == VCHomeProp ) 227 if ( name == VCHomeProp )
225 work = FALSE; 228 work = FALSE;
226 else if ( name == VCWorkProp ) 229 else if ( name == VCWorkProp )
227 work = TRUE; 230 work = TRUE;
228 else if ( name == VCStreetAddressProp ) 231 else if ( name == VCStreetAddressProp )
229 street = value; 232 street = value;
230 else if ( name == VCCityProp ) 233 else if ( name == VCCityProp )
231 city = value; 234 city = value;
232 else if ( name == VCRegionProp ) 235 else if ( name == VCRegionProp )
233 region = value; 236 region = value;
234 else if ( name == VCPostalCodeProp ) 237 else if ( name == VCPostalCodeProp )
235 postal = value; 238 postal = value;
236 else if ( name == VCCountryNameProp ) 239 else if ( name == VCCountryNameProp )
237 country = value; 240 country = value;
238 } 241 }
239 if ( work ) { 242 if ( work ) {
240 c.setBusinessStreet( street ); 243 c.setBusinessStreet( street );
241 c.setBusinessCity( city ); 244 c.setBusinessCity( city );
242 c.setBusinessCountry( country ); 245 c.setBusinessCountry( country );
243 c.setBusinessZip( postal ); 246 c.setBusinessZip( postal );
244 c.setBusinessState( region ); 247 c.setBusinessState( region );
245 } else { 248 } else {
246 c.setHomeStreet( street ); 249 c.setHomeStreet( street );
247 c.setHomeCity( city ); 250 c.setHomeCity( city );
248 c.setHomeCountry( country ); 251 c.setHomeCountry( country );
249 c.setHomeZip( postal ); 252 c.setHomeZip( postal );
250 c.setHomeState( region ); 253 c.setHomeState( region );
251 } 254 }
252 } 255 }
253 else if ( name == VCTelephoneProp ) { 256 else if ( name == VCTelephoneProp ) {
254 enum { 257 enum {
255 HOME = 0x01, 258 HOME = 0x01,
256 WORK = 0x02, 259 WORK = 0x02,
257 VOICE = 0x04, 260 VOICE = 0x04,
258 CELL = 0x08, 261 CELL = 0x08,
259 FAX = 0x10, 262 FAX = 0x10,
260 PAGER = 0x20, 263 PAGER = 0x20,
261 UNKNOWN = 0x80 264 UNKNOWN = 0x80
262 }; 265 };
263 int type = 0; 266 int type = 0;
264 267
265 VObjectIterator nit; 268 VObjectIterator nit;
266 initPropIterator( &nit, o ); 269 initPropIterator( &nit, o );
267 while( moreIteration( &nit ) ) { 270 while( moreIteration( &nit ) ) {
268 VObject *o = nextVObject( &nit ); 271 VObject *o = nextVObject( &nit );
269 QCString name = vObjectTypeInfo( o ); 272 QCString name = vObjectTypeInfo( o );
270 if ( name == VCHomeProp ) 273 if ( name == VCHomeProp )
271 type |= HOME; 274 type |= HOME;
272 else if ( name == VCWorkProp ) 275 else if ( name == VCWorkProp )
273 type |= WORK; 276 type |= WORK;
274 else if ( name == VCVoiceProp ) 277 else if ( name == VCVoiceProp )
275 type |= VOICE; 278 type |= VOICE;
276 else if ( name == VCCellularProp ) 279 else if ( name == VCCellularProp )
277 type |= CELL; 280 type |= CELL;
278 else if ( name == VCFaxProp ) 281 else if ( name == VCFaxProp )
279 type |= FAX; 282 type |= FAX;
280 else if ( name == VCPagerProp ) 283 else if ( name == VCPagerProp )
281 type |= PAGER; 284 type |= PAGER;
282 else if ( name == VCPreferredProp ) 285 else if ( name == VCPreferredProp )
283 ; 286 ;
284 else 287 else
285 type |= UNKNOWN; 288 type |= UNKNOWN;
286 } 289 }
287 if ( (type & UNKNOWN) != UNKNOWN ) { 290 if ( (type & UNKNOWN) != UNKNOWN ) {
288 if ( ( type & (HOME|WORK) ) == 0 ) // default 291 if ( ( type & (HOME|WORK) ) == 0 ) // default
289 type |= HOME; 292 type |= HOME;
290 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 293 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
291 type |= VOICE; 294 type |= VOICE;
292 295
293 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 296 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
294 c.setHomePhone( value ); 297 c.setHomePhone( value );
295 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 298 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
296 c.setHomeFax( value ); 299 c.setHomeFax( value );
297 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 300 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
298 c.setHomeMobile( value ); 301 c.setHomeMobile( value );
299 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 302 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
300 c.setBusinessPhone( value ); 303 c.setBusinessPhone( value );
301 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 304 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
302 c.setBusinessFax( value ); 305 c.setBusinessFax( value );
303 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 306 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
304 c.setBusinessMobile( value ); 307 c.setBusinessMobile( value );
305 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 308 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
306 c.setBusinessPager( value ); 309 c.setBusinessPager( value );
307 } 310 }
308 } 311 }
309 else if ( name == VCEmailAddressProp ) { 312 else if ( name == VCEmailAddressProp ) {
310 QString email = vObjectStringZValue( o ); 313 QString email = vObjectStringZValue( o );
311 bool valid = TRUE; 314 bool valid = TRUE;
312 VObjectIterator nit; 315 VObjectIterator nit;
313 initPropIterator( &nit, o ); 316 initPropIterator( &nit, o );
314 while( moreIteration( &nit ) ) { 317 while( moreIteration( &nit ) ) {
315 VObject *o = nextVObject( &nit ); 318 VObject *o = nextVObject( &nit );
316 QCString name = vObjectTypeInfo( o ); 319 QCString name = vObjectTypeInfo( o );
317 if ( name != VCInternetProp && name != VCHomeProp && 320 if ( name != VCInternetProp && name != VCHomeProp &&
318 name != VCWorkProp && 321 name != VCWorkProp &&
319 name != VCPreferredProp ) 322 name != VCPreferredProp )
320 // ### preffered should map to default email 323 // ### preffered should map to default email
321 valid = FALSE; 324 valid = FALSE;
322 } 325 }
323 if ( valid ) { 326 if ( valid ) {
324 c.insertEmail( email ); 327 c.insertEmail( email );
325 } 328 }
326 } 329 }
327 else if ( name == VCURLProp ) { 330 else if ( name == VCURLProp ) {
328 VObjectIterator nit; 331 VObjectIterator nit;
329 initPropIterator( &nit, o ); 332 initPropIterator( &nit, o );
330 while( moreIteration( &nit ) ) { 333 while( moreIteration( &nit ) ) {
331 VObject *o = nextVObject( &nit ); 334 VObject *o = nextVObject( &nit );
332 QCString name = vObjectTypeInfo( o ); 335 QCString name = vObjectTypeInfo( o );
333 if ( name == VCHomeProp ) 336 if ( name == VCHomeProp )
334 c.setHomeWebpage( value ); 337 c.setHomeWebpage( value );
335 else if ( name == VCWorkProp ) 338 else if ( name == VCWorkProp )
336 c.setBusinessWebpage( value ); 339 c.setBusinessWebpage( value );
337 } 340 }
338 } 341 }
339 else if ( name == VCOrgProp ) { 342 else if ( name == VCOrgProp ) {
340 VObjectIterator nit; 343 VObjectIterator nit;
341 initPropIterator( &nit, o ); 344 initPropIterator( &nit, o );
342 while( moreIteration( &nit ) ) { 345 while( moreIteration( &nit ) ) {
343 VObject *o = nextVObject( &nit ); 346 VObject *o = nextVObject( &nit );
344 QCString name = vObjectName( o ); 347 QCString name = vObjectName( o );
345 QString value = vObjectStringZValue( o ); 348 QString value = vObjectStringZValue( o );
346 if ( name == VCOrgNameProp ) 349 if ( name == VCOrgNameProp )
347 c.setCompany( value ); 350 c.setCompany( value );
348 else if ( name == VCOrgUnitProp ) 351 else if ( name == VCOrgUnitProp )
349 c.setDepartment( value ); 352 c.setDepartment( value );
350 else if ( name == VCOrgUnit2Prop ) 353 else if ( name == VCOrgUnit2Prop )
351 c.setOffice( value ); 354 c.setOffice( value );
352 } 355 }
353 } 356 }
354 else if ( name == VCTitleProp ) { 357 else if ( name == VCTitleProp ) {
355 c.setJobTitle( value ); 358 c.setJobTitle( value );
356 } 359 }
357 else if ( name == "X-Qtopia-Profession" ) { 360 else if ( name == "X-Qtopia-Profession" ) {
358 c.setProfession( value ); 361 c.setProfession( value );
359 } 362 }
360 else if ( name == "X-Qtopia-Manager" ) { 363 else if ( name == "X-Qtopia-Manager" ) {
361 c.setManager( value ); 364 c.setManager( value );
362 } 365 }
363 else if ( name == "X-Qtopia-Assistant" ) { 366 else if ( name == "X-Qtopia-Assistant" ) {
364 c.setAssistant( value ); 367 c.setAssistant( value );
365 } 368 }
366 else if ( name == "X-Qtopia-Spouse" ) { 369 else if ( name == "X-Qtopia-Spouse" ) {
367 c.setSpouse( value ); 370 c.setSpouse( value );
368 } 371 }
369 else if ( name == "X-Qtopia-Gender" ) { 372 else if ( name == "X-Qtopia-Gender" ) {
370 c.setGender( value ); 373 c.setGender( value );
371 } 374 }
372 else if ( name == "X-Qtopia-Anniversary" ) { 375 else if ( name == "X-Qtopia-Anniversary" ) {
373 c.setAnniversary( TimeConversion::fromString( value ) ); 376 c.setAnniversary( TimeConversion::fromString( value ) );
374 } 377 }
375 else if ( name == "X-Qtopia-Nickname" ) { 378 else if ( name == "X-Qtopia-Nickname" ) {
376 c.setNickname( value ); 379 c.setNickname( value );
377 } 380 }
378 else if ( name == "X-Qtopia-Children" ) { 381 else if ( name == "X-Qtopia-Children" ) {
379 c.setChildren( value ); 382 c.setChildren( value );
380 } 383 }
381 else if ( name == VCBirthDateProp ) { 384 else if ( name == VCBirthDateProp ) {
382 // Reading Birthdate regarding RFC 2425 (5.8.4) 385 // Reading Birthdate regarding RFC 2425 (5.8.4)
383 c.setBirthday( convVCardDateToDate( value ) ); 386 c.setBirthday( convVCardDateToDate( value ) );
384 387
385 } 388 }
386 389
387#if 0 390#if 0
388 else { 391 else {
389 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 392 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
390 VObjectIterator nit; 393 VObjectIterator nit;
391 initPropIterator( &nit, o ); 394 initPropIterator( &nit, o );
392 while( moreIteration( &nit ) ) { 395 while( moreIteration( &nit ) ) {
393 VObject *o = nextVObject( &nit ); 396 VObject *o = nextVObject( &nit );
394 QCString name = vObjectName( o ); 397 QCString name = vObjectName( o );
395 QString value = vObjectStringZValue( o ); 398 QString value = vObjectStringZValue( o );
396 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 399 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
397 } 400 }
398 } 401 }
399#endif 402#endif
400 } 403 }
401 c.setFileAs(); 404 c.setFileAs();
402 return c; 405 return c;
403} 406}
404 407
405 408
406VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) 409VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
407{ 410{
408 VObject *vcard = newVObject( VCCardProp ); 411 VObject *vcard = newVObject( VCCardProp );
409 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 412 safeAddPropValue( vcard, VCVersionProp, "2.1" );
410 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 413 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
411 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 414 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
412 415
413 // full name 416 // full name
414 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 417 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
415 418
416 // name properties 419 // name properties
417 VObject *name = safeAddProp( vcard, VCNameProp ); 420 VObject *name = safeAddProp( vcard, VCNameProp );
418 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 421 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
419 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 422 safeAddPropValue( name, VCGivenNameProp, c.firstName() );