author | zautrix <zautrix> | 2005-03-11 07:56:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-11 07:56:35 (UTC) |
commit | ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66 (patch) (side-by-side diff) | |
tree | ee14e30b5bb0a9519cb211f94e917f985be42e5f | |
parent | b6845008e161e1bb355a32767c3e3f89ff8e5c01 (diff) | |
download | kdepimpi-ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66.zip kdepimpi-ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66.tar.gz kdepimpi-ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66.tar.bz2 |
missing include
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 32b6c1e..0cf72c0 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp @@ -1,214 +1,215 @@ /* This file is part of libkabc. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qdatastream.h> #include <qstring.h> +#include <qregexp.h> #include "agent.h" #include "key.h" #include "picture.h" #include "secrecy.h" #include "sound.h" #include "vcardtool.h" using namespace KABC; VCardTool::VCardTool() { mAddressTypeMap.insert( "dom", Address::Dom ); mAddressTypeMap.insert( "intl", Address::Intl ); mAddressTypeMap.insert( "postal", Address::Postal ); mAddressTypeMap.insert( "parcel", Address::Parcel ); mAddressTypeMap.insert( "home", Address::Home ); mAddressTypeMap.insert( "work", Address::Work ); mAddressTypeMap.insert( "pref", Address::Pref ); mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); } VCardTool::~VCardTool() { } // TODO: make list a const& QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) { VCard::List vCardList; static const QRegExp semiExp(";"); Addressee::List::ConstIterator addrIt; Addressee::List::ConstIterator listEnd( list.end() ); for ( addrIt = list.begin(); addrIt != listEnd; ++addrIt ) { VCard card; QStringList::ConstIterator strIt; // ADR + LABEL const Address::List addresses = (*addrIt).addresses(); for ( Address::List::ConstIterator it = addresses.begin(); it != addresses.end(); ++it ) { QStringList address; bool isEmpty = ( (*it).postOfficeBox().isEmpty() && (*it).extended().isEmpty() && (*it).street().isEmpty() && (*it).locality().isEmpty() && (*it).region().isEmpty() && (*it).postalCode().isEmpty() && (*it).country().isEmpty() ); address.append( (*it).postOfficeBox().replace( semiExp, "\\;" ) ); address.append( (*it).extended().replace( semiExp, "\\;" ) ); address.append( (*it).street().replace( semiExp, "\\;" ) ); address.append( (*it).locality().replace( semiExp, "\\;" ) ); address.append( (*it).region().replace( semiExp, "\\;" ) ); address.append( (*it).postalCode().replace( semiExp, "\\;" ) ); address.append( (*it).country().replace( semiExp, "\\;" ) ); VCardLine adrLine( "ADR", address.join( ";" ) ); if ( version == VCard::v2_1 ) { adrLine.addParameter( "CHARSET", "UTF-8" ); adrLine.addParameter( "ENCODING", "8BIT" ); } VCardLine labelLine( "LABEL", (*it).label() ); if ( version == VCard::v2_1 ) { labelLine.addParameter( "CHARSET", "UTF-8" ); labelLine.addParameter( "ENCODING", "8BIT" ); } bool hasLabel = !(*it).label().isEmpty(); QMap<QString, int>::ConstIterator typeIt; for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { if ( typeIt.data() & (*it).type() ) { adrLine.addParameter( "TYPE", typeIt.key() ); if ( hasLabel ) labelLine.addParameter( "TYPE", typeIt.key() ); } } if ( !isEmpty ) card.addLine( adrLine ); if ( hasLabel ) card.addLine( labelLine ); } // AGENT card.addLine( createAgent( version, (*addrIt).agent() ) ); // BDAY card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); // CATEGORIES if ( version == VCard::v3_0 ) { QStringList categories = (*addrIt).categories(); QStringList::Iterator catIt; for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) (*catIt).replace( QRegExp(","), "\\," ); VCardLine catLine( "CATEGORIES", categories.join( "," ) ); if ( version == VCard::v2_1 ) { catLine.addParameter( "CHARSET", "UTF-8" ); catLine.addParameter( "ENCODING", "8BIT" ); } card.addLine( catLine ); } // CLASS if ( version == VCard::v3_0 ) { card.addLine( createSecrecy( (*addrIt).secrecy() ) ); } // EMAIL const QStringList emails = (*addrIt).emails(); bool pref = true; for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { VCardLine line( "EMAIL", *strIt ); if ( version == VCard::v2_1 ) { line.addParameter( "CHARSET", "UTF-8" ); line.addParameter( "ENCODING", "8BIT" ); } if ( pref == true && emails.count() > 1 ) { line.addParameter( "TYPE", "PREF" ); pref = false; } card.addLine( line ); } // FN VCardLine fnLine( "FN", (*addrIt).formattedName() ); if ( version == VCard::v2_1 ) { fnLine.addParameter( "CHARSET", "UTF-8" ); fnLine.addParameter( "ENCODING", "8BIT" ); } card.addLine( fnLine ); // GEO Geo geo = (*addrIt).geo(); if ( geo.isValid() ) { QString str; str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); card.addLine( VCardLine( "GEO", str ) ); } // KEY const Key::List keys = (*addrIt).keys(); Key::List::ConstIterator keyIt; for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) card.addLine( createKey( *keyIt ) ); // LOGO card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); // MAILER VCardLine mailerLine( "MAILER", (*addrIt).mailer() ); if ( version == VCard::v2_1 ) { mailerLine.addParameter( "CHARSET", "UTF-8" ); mailerLine.addParameter( "ENCODING", "8BIT" ); } card.addLine( mailerLine ); // N QStringList name; name.append( (*addrIt).familyName().replace( semiExp, "\\;" ) ); name.append( (*addrIt).givenName().replace( semiExp, "\\;" ) ); name.append( (*addrIt).additionalName().replace( semiExp, "\\;" ) ); name.append( (*addrIt).prefix().replace( semiExp, "\\;" ) ); name.append( (*addrIt).suffix().replace( semiExp, "\\;" ) ); VCardLine nLine( "N", name.join( ";" ) ); if ( version == VCard::v2_1 ) { nLine.addParameter( "CHARSET", "UTF-8" ); nLine.addParameter( "ENCODING", "8BIT" ); } card.addLine( nLine ); |