summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 7b4d81f..5ffcb11 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -27,27 +27,31 @@
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33
34/* OPIE */
33#include <opie2/ocontactaccessbackend_xml.h> 35#include <opie2/ocontactaccessbackend_xml.h>
36#include <opie2/xmltree.h>
37#include <opie2/ocontactaccessbackend.h>
38#include <opie2/ocontactaccess.h>
39#include <opie2/odebug.h>
40
41#include <qpe/global.h>
34 42
43/* QT */
35#include <qasciidict.h> 44#include <qasciidict.h>
36#include <qfile.h> 45#include <qfile.h>
37#include <qfileinfo.h> 46#include <qfileinfo.h>
38#include <qregexp.h> 47#include <qregexp.h>
39#include <qarray.h> 48#include <qarray.h>
40#include <qmap.h> 49#include <qmap.h>
41 50
42#include <qpe/global.h> 51/* STD */
43
44#include <opie2/xmltree.h>
45#include <opie2/ocontactaccessbackend.h>
46#include <opie2/ocontactaccess.h>
47
48#include <stdlib.h> 52#include <stdlib.h>
49#include <errno.h> 53#include <errno.h>
50 54
51using namespace Opie::Core; 55using namespace Opie::Core;
52 56
53 57
@@ -101,13 +105,13 @@ bool OPimContactAccessBackend_XML::save()
101 idx_offset += cstr.length(); 105 idx_offset += cstr.length();
102 out = ""; 106 out = "";
103 107
104 // Write all contacts 108 // Write all contacts
105 QListIterator<OPimContact> it( m_contactList ); 109 QListIterator<OPimContact> it( m_contactList );
106 for ( ; it.current(); ++it ) { 110 for ( ; it.current(); ++it ) {
107 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); 111 // owarn << " Uid " << (*it)->uid() << " at Offset: " << idx_offset << "" << oendl;
108 out += "<Contact "; 112 out += "<Contact ";
109 (*it)->save( out ); 113 (*it)->save( out );
110 out += "/>\n"; 114 out += "/>\n";
111 cstr = out.utf8(); 115 cstr = out.utf8();
112 total_written = f.writeBlock( cstr.data(), cstr.length() ); 116 total_written = f.writeBlock( cstr.data(), cstr.length() );
113 idx_offset += cstr.length(); 117 idx_offset += cstr.length();
@@ -456,13 +460,13 @@ QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
456 return m_currentQuery; 460 return m_currentQuery;
457 461
458} 462}
459 463
460bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact ) 464bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact )
461{ 465{
462 //qWarning("odefaultbackend: ACTION::ADD"); 466 //owarn << "odefaultbackend: ACTION::ADD" << oendl;
463 updateJournal (newcontact, ACTION_ADD); 467 updateJournal (newcontact, ACTION_ADD);
464 addContact_p( newcontact ); 468 addContact_p( newcontact );
465 469
466 m_changed = true; 470 m_changed = true;
467 471
468 return true; 472 return true;
@@ -480,13 +484,13 @@ bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact )
480 updateJournal ( *newCont, ACTION_REPLACE); 484 updateJournal ( *newCont, ACTION_REPLACE);
481 m_contactList.removeRef ( found ); 485 m_contactList.removeRef ( found );
482 m_contactList.append ( newCont ); 486 m_contactList.append ( newCont );
483 m_uidToContact.remove( QString().setNum( contact.uid() ) ); 487 m_uidToContact.remove( QString().setNum( contact.uid() ) );
484 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); 488 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
485 489
486 qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid()); 490 owarn << "Nur zur Sicherheit: " << contact.uid() << " == " << newCont->uid() << " ?" << oendl;
487 491
488 return true; 492 return true;
489 } else 493 } else
490 return false; 494 return false;
491} 495}
492 496
@@ -586,21 +590,21 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
586 dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); 590 dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
587 dict.insert( "Nickname", new int(Qtopia::Nickname) ); 591 dict.insert( "Nickname", new int(Qtopia::Nickname) );
588 dict.insert( "Notes", new int(Qtopia::Notes) ); 592 dict.insert( "Notes", new int(Qtopia::Notes) );
589 dict.insert( "action", new int(JOURNALACTION) ); 593 dict.insert( "action", new int(JOURNALACTION) );
590 dict.insert( "actionrow", new int(JOURNALROW) ); 594 dict.insert( "actionrow", new int(JOURNALROW) );
591 595
592 //qWarning( "OPimContactDefaultBackEnd::loading %s", filename.latin1() ); 596 //owarn << "OPimContactDefaultBackEnd::loading " << filename << "" << oendl;
593 597
594 XMLElement *root = XMLElement::load( filename ); 598 XMLElement *root = XMLElement::load( filename );
595 if(root != 0l ){ // start parsing 599 if(root != 0l ){ // start parsing
596 /* Parse all XML-Elements and put the data into the 600 /* Parse all XML-Elements and put the data into the
597 * Contact-Class 601 * Contact-Class
598 */ 602 */
599 XMLElement *element = root->firstChild(); 603 XMLElement *element = root->firstChild();
600 //qWarning("OPimContactAccess::load tagName(): %s", root->tagName().latin1() ); 604 //owarn << "OPimContactAccess::load tagName(): " << root->tagName() << "" << oendl;
601 element = element->firstChild(); 605 element = element->firstChild();
602 606
603 /* Search Tag "Contacts" which is the parent of all Contacts */ 607 /* Search Tag "Contacts" which is the parent of all Contacts */
604 while( element && !isJournal ){ 608 while( element && !isJournal ){
605 if( element->tagName() != QString::fromLatin1("Contacts") ){ 609 if( element->tagName() != QString::fromLatin1("Contacts") ){
606 //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s", 610 //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s",
@@ -634,13 +638,13 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
634 for( it = aMap.begin(); it != aMap.end(); ++it ){ 638 for( it = aMap.begin(); it != aMap.end(); ++it ){
635 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); 639 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
636 640
637 int *find = dict[ it.key() ]; 641 int *find = dict[ it.key() ];
638 /* Unknown attributes will be stored as "Custom" elements */ 642 /* Unknown attributes will be stored as "Custom" elements */
639 if ( !find ) { 643 if ( !find ) {
640 // qWarning("Attribute %s not known.", it.key().latin1()); 644 // owarn << "Attribute " << it.key() << " not known." << oendl;
641 //contact.setCustomField(it.key(), it.data()); 645 //contact.setCustomField(it.key(), it.data());
642 customMap.insert( it.key(), it.data() ); 646 customMap.insert( it.key(), it.data() );
643 continue; 647 continue;
644 } 648 }
645 649
646 /* Check if special conversion is needed and add attribute 650 /* Check if special conversion is needed and add attribute
@@ -701,16 +705,16 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
701 } 705 }
702 706
703 /* Move to next element */ 707 /* Move to next element */
704 element = element->nextChild(); 708 element = element->nextChild();
705 } 709 }
706 }else { 710 }else {
707 qWarning("ODefBack::could not load"); 711 owarn << "ODefBack::could not load" << oendl;
708 } 712 }
709 delete root; 713 delete root;
710 qWarning("returning from loading" ); 714 owarn << "returning from loading" << oendl;
711 return true; 715 return true;
712} 716}
713 717
714 718
715void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt, 719void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt,
716 journal_action action ) 720 journal_action action )