-rw-r--r-- | kabc/vcard/ContentLine.cpp | 10 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 12 | ||||
-rw-r--r-- | kabc/vcard/include/VCardDefines.h | 3 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 2 |
4 files changed, 20 insertions, 7 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index 0fb5b5d..f7e04a9 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp @@ -21,128 +21,134 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <qcstring.h> #include <qstrlist.h> #include <qregexp.h> #include <kdebug.h> #include <VCardAdrParam.h> #include <VCardAgentParam.h> #include <VCardDateParam.h> #include <VCardEmailParam.h> #include <VCardImageParam.h> #include <VCardSourceParam.h> #include <VCardTelParam.h> #include <VCardTextBinParam.h> #include <VCardTextParam.h> #include <VCardAdrValue.h> #include <VCardAgentValue.h> #include <VCardDateValue.h> #include <VCardImageValue.h> #include <VCardTextValue.h> #include <VCardTextBinValue.h> #include <VCardLangValue.h> #include <VCardNValue.h> #include <VCardURIValue.h> #include <VCardSoundValue.h> #include <VCardClassValue.h> #include <VCardFloatValue.h> #include <VCardOrgValue.h> #include <VCardTelValue.h> #include <VCardTextListValue.h> #include <VCardUTCValue.h> #include <VCardGeoValue.h> #include <VCardRToken.h> #include <VCardContentLine.h> #include <VCardEntity.h> #include <VCardEnum.h> #include <VCardDefines.h> using namespace VCARD; ContentLine::ContentLine() : Entity(), - value_(0) + value_(0), + paramType_( ParamUnknown ), + valueType_( ValueUnknown ), + entityType_( EntityUnknown ) { paramList_.setAutoDelete( TRUE ); } ContentLine::ContentLine(const ContentLine & x) : Entity(x), group_ (x.group_), name_ (x.name_), /*US paramList_(x.paramList_),*/ value_(x.value_->clone()), paramType_(x.paramType_), valueType_(x.valueType_), entityType_(x.entityType_) { paramList_.setAutoDelete( TRUE ); ParamListIterator it(x.paramList_); for (; it.current(); ++it) { Param *p = new Param; p->setName( it.current()->name() ); p->setValue( it.current()->value() ); paramList_.append(p); } } ContentLine::ContentLine(const QCString & s) : Entity(s), - value_(0) + value_(0), + paramType_( ParamUnknown ), + valueType_( ValueUnknown ), + entityType_( EntityUnknown ) { paramList_.setAutoDelete( TRUE ); } ContentLine & ContentLine::operator = (ContentLine & x) { if (*this == x) return *this; ParamListIterator it(x.paramList_); for (; it.current(); ++it) { Param *p = new Param; p->setName( it.current()->name() ); p->setValue( it.current()->value() ); paramList_.append(p); } value_ = x.value_->clone(); Entity::operator = (x); return *this; } ContentLine & ContentLine::operator = (const QCString & s) { Entity::operator = (s); delete value_; value_ = 0; return *this; } bool ContentLine::operator == (ContentLine & x) { x.parse(); QPtrListIterator<Param> it(x.paramList()); if (!paramList_.find(it.current())) return false; return true; } ContentLine::~ContentLine() { diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index 391a69e..d19a004 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp @@ -143,103 +143,107 @@ VCard::_parse() } if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! vDebug("No BEGIN"); return; } if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! vDebug("No VCARD"); return; } /////////////////////////////////////////////////////////////// // CONTENT LINES // vDebug("Content lines"); // Handle folded lines. QStrList refolded; QStrListIterator it(l); QCString cur; for (; it.current(); ++it) { cur = it.current(); ++it; while ( it.current() && it.current()[0] == ' ' && strlen(it.current()) != 1) { cur += it.current() + 1; ++it; } --it; refolded.append(cur); } QStrListIterator it2(refolded); for (; it2.current(); ++it2) { - - vDebug("New contentline using \"" + QCString(it2.current()) + "\""); + vDebug("New contentline using \"" + QCString(it2.current()) + "\""); ContentLine * cl = new ContentLine(it2.current()); cl->parse(); - - contentLineList_.append(cl); + if (cl->value() == 0) + { + qDebug("Content line could not be parsed. Discarded: %s" + QCString(it2.current())); + delete cl; + } + else + contentLineList_.append(cl); } /////////////////////////////////////////////////////////////// // LAST LINE split = endLine.find(':'); if (split == -1) // invalid, no END return; firstPart = endLine.left(split); valuePart = endLine.right(firstPart.length() - split - 1); split = firstPart.find('.'); if (split != -1) { group_ = firstPart.left(split); firstPart = firstPart.right(firstPart.length() - split - 1); } if (qstricmp(firstPart, "END") != 0) // No END ! return; if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! return; } void VCard::_assemble() { vDebug("Assembling vcard"); strRep_ = "BEGIN:VCARD\r\n"; strRep_ += "VERSION:3.0\r\n"; QPtrListIterator<ContentLine> it(contentLineList_); for (; it.current(); ++it) strRep_ += it.current()->asString() + "\r\n"; strRep_ += "END:VCARD\r\n"; } bool VCard::has(EntityType t) { parse(); return contentLine(t) == 0 ? false : true; } diff --git a/kabc/vcard/include/VCardDefines.h b/kabc/vcard/include/VCardDefines.h index dd38ae2..557410f 100644 --- a/kabc/vcard/include/VCardDefines.h +++ b/kabc/vcard/include/VCardDefines.h @@ -1,52 +1,53 @@ /* libvcard - vCard parsing library for vCard version 3.0 Copyright (C) 1998 Rik Hemsley rik@kde.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef VCARD_DEFINES_H #define VCARD_DEFINES_H #include <kdebug.h> #ifdef VCARD_DEBUG -#define vDebug(a) kdDebug(5710) << a << endl; +//US #define vDebug(a) kdDebug(5710) << a << endl; +#define vDebug(a) qDebug(a); #else #define vDebug(a) #endif #if 0 #ifndef NDEBUG # include <qcstring.h> # include <iostream> # ifdef __GNUG__ # define vDebug(a) cerr << className() << ":" << __FUNCTION__ << " (" \ << __LINE__ << "): " << QCString((a)).data() << endl; # else # define vDebug(a) cerr << className() << ": " \ << QCString((a)).data() << endl; # endif #else # define vDebug(a) #endif #endif #endif // Included this file diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index 2d6eb3d..1bf2cde 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp @@ -216,96 +216,97 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) break; case EntityBirthday: addressee.setBirthday( readDateValue( cl ) ); break; case EntityRevision: addressee.setRevision( readDateTimeValue( cl ) ); break; case EntityGeo: addressee.setGeo( readGeoValue( cl ) ); break; case EntityTimeZone: addressee.setTimeZone( readUTCValue( cl ) ); break; case EntityVersion: break; case EntityClass: addressee.setSecrecy( readClassValue( cl ) ); break; case EntityKey: addressee.insertKey( readKeyValue( cl ) ); break; case EntityPhoto: addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); break; case EntityLogo: addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); break; case EntityAgent: addressee.setAgent( readAgentValue( cl ) ); break; case EntitySound: addressee.setSound( readSoundValue( cl, addressee ) ); break; default: kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " << int( type ) << ": " << cl->asString() << endl; + qDebug("VCardFormat::load(): Unsupported entity: %i: %s ", int(type), (const char*)cl->asString()); break; } } for( cl = contentLines.first(); cl; cl = contentLines.next() ) { EntityType type = cl->entityType(); if ( type == EntityLabel ) { int type = readAddressParam( cl ); Address address = addressee.address( type ); if ( address.isEmpty() ) address.setType( type ); address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); addressee.insertAddress( address ); } } return true; } void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) { //US ContentLine cl; //US QString value; addTextValue( v, EntityName, addressee.name() ); addTextValue( v, EntityUID, addressee.uid() ); addTextValue( v, EntityFullName, addressee.formattedName() ); QStringList emails = addressee.emails(); QStringList::ConstIterator it4; for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { addTextValue( v, EntityEmail, *it4 ); } QStringList customs = addressee.customs(); QStringList::ConstIterator it5; for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { addCustomValue( v, *it5 ); } addTextValue( v, EntityURL, addressee.url().url() ); addNValue( v, addressee ); addTextValue( v, EntityNickname, addressee.nickName() ); addTextValue( v, EntityMailer, addressee.mailer() ); addTextValue( v, EntityTitle, addressee.title() ); @@ -594,96 +595,97 @@ void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); cl.setParamList( params ); v->add(cl); } PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) { PhoneNumber p; TelValue *value = (TelValue *)cl->value(); p.setNumber( QString::fromUtf8( value->asString() ) ); int type = 0; ParamList params = cl->paramList(); ParamListIterator it( params ); QCString tmpStr; for( ; it.current(); ++it ) { if ( (*it)->name() == "TYPE" ) { tmpStr = (*it)->value().lower(); if ( tmpStr == "home" ) type |= PhoneNumber::Home; else if ( tmpStr == "work" ) type |= PhoneNumber::Work; else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; else if ( tmpStr == "video" ) type |= PhoneNumber::Video; else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; else if ( tmpStr == "car" ) type |= PhoneNumber::Car; else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; } } p.setType( type ); return p; } QString VCardFormatImpl::readTextValue( ContentLine *cl ) { VCARD::Value *value = cl->value(); if ( value ) { return QString::fromUtf8( value->asString() ); } else { kdDebug(5700) << "No value: " << cl->asString() << endl; + qDebug("No value: %s", (const char*)(cl->asString())); return QString::null; } } QDate VCardFormatImpl::readDateValue( ContentLine *cl ) { DateValue *dateValue = (DateValue *)cl->value(); if ( dateValue ) return dateValue->qdate(); else return QDate(); } QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) { DateValue *dateValue = (DateValue *)cl->value(); if ( dateValue ) return dateValue->qdt(); else return QDateTime(); } Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) { GeoValue *geoValue = (GeoValue *)cl->value(); if ( geoValue ) { Geo geo( geoValue->latitude(), geoValue->longitude() ); return geo; } else return Geo(); } TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) { UTCValue *utcValue = (UTCValue *)cl->value(); if ( utcValue ) { TimeZone tz; tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); return tz; } else return TimeZone(); } Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) { ClassValue *classValue = (ClassValue *)cl->value(); if ( classValue ) { Secrecy secrecy; |