-rw-r--r-- | kabc/vcardformatimpl.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index 580c28b..2417874 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -27,8 +27,11 @@ $Id$ | |||
27 | 27 | ||
28 | #include <qfile.h> | 28 | #include <qfile.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | //Added by qt3to4: | ||
32 | #include <Q3CString> | ||
33 | #include <Q3PtrList> | ||
31 | 34 | ||
32 | #include <kdebug.h> | 35 | #include <kdebug.h> |
33 | #include <kmdcodec.h> | 36 | #include <kmdcodec.h> |
34 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
@@ -53,9 +56,9 @@ bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) | |||
53 | { | 56 | { |
54 | kdDebug(5700) << "VCardFormat::load()" << endl; | 57 | kdDebug(5700) << "VCardFormat::load()" << endl; |
55 | 58 | ||
56 | QByteArray fdata = file->readAll(); | 59 | QByteArray fdata = file->readAll(); |
57 | QCString data(fdata.data(), fdata.size()+1); | 60 | Q3CString data(fdata.data(), fdata.size()+1); |
58 | 61 | ||
59 | VCardEntity e( data ); | 62 | VCardEntity e( data ); |
60 | 63 | ||
61 | VCardListIterator it( e.cardList() ); | 64 | VCardListIterator it( e.cardList() ); |
@@ -74,9 +77,9 @@ bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) | |||
74 | #include <kmessagebox.h> | 77 | #include <kmessagebox.h> |
75 | bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) | 78 | bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) |
76 | { | 79 | { |
77 | 80 | ||
78 | QCString data(file->readAll().data(), file->size()+1); | 81 | Q3CString data(file->readAll().data(), file->size()+1); |
79 | VCardEntity e( data ); | 82 | VCardEntity e( data ); |
80 | 83 | ||
81 | VCardListIterator it( e.cardList() ); | 84 | VCardListIterator it( e.cardList() ); |
82 | 85 | ||
@@ -107,9 +110,9 @@ void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) | |||
107 | 110 | ||
108 | vcardlist.append( v ); | 111 | vcardlist.append( v ); |
109 | vcards.setCardList( vcardlist ); | 112 | vcards.setCardList( vcardlist ); |
110 | 113 | ||
111 | QCString vcardData = vcards.asString(); | 114 | Q3CString vcardData = vcards.asString(); |
112 | file->writeBlock( (const char*)vcardData, vcardData.length() ); | 115 | file->writeBlock( (const char*)vcardData, vcardData.length() ); |
113 | } | 116 | } |
114 | 117 | ||
115 | void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) | 118 | void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) |
@@ -128,13 +131,13 @@ void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file | |||
128 | } | 131 | } |
129 | 132 | ||
130 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | 133 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) |
131 | { | 134 | { |
132 | QPtrList<ContentLine> contentLines = v->contentLineList(); | 135 | Q3PtrList<ContentLine> contentLines = v->contentLineList(); |
133 | ContentLine *cl; | 136 | ContentLine *cl; |
134 | 137 | ||
135 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 138 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
136 | QCString n = cl->name(); | 139 | Q3CString n = cl->name(); |
137 | if ( n.left( 2 ) == "X-" ) { | 140 | if ( n.left( 2 ) == "X-" ) { |
138 | n = n.mid( 2 ); | 141 | n = n.mid( 2 ); |
139 | int posDash = n.find( "-" ); | 142 | int posDash = n.find( "-" ); |
140 | addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), | 143 | addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), |
@@ -218,9 +221,9 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | |||
218 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); | 221 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); |
219 | break; | 222 | break; |
220 | 223 | ||
221 | case EntityBirthday: | 224 | case EntityBirthday: |
222 | addressee.setBirthday( readDateValue( cl ) ); | 225 | addressee.setBirthday( (QDateTime) readDateValue( cl ) ); |
223 | break; | 226 | break; |
224 | 227 | ||
225 | case EntityRevision: | 228 | case EntityRevision: |
226 | addressee.setRevision( readDateTimeValue( cl ) ); | 229 | addressee.setRevision( readDateTimeValue( cl ) ); |
@@ -529,9 +532,9 @@ int VCardFormatImpl::readAddressParam( ContentLine *cl ) | |||
529 | { | 532 | { |
530 | int type = 0; | 533 | int type = 0; |
531 | ParamList params = cl->paramList(); | 534 | ParamList params = cl->paramList(); |
532 | ParamListIterator it( params ); | 535 | ParamListIterator it( params ); |
533 | QCString tmpStr; | 536 | Q3CString tmpStr; |
534 | for( ; it.current(); ++it ) { | 537 | for( ; it.current(); ++it ) { |
535 | if ( (*it)->name().upper() == "TYPE" ) { | 538 | if ( (*it)->name().upper() == "TYPE" ) { |
536 | tmpStr = (*it)->value().lower(); | 539 | tmpStr = (*it)->value().lower(); |
537 | if ( tmpStr == "dom" ) type |= Address::Dom; | 540 | if ( tmpStr == "dom" ) type |= Address::Dom; |
@@ -608,9 +611,9 @@ PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) | |||
608 | 611 | ||
609 | int type = 0; | 612 | int type = 0; |
610 | ParamList params = cl->paramList(); | 613 | ParamList params = cl->paramList(); |
611 | ParamListIterator it( params ); | 614 | ParamListIterator it( params ); |
612 | QCString tmpStr; | 615 | Q3CString tmpStr; |
613 | for( ; it.current(); ++it ) { | 616 | for( ; it.current(); ++it ) { |
614 | if ( (*it)->name() == "TYPE" ) { | 617 | if ( (*it)->name() == "TYPE" ) { |
615 | tmpStr = (*it)->value().lower(); | 618 | tmpStr = (*it)->value().lower(); |
616 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; | 619 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; |
@@ -869,9 +872,9 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty | |||
869 | if ( pic.isIntern() ) { | 872 | if ( pic.isIntern() ) { |
870 | QImage img = pic.data(); | 873 | QImage img = pic.data(); |
871 | if ( intern ) { // only for vCard export we really write the data inline | 874 | if ( intern ) { // only for vCard export we really write the data inline |
872 | QByteArray data; | 875 | QByteArray data; |
873 | QDataStream s( data, IO_WriteOnly ); | 876 | QDataStream s( &data, QIODevice::WriteOnly ); |
874 | s.setVersion( 4 ); // to produce valid png files | 877 | s.setVersion( 4 ); // to produce valid png files |
875 | s << img; | 878 | s << img; |
876 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 879 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
877 | params.append( new Param( "ENCODING", "b" ) ); | 880 | params.append( new Param( "ENCODING", "b" ) ); |
@@ -958,9 +961,9 @@ void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, co | |||
958 | if ( intern ) { // only for vCard export we really write the data inline | 961 | if ( intern ) { // only for vCard export we really write the data inline |
959 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 962 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
960 | } else { // save sound in cache | 963 | } else { // save sound in cache |
961 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 964 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
962 | if ( file.open( IO_WriteOnly ) ) { | 965 | if ( file.open( QIODevice::WriteOnly ) ) { |
963 | file.writeBlock( data ); | 966 | file.writeBlock( data ); |
964 | } | 967 | } |
965 | cl.setValue( new TextValue( "<dummy>" ) ); | 968 | cl.setValue( new TextValue( "<dummy>" ) ); |
966 | } | 969 | } |
@@ -990,9 +993,9 @@ Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee & | |||
990 | if ( isInline ) { | 993 | if ( isInline ) { |
991 | QByteArray data; | 994 | QByteArray data; |
992 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache | 995 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache |
993 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 996 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
994 | if ( file.open( IO_ReadOnly ) ) { | 997 | if ( file.open( QIODevice::ReadOnly ) ) { |
995 | data = file.readAll(); | 998 | data = file.readAll(); |
996 | file.close(); | 999 | file.close(); |
997 | } | 1000 | } |
998 | } else { | 1001 | } else { |