-rw-r--r-- | kabc/vcard21parser.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index 60d02b8..e24a9dc 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp @@ -22,16 +22,18 @@ Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qmap.h> #include <qregexp.h> +//Added by qt3to4: +#include <Q3ValueList> #include <kmdcodec.h> #include "vcard21parser.h" #include "vcardconverter.h" using namespace KABC; bool VCardLineX::isValid() const @@ -40,17 +42,17 @@ bool VCardLineX::isValid() const if ( name == VCARD_BEGIN_N || name == VCARD_END_N ) return false; if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line return true; // This is long but it makes it a bit faster (and saves me from using // a tree which is probably the ideal situation, but a bit memory heavy) - switch( name[0] ) { + switch( name[0].unicode() ) { case 'a': if ( name == VCARD_ADR && qualified && (qualifiers.contains(VCARD_ADR_DOM) || qualifiers.contains(VCARD_ADR_INTL) || qualifiers.contains(VCARD_ADR_POSTAL) || qualifiers.contains(VCARD_ADR_HOME) || qualifiers.contains(VCARD_ADR_WORK) || qualifiers.contains(VCARD_ADR_PREF) @@ -264,17 +266,17 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) addressee.setUrl(KURL(tmpStr)); } //set the addressee's birthday tmpStr = mVCard->getValue(VCARD_BDAY); addressee.setBirthday(VCardStringToDate(tmpStr)); //set the addressee's phone numbers - for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { + for ( Q3ValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { if ( (*i).name == VCARD_TEL ) { int type = 0; if ( (*i).qualified ) { if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) type |= PhoneNumber::Home; if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) type |= PhoneNumber::Work; if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) @@ -303,17 +305,17 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) type |= PhoneNumber::Pcs; } addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); } } addressee.makePhoneNumbersOLcompatible(); //set the addressee's addresses - for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { + for ( Q3ValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { if ( (*i).name == VCARD_ADR ) { int type = 0; if ( (*i).qualified ) { if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) type |= Address::Dom; if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) type |= Address::Intl; if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) @@ -322,17 +324,20 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) type |= Address::Parcel; if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) type |= Address::Home; if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) type |= Address::Work; if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) type |= Address::Pref; } - addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); + QStringList tmp; + for(Q3ValueList<QString>::const_iterator ii=(*i).parameters.begin();ii!=(*i).parameters.end();++ii) + tmp.push_back(*ii); + addressee.insertAddress( readAddressFromQStringList( tmp, type ) ); } } //set the addressee's delivery label tmpStr = mVCard->getValue(VCARD_LABEL); if (!tmpStr.isEmpty()) { qDebug("VCard21Parser::readFromString please verify if replace is correct"); //US tmpStr.replace("\r\n","\n"); @@ -403,20 +408,20 @@ KABC::Address VCard21Parser::readAddressFromQStringList ( const QStringList &dat } VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) { int _err = 0; int _state = VC_STATE_BEGIN; - QValueList<VCardLineX> *_vcdata; - QValueList<QString> lines; + Q3ValueList<VCardLineX> *_vcdata; + QStringList lines; - _vcdata = new QValueList<VCardLineX>; + _vcdata = new Q3ValueList<VCardLineX>; lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); // for each line in the vCard for ( QStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) { VCardLineX _vcl; // take spaces off the end - ugly but necessary hack @@ -496,18 +501,18 @@ VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) if ( qp ) { // join any split lines while ( value.at( value.length() - 1 ) == '=' ) { value.remove( value.length() - 1, 1 ); value.append(*( ++j )); } } _vcl.parameters = QStringList::split( ';', value, true ); if ( qp ) { // decode the quoted printable - for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) - *z = KCodecs::quotedPrintableDecode( (*z).latin1() ); + for ( QLinkedList<QString>::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) + *z = KCodecs::quotedPrintableDecode( (Q3CString)(*z).latin1() ); } } } else { _err = VC_ERR_INTERNAL; break; } // validate VCardLineX @@ -538,70 +543,71 @@ VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) if ( _err != 0 ) { delete _vcdata; return 0; } return new VCard21ParserImpl( _vcdata ); } -VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd) +VCard21ParserImpl::VCard21ParserImpl(Q3ValueList<VCardLineX> *_vcd) : _vcdata(_vcd) { } QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifier) { QString failed; const QString lowname = name.lower(); const QString lowqualifier = qualifier.lower(); - for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { if ((*i).parameters.count() > 0) return (*i).parameters[0]; else return failed; } } return failed; } QString VCard21ParserImpl::getValue(const QString& name) { QString failed; const QString lowname = name.lower(); - for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { if ((*i).name == lowname && !(*i).qualified) { if ((*i).parameters.count() > 0) return (*i).parameters[0]; else return failed; } } return failed; } QStringList VCard21ParserImpl::getValues(const QString& name) { const QString lowname = name.lower(); - for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { - if ((*i).name == lowname && !(*i).qualified) - return (*i).parameters; + for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + if ((*i).name == lowname && !(*i).qualified) { + return QStringList( (*i).parameters ); + } } // failed. return QStringList(); } QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qualifier) { const QString lowname = name.lower(); const QString lowqualifier = qualifier.lower(); - for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { + for (Q3ValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) - return (*i).parameters; + return QStringList( (*i).parameters ); } // failed. return QStringList(); } |