summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show 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
@@ -32,24 +32,31 @@ $Id$
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() ) {
@@ -71,24 +78,28 @@ bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFi
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;
diff --git a/kabc/vcardformatimpl.h b/kabc/vcardformatimpl.h
index fa3d55f..4821047 100644
--- a/kabc/vcardformatimpl.h
+++ b/kabc/vcardformatimpl.h
@@ -40,24 +40,26 @@ namespace 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
@@ -97,16 +99,19 @@ class VCardFormatImpl
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