summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-11 07:56:35 (UTC)
committer zautrix <zautrix>2005-03-11 07:56:35 (UTC)
commitee802b5ac60e084365e60ee2bdc0b8a9e8e72c66 (patch) (unidiff)
treeee14e30b5bb0a9519cb211f94e917f985be42e5f
parentb6845008e161e1bb355a32767c3e3f89ff8e5c01 (diff)
downloadkdepimpi-ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66.zip
kdepimpi-ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66.tar.gz
kdepimpi-ee802b5ac60e084365e60ee2bdc0b8a9e8e72c66.tar.bz2
missing include
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardparser/vcardtool.cpp1
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,118 +1,119 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdatastream.h> 21#include <qdatastream.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qregexp.h>
23 24
24#include "agent.h" 25#include "agent.h"
25#include "key.h" 26#include "key.h"
26#include "picture.h" 27#include "picture.h"
27#include "secrecy.h" 28#include "secrecy.h"
28#include "sound.h" 29#include "sound.h"
29 30
30#include "vcardtool.h" 31#include "vcardtool.h"
31 32
32using namespace KABC; 33using namespace KABC;
33 34
34VCardTool::VCardTool() 35VCardTool::VCardTool()
35{ 36{
36 mAddressTypeMap.insert( "dom", Address::Dom ); 37 mAddressTypeMap.insert( "dom", Address::Dom );
37 mAddressTypeMap.insert( "intl", Address::Intl ); 38 mAddressTypeMap.insert( "intl", Address::Intl );
38 mAddressTypeMap.insert( "postal", Address::Postal ); 39 mAddressTypeMap.insert( "postal", Address::Postal );
39 mAddressTypeMap.insert( "parcel", Address::Parcel ); 40 mAddressTypeMap.insert( "parcel", Address::Parcel );
40 mAddressTypeMap.insert( "home", Address::Home ); 41 mAddressTypeMap.insert( "home", Address::Home );
41 mAddressTypeMap.insert( "work", Address::Work ); 42 mAddressTypeMap.insert( "work", Address::Work );
42 mAddressTypeMap.insert( "pref", Address::Pref ); 43 mAddressTypeMap.insert( "pref", Address::Pref );
43 44
44 mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); 45 mPhoneTypeMap.insert( "HOME", PhoneNumber::Home );
45 mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); 46 mPhoneTypeMap.insert( "WORK", PhoneNumber::Work );
46 mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); 47 mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg );
47 mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); 48 mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref );
48 mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); 49 mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice );
49 mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); 50 mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax );
50 mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); 51 mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell );
51 mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); 52 mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video );
52 mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); 53 mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs );
53 mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); 54 mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem );
54 mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); 55 mPhoneTypeMap.insert( "CAR", PhoneNumber::Car );
55 mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); 56 mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn );
56 mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); 57 mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs );
57 mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); 58 mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager );
58} 59}
59 60
60VCardTool::~VCardTool() 61VCardTool::~VCardTool()
61{ 62{
62} 63}
63 64
64// TODO: make list a const& 65// TODO: make list a const&
65QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) 66QString VCardTool::createVCards( Addressee::List list, VCard::Version version )
66{ 67{
67 VCard::List vCardList; 68 VCard::List vCardList;
68 static const QRegExp semiExp(";"); 69 static const QRegExp semiExp(";");
69 70
70 Addressee::List::ConstIterator addrIt; 71 Addressee::List::ConstIterator addrIt;
71 Addressee::List::ConstIterator listEnd( list.end() ); 72 Addressee::List::ConstIterator listEnd( list.end() );
72 for ( addrIt = list.begin(); addrIt != listEnd; ++addrIt ) { 73 for ( addrIt = list.begin(); addrIt != listEnd; ++addrIt ) {
73 VCard card; 74 VCard card;
74 QStringList::ConstIterator strIt; 75 QStringList::ConstIterator strIt;
75 76
76 // ADR + LABEL 77 // ADR + LABEL
77 const Address::List addresses = (*addrIt).addresses(); 78 const Address::List addresses = (*addrIt).addresses();
78 for ( Address::List::ConstIterator it = addresses.begin(); it != addresses.end(); ++it ) { 79 for ( Address::List::ConstIterator it = addresses.begin(); it != addresses.end(); ++it ) {
79 QStringList address; 80 QStringList address;
80 81
81 bool isEmpty = ( (*it).postOfficeBox().isEmpty() && 82 bool isEmpty = ( (*it).postOfficeBox().isEmpty() &&
82 (*it).extended().isEmpty() && 83 (*it).extended().isEmpty() &&
83 (*it).street().isEmpty() && 84 (*it).street().isEmpty() &&
84 (*it).locality().isEmpty() && 85 (*it).locality().isEmpty() &&
85 (*it).region().isEmpty() && 86 (*it).region().isEmpty() &&
86 (*it).postalCode().isEmpty() && 87 (*it).postalCode().isEmpty() &&
87 (*it).country().isEmpty() ); 88 (*it).country().isEmpty() );
88 89
89 address.append( (*it).postOfficeBox().replace( semiExp, "\\;" ) ); 90 address.append( (*it).postOfficeBox().replace( semiExp, "\\;" ) );
90 address.append( (*it).extended().replace( semiExp, "\\;" ) ); 91 address.append( (*it).extended().replace( semiExp, "\\;" ) );
91 address.append( (*it).street().replace( semiExp, "\\;" ) ); 92 address.append( (*it).street().replace( semiExp, "\\;" ) );
92 address.append( (*it).locality().replace( semiExp, "\\;" ) ); 93 address.append( (*it).locality().replace( semiExp, "\\;" ) );
93 address.append( (*it).region().replace( semiExp, "\\;" ) ); 94 address.append( (*it).region().replace( semiExp, "\\;" ) );
94 address.append( (*it).postalCode().replace( semiExp, "\\;" ) ); 95 address.append( (*it).postalCode().replace( semiExp, "\\;" ) );
95 address.append( (*it).country().replace( semiExp, "\\;" ) ); 96 address.append( (*it).country().replace( semiExp, "\\;" ) );
96 97
97 VCardLine adrLine( "ADR", address.join( ";" ) ); 98 VCardLine adrLine( "ADR", address.join( ";" ) );
98 if ( version == VCard::v2_1 ) { 99 if ( version == VCard::v2_1 ) {
99 adrLine.addParameter( "CHARSET", "UTF-8" ); 100 adrLine.addParameter( "CHARSET", "UTF-8" );
100 adrLine.addParameter( "ENCODING", "8BIT" ); 101 adrLine.addParameter( "ENCODING", "8BIT" );
101 } 102 }
102 103
103 VCardLine labelLine( "LABEL", (*it).label() ); 104 VCardLine labelLine( "LABEL", (*it).label() );
104 if ( version == VCard::v2_1 ) { 105 if ( version == VCard::v2_1 ) {
105 labelLine.addParameter( "CHARSET", "UTF-8" ); 106 labelLine.addParameter( "CHARSET", "UTF-8" );
106 labelLine.addParameter( "ENCODING", "8BIT" ); 107 labelLine.addParameter( "ENCODING", "8BIT" );
107 } 108 }
108 109
109 bool hasLabel = !(*it).label().isEmpty(); 110 bool hasLabel = !(*it).label().isEmpty();
110 QMap<QString, int>::ConstIterator typeIt; 111 QMap<QString, int>::ConstIterator typeIt;
111 for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { 112 for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) {
112 if ( typeIt.data() & (*it).type() ) { 113 if ( typeIt.data() & (*it).type() ) {
113 adrLine.addParameter( "TYPE", typeIt.key() ); 114 adrLine.addParameter( "TYPE", typeIt.key() );
114 if ( hasLabel ) 115 if ( hasLabel )
115 labelLine.addParameter( "TYPE", typeIt.key() ); 116 labelLine.addParameter( "TYPE", typeIt.key() );
116 } 117 }
117 } 118 }
118 119