summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp24
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp232
2 files changed, 235 insertions, 21 deletions
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index 69eddfe..b9a491e 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -36,12 +36,8 @@
36#include <stdlib.h> 36#include <stdlib.h>
37#include <stdio.h> 37#include <stdio.h>
38 38
39// fromLocal8Bit() does not work as expected. Thus it 39namespace Opie {
40// is replaced by fromLatin1() (eilers) 40namespace DB {
41#define __BUGGY_LOCAL8BIT_
42
43namespace Opie {
44namespace DB {
45namespace Internal { 41namespace Internal {
46 42
47namespace { 43namespace {
@@ -173,8 +169,8 @@ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
173 query.driver = this; 169 query.driver = this;
174 char *err; 170 char *err;
175 /* SQLITE_OK 0 if return code > 0 == failure */ 171 /* SQLITE_OK 0 if return code > 0 == failure */
176 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { 172 if ( sqlite_exec(m_sqlite, qu->query().utf8(),&call_back, &query, &err) > 0 ) {
177 owarn << "OSQLiteDriver::query: Error while executing " << err << "" << oendl; 173 qWarning("OSQLiteDriver::query: Error while executing %s",err);
178 free(err ); 174 free(err );
179 // FixMe Errors 175 // FixMe Errors
180 } 176 }
@@ -215,15 +211,9 @@ int OSQLiteDriver::call_back( void* voi, int argc,
215 QMap<int, QString> tableInt; 211 QMap<int, QString> tableInt;
216 for (int i = 0; i < argc; i++ ) { 212 for (int i = 0; i < argc; i++ ) {
217 213
218#ifdef __BUGGY_LOCAL8BIT_ 214 tableInt.insert( i, QString::fromUtf8( argv[i] ) );
219 tableInt.insert( i, QString::fromLatin1( argv[i] ) ); 215 tableString.insert( QString::fromUtf8( columns[i] ),
220 tableString.insert( QString::fromLatin1( columns[i] ), 216 QString::fromUtf8( argv[i] ) );
221 QString::fromLatin1( argv[i] ) );
222#else
223 tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) );
224 tableString.insert( QString::fromLocal8Bit( columns[i] ),
225 QString::fromLocal8Bit( argv[i] ) );
226#endif
227 } 217 }
228 OSQLResultItem item( tableString, tableInt ); 218 OSQLResultItem item( tableString, tableInt );
229 qu->items.append( item ); 219 qu->items.append( item );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index b6ea461..caf3c6e 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -210,6 +210,215 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
210{ 210{
211 OPimContact c; 211 OPimContact c;
212 212
213<<<<<<< ocontactaccessbackend_vcard.cpp
214 VObjectIterator it;
215 initPropIterator( &it, obj );
216 while( moreIteration( &it ) ) {
217 VObject *o = nextVObject( &it );
218 QCString name = vObjectName( o );
219 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
220 qDebug( "(1)Read: %s", QString( value ).latin1() );
221 if ( name == VCNameProp ) {
222 VObjectIterator nit;
223 initPropIterator( &nit, o );
224 while( moreIteration( &nit ) ) {
225 VObject *o = nextVObject( &nit );
226 QCString name = vObjectTypeInfo( o );
227 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
228 qDebug( "(2)Read: %s", value.latin1() );
229 if ( name == VCNamePrefixesProp )
230 c.setTitle( value );
231 else if ( name == VCNameSuffixesProp )
232 c.setSuffix( value );
233 else if ( name == VCFamilyNameProp )
234 c.setLastName( value );
235 else if ( name == VCGivenNameProp )
236 c.setFirstName( value );
237 else if ( name == VCAdditionalNamesProp )
238 c.setMiddleName( value );
239 }
240 }
241 else if ( name == VCAdrProp ) {
242 bool work = TRUE; // default address is work address
243 QString street;
244 QString city;
245 QString region;
246 QString postal;
247 QString country;
248
249 VObjectIterator nit;
250 initPropIterator( &nit, o );
251 while( moreIteration( &nit ) ) {
252 VObject *o = nextVObject( &nit );
253 QCString name = vObjectName( o );
254 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
255 if ( name == VCHomeProp )
256 work = FALSE;
257 else if ( name == VCWorkProp )
258 work = TRUE;
259 else if ( name == VCStreetAddressProp )
260 street = value;
261 else if ( name == VCCityProp )
262 city = value;
263 else if ( name == VCRegionProp )
264 region = value;
265 else if ( name == VCPostalCodeProp )
266 postal = value;
267 else if ( name == VCCountryNameProp )
268 country = value;
269 }
270 if ( work ) {
271 c.setBusinessStreet( street );
272 c.setBusinessCity( city );
273 c.setBusinessCountry( country );
274 c.setBusinessZip( postal );
275 c.setBusinessState( region );
276 } else {
277 c.setHomeStreet( street );
278 c.setHomeCity( city );
279 c.setHomeCountry( country );
280 c.setHomeZip( postal );
281 c.setHomeState( region );
282 }
283 }
284 else if ( name == VCTelephoneProp ) {
285 enum {
286 HOME = 0x01,
287 WORK = 0x02,
288 VOICE = 0x04,
289 CELL = 0x08,
290 FAX = 0x10,
291 PAGER = 0x20,
292 UNKNOWN = 0x80
293 };
294 int type = 0;
295
296 VObjectIterator nit;
297 initPropIterator( &nit, o );
298 while( moreIteration( &nit ) ) {
299 VObject *o = nextVObject( &nit );
300 QCString name = vObjectTypeInfo( o );
301 if ( name == VCHomeProp )
302 type |= HOME;
303 else if ( name == VCWorkProp )
304 type |= WORK;
305 else if ( name == VCVoiceProp )
306 type |= VOICE;
307 else if ( name == VCCellularProp )
308 type |= CELL;
309 else if ( name == VCFaxProp )
310 type |= FAX;
311 else if ( name == VCPagerProp )
312 type |= PAGER;
313 else if ( name == VCPreferredProp )
314 ;
315 else
316 type |= UNKNOWN;
317 }
318 if ( (type & UNKNOWN) != UNKNOWN ) {
319 if ( ( type & (HOME|WORK) ) == 0 ) // default
320 type |= HOME;
321 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
322 type |= VOICE;
323
324 qWarning("value %s %d", value.data(), type );
325 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
326 c.setHomePhone( value );
327 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
328 c.setHomeFax( value );
329 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
330 c.setHomeMobile( value );
331 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
332 c.setBusinessPhone( value );
333 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
334 c.setBusinessFax( value );
335 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
336 c.setBusinessMobile( value );
337 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
338 c.setBusinessPager( value );
339 }
340 }
341 else if ( name == VCEmailAddressProp ) {
342 QString email = QString::fromUtf8( vObjectStringZValue( o ) );
343 bool valid = TRUE;
344 VObjectIterator nit;
345 initPropIterator( &nit, o );
346 while( moreIteration( &nit ) ) {
347 VObject *o = nextVObject( &nit );
348 QCString name = vObjectTypeInfo( o );
349 if ( name != VCInternetProp && name != VCHomeProp &&
350 name != VCWorkProp &&
351 name != VCPreferredProp )
352 // ### preffered should map to default email
353 valid = FALSE;
354 }
355 if ( valid ) {
356 c.insertEmail( email );
357 }
358 }
359 else if ( name == VCURLProp ) {
360 VObjectIterator nit;
361 initPropIterator( &nit, o );
362 while( moreIteration( &nit ) ) {
363 VObject *o = nextVObject( &nit );
364 QCString name = vObjectTypeInfo( o );
365 if ( name == VCHomeProp )
366 c.setHomeWebpage( value );
367 else if ( name == VCWorkProp )
368 c.setBusinessWebpage( value );
369 }
370 }
371 else if ( name == VCOrgProp ) {
372 VObjectIterator nit;
373 initPropIterator( &nit, o );
374 while( moreIteration( &nit ) ) {
375 VObject *o = nextVObject( &nit );
376 QCString name = vObjectName( o );
377 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
378 if ( name == VCOrgNameProp )
379 c.setCompany( value );
380 else if ( name == VCOrgUnitProp )
381 c.setDepartment( value );
382 else if ( name == VCOrgUnit2Prop )
383 c.setOffice( value );
384 }
385 }
386 else if ( name == VCTitleProp ) {
387 c.setJobTitle( value );
388 }
389 else if ( name == "X-Qtopia-Profession" ) {
390 c.setProfession( value );
391 }
392 else if ( name == "X-Qtopia-Manager" ) {
393 c.setManager( value );
394 }
395 else if ( name == "X-Qtopia-Assistant" ) {
396 c.setAssistant( value );
397 }
398 else if ( name == "X-Qtopia-Spouse" ) {
399 c.setSpouse( value );
400 }
401 else if ( name == "X-Qtopia-Gender" ) {
402 c.setGender( value );
403 }
404 else if ( name == "X-Qtopia-Anniversary" ) {
405 c.setAnniversary( convVCardDateToDate( value ) );
406 }
407 else if ( name == "X-Qtopia-Nickname" ) {
408 c.setNickname( value );
409 }
410 else if ( name == "X-Qtopia-Children" ) {
411 c.setChildren( value );
412 }
413 else if ( name == VCBirthDateProp ) {
414 // Reading Birthdate regarding RFC 2425 (5.8.4)
415 c.setBirthday( convVCardDateToDate( value ) );
416
417 }
418 else if ( name == VCCommentProp ) {
419 c.setNotes( value );
420 }
421=======
213 VObjectIterator it; 422 VObjectIterator it;
214 initPropIterator( &it, obj ); 423 initPropIterator( &it, obj );
215 while( moreIteration( &it ) ) { 424 while( moreIteration( &it ) ) {
@@ -415,7 +624,21 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
415 else if ( name == VCCommentProp ) { 624 else if ( name == VCCommentProp ) {
416 c.setNotes( value ); 625 c.setNotes( value );
417 } 626 }
627>>>>>>> 1.15
418#if 0 628#if 0
629<<<<<<< ocontactaccessbackend_vcard.cpp
630 else {
631 printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) );
632 VObjectIterator nit;
633 initPropIterator( &nit, o );
634 while( moreIteration( &nit ) ) {
635 VObject *o = nextVObject( &nit );
636 QCString name = vObjectName( o );
637 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
638 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
639 }
640 }
641=======
419 else { 642 else {
420 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 643 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
421 VObjectIterator nit; 644 VObjectIterator nit;
@@ -427,6 +650,7 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
427 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 650 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
428 } 651 }
429 } 652 }
653>>>>>>> 1.15
430#endif 654#endif
431 } 655 }
432 c.setFileAs(); 656 c.setFileAs();
@@ -581,10 +805,10 @@ QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datest
581 805
582VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 806VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
583{ 807{
584 VObject *ret = 0; 808 VObject *ret = 0;
585 if ( o && !value.isEmpty() ) 809 if ( o && !value.isEmpty() )
586 ret = addPropValue( o, prop, value.latin1() ); 810 ret = addPropValue( o, prop, value.utf8() );
587 return ret; 811 return ret;
588} 812}
589 813
590VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) 814VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop)