summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-29 02:41:02 (UTC)
committer ulf69 <ulf69>2004-09-29 02:41:02 (UTC)
commitf7810320ed36a03c96d00436f6b589b9b5ca8c30 (patch) (unidiff)
tree2d47b246b4fef9e7001573405018543e15849b5f
parentcd2cb3a9e2ea93909efc9efa16ddd80c2d2b5408 (diff)
downloadkdepimpi-f7810320ed36a03c96d00436f6b589b9b5ca8c30.zip
kdepimpi-f7810320ed36a03c96d00436f6b589b9b5ca8c30.tar.gz
kdepimpi-f7810320ed36a03c96d00436f6b589b9b5ca8c30.tar.bz2
set env variable KABC_DEBUG to display processewd addresses while loading
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardformatimpl.cpp11
-rw-r--r--kabc/vcardformatimpl.h5
2 files changed, 16 insertions, 0 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index 1bf2cde..ede5773 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -20,87 +20,98 @@
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <qfile.h> 28#include <qfile.h>
29#include <qregexp.h> 29#include <qregexp.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kmdcodec.h> 32#include <kmdcodec.h>
33#include <kstandarddirs.h> 33#include <kstandarddirs.h>
34#include <ktempfile.h> 34#include <ktempfile.h>
35 35
36#include <VCard.h> 36#include <VCard.h>
37 37
38#include "addressbook.h" 38#include "addressbook.h"
39#include "vcardformatimpl.h" 39#include "vcardformatimpl.h"
40 40
41using namespace KABC; 41using namespace KABC;
42using namespace VCARD; 42using namespace VCARD;
43 43
44int VCardFormatImpl::debug = -1;
45
46VCardFormatImpl::VCardFormatImpl()
47{
48 debug = (getenv("KABC_DEBUG") != 0);
49}
50
44bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) 51bool VCardFormatImpl::load( Addressee &addressee, QFile *file )
45{ 52{
46 kdDebug(5700) << "VCardFormat::load()" << endl; 53 kdDebug(5700) << "VCardFormat::load()" << endl;
47 54
48 QByteArray fdata = file->readAll(); 55 QByteArray fdata = file->readAll();
49 QCString data(fdata.data(), fdata.size()+1); 56 QCString data(fdata.data(), fdata.size()+1);
50 57
51 VCardEntity e( data ); 58 VCardEntity e( data );
52 59
53 VCardListIterator it( e.cardList() ); 60 VCardListIterator it( e.cardList() );
54 61
55 if ( it.current() ) { 62 if ( it.current() ) {
56//US VCard v(*it.current()); 63//US VCard v(*it.current());
57//US loadAddressee( addressee, v ); 64//US loadAddressee( addressee, v );
58 loadAddressee( addressee, it.current() ); 65 loadAddressee( addressee, it.current() );
59 return true; 66 return true;
60 } 67 }
61 68
62 return false; 69 return false;
63} 70}
64 71
65bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 72bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
66{ 73{
67 kdDebug(5700) << "VCardFormat::loadAll()" << endl; 74 kdDebug(5700) << "VCardFormat::loadAll()" << endl;
68 75
69 QByteArray fdata = file->readAll(); 76 QByteArray fdata = file->readAll();
70 QCString data(fdata.data(), fdata.size()+1); 77 QCString data(fdata.data(), fdata.size()+1);
71 78
72 VCardEntity e( data ); 79 VCardEntity e( data );
73 80
74 VCardListIterator it( e.cardList() ); 81 VCardListIterator it( e.cardList() );
75 82
76 for (; it.current(); ++it) { 83 for (; it.current(); ++it) {
77//US VCard v(*it.current()); 84//US VCard v(*it.current());
78 Addressee addressee; 85 Addressee addressee;
79//US loadAddressee( addressee, v ); 86//US loadAddressee( addressee, v );
80 loadAddressee( addressee, it.current() ); 87 loadAddressee( addressee, it.current() );
81 addressee.setResource( resource ); 88 addressee.setResource( resource );
82 addressBook->insertAddressee( addressee ); 89 addressBook->insertAddressee( addressee );
90 if (debug == true)
91 {
92 printf("address %s loaded successfully\n", addressee.formattedName().latin1());
93 }
83 } 94 }
84 95
85 return true; 96 return true;
86} 97}
87 98
88void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) 99void VCardFormatImpl::save( const Addressee &addressee, QFile *file )
89{ 100{
90 VCardEntity vcards; 101 VCardEntity vcards;
91 VCardList vcardlist; 102 VCardList vcardlist;
92 vcardlist.setAutoDelete( true ); 103 vcardlist.setAutoDelete( true );
93 104
94 VCard *v = new VCard; 105 VCard *v = new VCard;
95 106
96 saveAddressee( addressee, v, false ); 107 saveAddressee( addressee, v, false );
97 108
98 vcardlist.append( v ); 109 vcardlist.append( v );
99 vcards.setCardList( vcardlist ); 110 vcards.setCardList( vcardlist );
100 111
101 QCString vcardData = vcards.asString(); 112 QCString vcardData = vcards.asString();
102 file->writeBlock( (const char*)vcardData, vcardData.length() ); 113 file->writeBlock( (const char*)vcardData, vcardData.length() );
103} 114}
104 115
105void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) 116void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file )
106{ 117{
diff --git a/kabc/vcardformatimpl.h b/kabc/vcardformatimpl.h
index fa3d55f..4821047 100644
--- a/kabc/vcardformatimpl.h
+++ b/kabc/vcardformatimpl.h
@@ -28,48 +28,50 @@ $Id$
28#ifndef KABC_VCARDFORMATIMPL_H 28#ifndef KABC_VCARDFORMATIMPL_H
29#define KABC_VCARDFORMATIMPL_H 29#define KABC_VCARDFORMATIMPL_H
30 30
31#include <qstring.h> 31#include <qstring.h>
32#include <qfile.h> 32#include <qfile.h>
33 33
34#include "address.h" 34#include "address.h"
35#include "addressee.h" 35#include "addressee.h"
36 36
37#include <VCard.h> 37#include <VCard.h>
38 38
39namespace KABC { 39namespace KABC {
40 40
41class AddressBook; 41class AddressBook;
42 42
43/** 43/**
44 @short Implementation of vCard backend for address book. 44 @short Implementation of vCard backend for address book.
45 45
46 This class implements reading and writing of address book information using 46 This class implements reading and writing of address book information using
47 the vCard format. It requires the vCard lib from kdepim. 47 the vCard format. It requires the vCard lib from kdepim.
48*/ 48*/
49class VCardFormatImpl 49class VCardFormatImpl
50{ 50{
51 public: 51 public:
52 VCardFormatImpl();
53
52 bool load( Addressee &, QFile *file ); 54 bool load( Addressee &, QFile *file );
53 bool loadAll( AddressBook *, Resource *, QFile *file ); 55 bool loadAll( AddressBook *, Resource *, QFile *file );
54 void save( const Addressee &, QFile *file ); 56 void save( const Addressee &, QFile *file );
55 void saveAll( AddressBook *, Resource *, QFile *file ); 57 void saveAll( AddressBook *, Resource *, QFile *file );
56 58
57 bool readFromString( const QString &vcard, Addressee &addr ); 59 bool readFromString( const QString &vcard, Addressee &addr );
58 bool writeToString( const Addressee &addressee, QString &vcard ); 60 bool writeToString( const Addressee &addressee, QString &vcard );
59 61
60 protected: 62 protected:
61 bool loadAddressee( Addressee &, VCARD::VCard * ); 63 bool loadAddressee( Addressee &, VCARD::VCard * );
62 void saveAddressee( const Addressee &, VCARD::VCard *, bool intern ); 64 void saveAddressee( const Addressee &, VCARD::VCard *, bool intern );
63 65
64 void addTextValue (VCARD::VCard *, VCARD::EntityType, const QString & ); 66 void addTextValue (VCARD::VCard *, VCARD::EntityType, const QString & );
65 QString readTextValue( VCARD::ContentLine * ); 67 QString readTextValue( VCARD::ContentLine * );
66 68
67 void addDateValue( VCARD::VCard *, VCARD::EntityType, const QDate & ); 69 void addDateValue( VCARD::VCard *, VCARD::EntityType, const QDate & );
68 QDate readDateValue( VCARD::ContentLine * ); 70 QDate readDateValue( VCARD::ContentLine * );
69 71
70 void addDateTimeValue( VCARD::VCard *, VCARD::EntityType, const QDateTime & ); 72 void addDateTimeValue( VCARD::VCard *, VCARD::EntityType, const QDateTime & );
71 QDateTime readDateTimeValue( VCARD::ContentLine * ); 73 QDateTime readDateTimeValue( VCARD::ContentLine * );
72 74
73 void addAddressValue( VCARD::VCard *, const Address & ); 75 void addAddressValue( VCARD::VCard *, const Address & );
74 Address readAddressValue( VCARD::ContentLine * ); 76 Address readAddressValue( VCARD::ContentLine * );
75 77
@@ -85,28 +87,31 @@ class VCardFormatImpl
85 87
86 void addAddressParam( VCARD::ContentLine *, int ); 88 void addAddressParam( VCARD::ContentLine *, int );
87 int readAddressParam( VCARD::ContentLine * ); 89 int readAddressParam( VCARD::ContentLine * );
88 90
89 void addGeoValue( VCARD::VCard *, const Geo & ); 91 void addGeoValue( VCARD::VCard *, const Geo & );
90 Geo readGeoValue( VCARD::ContentLine * ); 92 Geo readGeoValue( VCARD::ContentLine * );
91 93
92 void addUTCValue( VCARD::VCard *, const TimeZone & ); 94 void addUTCValue( VCARD::VCard *, const TimeZone & );
93 TimeZone readUTCValue( VCARD::ContentLine * ); 95 TimeZone readUTCValue( VCARD::ContentLine * );
94 96
95 void addClassValue( VCARD::VCard *, const Secrecy & ); 97 void addClassValue( VCARD::VCard *, const Secrecy & );
96 Secrecy readClassValue( VCARD::ContentLine * ); 98 Secrecy readClassValue( VCARD::ContentLine * );
97 99
98 void addKeyValue( VCARD::VCard *, const Key & ); 100 void addKeyValue( VCARD::VCard *, const Key & );
99 Key readKeyValue( VCARD::ContentLine * ); 101 Key readKeyValue( VCARD::ContentLine * );
100 102
101 void addPictureValue( VCARD::VCard *, VCARD::EntityType, const Picture &, const Addressee &, bool ); 103 void addPictureValue( VCARD::VCard *, VCARD::EntityType, const Picture &, const Addressee &, bool );
102 Picture readPictureValue( VCARD::ContentLine *, VCARD::EntityType, const Addressee &addr ); 104 Picture readPictureValue( VCARD::ContentLine *, VCARD::EntityType, const Addressee &addr );
103 105
104 void addSoundValue( VCARD::VCard *, const Sound &, const Addressee &, bool ); 106 void addSoundValue( VCARD::VCard *, const Sound &, const Addressee &, bool );
105 Sound readSoundValue( VCARD::ContentLine *, const Addressee &addr ); 107 Sound readSoundValue( VCARD::ContentLine *, const Addressee &addr );
106 108
107 void addAgentValue( VCARD::VCard *, const Agent & ); 109 void addAgentValue( VCARD::VCard *, const Agent & );
108 Agent readAgentValue( VCARD::ContentLine * ); 110 Agent readAgentValue( VCARD::ContentLine * );
111
112 private:
113 static int debug;
109}; 114};
110 115
111} 116}
112#endif 117#endif