author | zautrix <zautrix> | 2005-03-10 22:11:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-10 22:11:30 (UTC) |
commit | b6845008e161e1bb355a32767c3e3f89ff8e5c01 (patch) (unidiff) | |
tree | b1618c2a81ee8fa26d00332352fde82f2e3e51c9 | |
parent | 6e3c3178fa8e0c421753c08506b4a91bbcecc26f (diff) | |
download | kdepimpi-b6845008e161e1bb355a32767c3e3f89ff8e5c01.zip kdepimpi-b6845008e161e1bb355a32767c3e3f89ff8e5c01.tar.gz kdepimpi-b6845008e161e1bb355a32767c3e3f89ff8e5c01.tar.bz2 |
quoted printable for kapi
-rw-r--r-- | kabc/vcardparser/vcard.cpp | 84 | ||||
-rw-r--r-- | kabc/vcardparser/vcard.h | 11 | ||||
-rw-r--r-- | kabc/vcardparser/vcardline.cpp | 115 | ||||
-rw-r--r-- | kabc/vcardparser/vcardline.h | 31 | ||||
-rw-r--r-- | kabc/vcardparser/vcardparser.cpp | 131 | ||||
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 484 |
6 files changed, 425 insertions, 431 deletions
diff --git a/kabc/vcardparser/vcard.cpp b/kabc/vcardparser/vcard.cpp index da97ec2..24fd498 100644 --- a/kabc/vcardparser/vcard.cpp +++ b/kabc/vcardparser/vcard.cpp | |||
@@ -25,3 +25,2 @@ using namespace KABC; | |||
25 | VCard::VCard() | 25 | VCard::VCard() |
26 | : mLineMap( 0 ) | ||
27 | { | 26 | { |
@@ -30,13 +29,4 @@ VCard::VCard() | |||
30 | VCard::VCard( const VCard& vcard ) | 29 | VCard::VCard( const VCard& vcard ) |
31 | : mLineMap( 0 ) | ||
32 | { | 30 | { |
33 | if ( vcard.mLineMap ) { | 31 | mLineMap = vcard.mLineMap; |
34 | if ( !mLineMap ) | ||
35 | mLineMap = new QMap<QString, QValueList<VCardLine> >; | ||
36 | |||
37 | *mLineMap = *(vcard.mLineMap); | ||
38 | } else { | ||
39 | delete mLineMap; | ||
40 | mLineMap = 0; | ||
41 | } | ||
42 | } | 32 | } |
@@ -45,4 +35,2 @@ VCard::~VCard() | |||
45 | { | 35 | { |
46 | delete mLineMap; | ||
47 | mLineMap = 0; | ||
48 | } | 36 | } |
@@ -54,11 +42,3 @@ VCard& VCard::operator=( const VCard& vcard ) | |||
54 | 42 | ||
55 | if ( vcard.mLineMap ) { | 43 | mLineMap = vcard.mLineMap; |
56 | if ( !mLineMap ) | ||
57 | mLineMap = new QMap<QString, QValueList<VCardLine> >; | ||
58 | |||
59 | *mLineMap = *(vcard.mLineMap); | ||
60 | } else { | ||
61 | delete mLineMap; | ||
62 | mLineMap = 0; | ||
63 | } | ||
64 | 44 | ||
@@ -69,4 +49,3 @@ void VCard::clear() | |||
69 | { | 49 | { |
70 | if ( mLineMap ) | 50 | mLineMap.clear(); |
71 | mLineMap->clear(); | ||
72 | } | 51 | } |
@@ -75,12 +54,9 @@ QStringList VCard::identifiers() const | |||
75 | { | 54 | { |
76 | if ( !mLineMap ) | 55 | //return mLineMap.keys(); |
77 | return QStringList(); | 56 | //PP re: US method QMap::keys() not available yet. SO collect the data manually |
78 | else { | 57 | |
79 | //US method QMap::keys() not available yet. SO collect the data manually | ||
80 | //US return mLineMap->keys(); | ||
81 | |||
82 | QStringList result; | 58 | QStringList result; |
83 | 59 | ||
84 | QMap< QString, VCardLine::List >::ConstIterator it; | 60 | QMap<QString, VCardLine::List>::ConstIterator it; |
85 | for( it = mLineMap->begin(); it != mLineMap->end(); ++it ) { | 61 | for( it = mLineMap.begin(); it != mLineMap.end(); ++it ) { |
86 | result << it.key().latin1(); | 62 | result << it.key().latin1(); |
@@ -88,3 +64,2 @@ QStringList VCard::identifiers() const | |||
88 | return result; | 64 | return result; |
89 | } | ||
90 | } | 65 | } |
@@ -93,22 +68,24 @@ void VCard::addLine( const VCardLine& line ) | |||
93 | { | 68 | { |
94 | if ( !mLineMap ) | 69 | mLineMap[ line.identifier() ].append( line ); |
95 | mLineMap = new QMap<QString, QValueList<VCardLine> >; | ||
96 | |||
97 | (*mLineMap)[ line.identifier() ].append( line ); | ||
98 | } | 70 | } |
99 | 71 | ||
100 | VCardLine::List VCard::lines( const QString& identifier ) | 72 | VCardLine::List VCard::lines( const QString& identifier ) const |
101 | { | 73 | { |
102 | if ( !mLineMap ) | 74 | LineMap::ConstIterator it = mLineMap.find( identifier ); |
75 | if ( it == mLineMap.end() ) | ||
103 | return VCardLine::List(); | 76 | return VCardLine::List(); |
104 | else | 77 | |
105 | return (*mLineMap)[ identifier ]; | 78 | return *it; |
106 | } | 79 | } |
107 | 80 | ||
108 | VCardLine VCard::line( const QString& identifier ) | 81 | VCardLine VCard::line( const QString& identifier ) const |
109 | { | 82 | { |
110 | if ( !mLineMap ) | 83 | LineMap::ConstIterator it = mLineMap.find( identifier ); |
84 | if ( it == mLineMap.end() ) | ||
85 | return VCardLine(); | ||
86 | |||
87 | if ( (*it).isEmpty() ) | ||
111 | return VCardLine(); | 88 | return VCardLine(); |
112 | else | 89 | else |
113 | return (*mLineMap)[ identifier ][ 0 ]; | 90 | return (*it).first(); |
114 | } | 91 | } |
@@ -117,8 +94,4 @@ void VCard::setVersion( Version version ) | |||
117 | { | 94 | { |
118 | if ( !mLineMap ) | 95 | mLineMap.remove( "VERSION" ); |
119 | mLineMap = new QMap<QString, QValueList<VCardLine> >; | 96 | |
120 | else { | ||
121 | //US mLineMap->erase( "VERSION" ); | ||
122 | mLineMap->remove( "VERSION" ); | ||
123 | } | ||
124 | VCardLine line; | 97 | VCardLine line; |
@@ -127,6 +100,6 @@ void VCard::setVersion( Version version ) | |||
127 | line.setIdentifier( "2.1" ); | 100 | line.setIdentifier( "2.1" ); |
128 | if ( version == v3_0 ) | 101 | else if ( version == v3_0 ) |
129 | line.setIdentifier( "3.0" ); | 102 | line.setIdentifier( "3.0" ); |
130 | 103 | ||
131 | (*mLineMap)[ "VERSION" ].append( line ); | 104 | mLineMap[ "VERSION" ].append( line ); |
132 | } | 105 | } |
@@ -135,6 +108,7 @@ VCard::Version VCard::version() const | |||
135 | { | 108 | { |
136 | if ( !mLineMap ) | 109 | LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" ); |
110 | if ( versionEntry == mLineMap.end() ) | ||
137 | return v3_0; | 111 | return v3_0; |
138 | 112 | ||
139 | VCardLine line = (*mLineMap)[ "VERSION" ][ 0 ]; | 113 | VCardLine line = ( *versionEntry )[ 0 ]; |
140 | if ( line.value() == "2.1" ) | 114 | if ( line.value() == "2.1" ) |
diff --git a/kabc/vcardparser/vcard.h b/kabc/vcardparser/vcard.h index ce672b5..0bee441 100644 --- a/kabc/vcardparser/vcard.h +++ b/kabc/vcardparser/vcard.h | |||
@@ -20,4 +20,4 @@ | |||
20 | 20 | ||
21 | #ifndef VCARD_H | 21 | #ifndef VCARDPARSER_VCARD_H |
22 | #define VCARD_H | 22 | #define VCARDPARSER_VCARD_H |
23 | 23 | ||
@@ -34,2 +34,3 @@ class VCard | |||
34 | typedef QValueList<VCard> List; | 34 | typedef QValueList<VCard> List; |
35 | typedef QMap< QString, VCardLine::List > LineMap; | ||
35 | 36 | ||
@@ -63,3 +64,3 @@ class VCard | |||
63 | */ | 64 | */ |
64 | VCardLine::List lines( const QString& identifier ); | 65 | VCardLine::List lines( const QString& identifier ) const; |
65 | 66 | ||
@@ -68,3 +69,3 @@ class VCard | |||
68 | */ | 69 | */ |
69 | VCardLine line( const QString& identifier ); | 70 | VCardLine line( const QString& identifier ) const; |
70 | 71 | ||
@@ -81,3 +82,3 @@ class VCard | |||
81 | private: | 82 | private: |
82 | QMap< QString, VCardLine::List > *mLineMap; | 83 | LineMap mLineMap; |
83 | 84 | ||
diff --git a/kabc/vcardparser/vcardline.cpp b/kabc/vcardparser/vcardline.cpp index 84638f8..0972a35 100644 --- a/kabc/vcardparser/vcardline.cpp +++ b/kabc/vcardparser/vcardline.cpp | |||
@@ -24,4 +24,10 @@ using namespace KABC; | |||
24 | 24 | ||
25 | class VCardLine::VCardLinePrivate | ||
26 | { | ||
27 | public: | ||
28 | QString mGroup; | ||
29 | }; | ||
30 | |||
25 | VCardLine::VCardLine() | 31 | VCardLine::VCardLine() |
26 | : mParamMap( 0 ) | 32 | : d( 0 ) |
27 | { | 33 | { |
@@ -30,3 +36,3 @@ VCardLine::VCardLine() | |||
30 | VCardLine::VCardLine( const QString &identifier ) | 36 | VCardLine::VCardLine( const QString &identifier ) |
31 | : mParamMap( 0 ) | 37 | : d( 0 ) |
32 | { | 38 | { |
@@ -35,7 +41,7 @@ VCardLine::VCardLine( const QString &identifier ) | |||
35 | 41 | ||
36 | VCardLine::VCardLine( const QString &identifier, const QVariant &value ) | 42 | VCardLine::VCardLine( const QString &identifier, const QString &value ) |
37 | : mParamMap( 0 ) | 43 | : d( 0 ) |
38 | { | 44 | { |
39 | mIdentifier = identifier; | 45 | mIdentifier = identifier; |
40 | mValue = value; | 46 | mValue.assign( value.data(), value.length() ); |
41 | } | 47 | } |
@@ -43,14 +49,5 @@ VCardLine::VCardLine( const QString &identifier, const QVariant &value ) | |||
43 | VCardLine::VCardLine( const VCardLine& line ) | 49 | VCardLine::VCardLine( const VCardLine& line ) |
44 | : mParamMap( 0 ) | 50 | : d( 0 ) |
45 | { | 51 | { |
46 | if ( line.mParamMap ) { | 52 | mParamMap = line.mParamMap; |
47 | if ( !mParamMap ) | ||
48 | mParamMap = new QMap<QString, QStringList>; | ||
49 | |||
50 | *mParamMap = *(line.mParamMap); | ||
51 | } else { | ||
52 | delete mParamMap; | ||
53 | mParamMap = 0; | ||
54 | } | ||
55 | |||
56 | mValue = line.mValue; | 53 | mValue = line.mValue; |
@@ -61,4 +58,4 @@ VCardLine::~VCardLine() | |||
61 | { | 58 | { |
62 | delete mParamMap; | 59 | delete d; |
63 | mParamMap = 0; | 60 | d = 0; |
64 | } | 61 | } |
@@ -70,12 +67,3 @@ VCardLine& VCardLine::operator=( const VCardLine& line ) | |||
70 | 67 | ||
71 | if ( line.mParamMap ) { | 68 | mParamMap = line.mParamMap; |
72 | if ( !mParamMap ) | ||
73 | mParamMap = new QMap<QString, QStringList>; | ||
74 | |||
75 | *mParamMap = *(line.mParamMap); | ||
76 | } else { | ||
77 | delete mParamMap; | ||
78 | mParamMap = 0; | ||
79 | } | ||
80 | |||
81 | mValue = line.mValue; | 69 | mValue = line.mValue; |
@@ -95,3 +83,9 @@ QString VCardLine::identifier() const | |||
95 | } | 83 | } |
96 | void VCardLine::setValue( const QVariant& value ) | 84 | |
85 | void VCardLine::setValue( const QString& value ) | ||
86 | { | ||
87 | mValue.duplicate( value.data(), value.length() ); | ||
88 | } | ||
89 | |||
90 | void VCardLine::setValue( const QByteArray& value ) | ||
97 | { | 91 | { |
@@ -102,2 +96,7 @@ QVariant VCardLine::value() const | |||
102 | { | 96 | { |
97 | return QVariant( QCString( mValue.data(), mValue.size()+1 ) ); | ||
98 | } | ||
99 | |||
100 | QByteArray VCardLine::valueBytes() const | ||
101 | { | ||
103 | return mValue; | 102 | return mValue; |
@@ -105,14 +104,36 @@ QVariant VCardLine::value() const | |||
105 | 104 | ||
105 | void VCardLine::setGroup( const QString& group ) | ||
106 | { | ||
107 | if ( !d ) | ||
108 | d = new VCardLinePrivate(); | ||
109 | |||
110 | d->mGroup = group; | ||
111 | } | ||
112 | |||
113 | QString VCardLine::group() const | ||
114 | { | ||
115 | if ( d ) | ||
116 | return d->mGroup; | ||
117 | else | ||
118 | return QString(); | ||
119 | } | ||
120 | |||
121 | bool VCardLine::hasGroup() const | ||
122 | { | ||
123 | if ( !d ) | ||
124 | return false; | ||
125 | else | ||
126 | return d->mGroup.isEmpty(); | ||
127 | } | ||
128 | |||
106 | QStringList VCardLine::parameterList() const | 129 | QStringList VCardLine::parameterList() const |
107 | { | 130 | { |
108 | if ( !mParamMap ) | 131 | //return mParamMap.keys(); |
109 | return QStringList(); | ||
110 | else { | ||
111 | //US method QMap::keys() not available yet. SO collect the data manually | 132 | //US method QMap::keys() not available yet. SO collect the data manually |
112 | //US return mParamMap->keys(); | 133 | //US return mParamMap->keys(); |
113 | 134 | ||
114 | QStringList result; | 135 | QStringList result; |
115 | 136 | ||
116 | QMap<QString, QStringList>::ConstIterator it; | 137 | QMap<QString, QStringList>::ConstIterator it; |
117 | for( it = mParamMap->begin(); it != mParamMap->end(); ++it ) { | 138 | for( it = mParamMap.begin(); it != mParamMap.end(); ++it ) { |
118 | result << it.key().latin1(); | 139 | result << it.key().latin1(); |
@@ -120,3 +141,2 @@ QStringList VCardLine::parameterList() const | |||
120 | return result; | 141 | return result; |
121 | } | ||
122 | } | 142 | } |
@@ -125,7 +145,4 @@ void VCardLine::addParameter( const QString& param, const QString& value ) | |||
125 | { | 145 | { |
126 | if ( !mParamMap ) | 146 | QStringList &list = mParamMap[ param ]; |
127 | mParamMap = new QMap<QString, QStringList>; | 147 | if ( list.findIndex( value ) == -1 ) // not included yet |
128 | |||
129 | QStringList &list = (*mParamMap)[ param ]; | ||
130 | if ( list.find( value ) == list.end() ) // not included yet | ||
131 | list.append( value ); | 148 | list.append( value ); |
@@ -135,6 +152,7 @@ QStringList VCardLine::parameters( const QString& param ) const | |||
135 | { | 152 | { |
136 | if ( !mParamMap ) | 153 | ParamMap::ConstIterator it = mParamMap.find( param ); |
154 | if ( it == mParamMap.end() ) | ||
137 | return QStringList(); | 155 | return QStringList(); |
138 | else | 156 | else |
139 | return (*mParamMap)[ param ]; | 157 | return *it; |
140 | } | 158 | } |
@@ -143,6 +161,11 @@ QString VCardLine::parameter( const QString& param ) const | |||
143 | { | 161 | { |
144 | if ( !mParamMap ) | 162 | ParamMap::ConstIterator it = mParamMap.find( param ); |
163 | if ( it == mParamMap.end() ) | ||
145 | return QString::null; | 164 | return QString::null; |
146 | else | 165 | else { |
147 | return (*mParamMap)[ param ][ 0 ]; | 166 | if ( (*it).isEmpty() ) |
167 | return QString::null; | ||
168 | else | ||
169 | return (*it).first(); | ||
170 | } | ||
148 | } | 171 | } |
diff --git a/kabc/vcardparser/vcardline.h b/kabc/vcardparser/vcardline.h index 78b61f8..6e74b38 100644 --- a/kabc/vcardparser/vcardline.h +++ b/kabc/vcardparser/vcardline.h | |||
@@ -25,2 +25,3 @@ | |||
25 | #include <qvaluelist.h> | 25 | #include <qvaluelist.h> |
26 | #include <qcstring.h> | ||
26 | #include <qvariant.h> | 27 | #include <qvariant.h> |
@@ -35,2 +36,3 @@ class VCardLine | |||
35 | typedef QValueList<VCardLine> List; | 36 | typedef QValueList<VCardLine> List; |
37 | typedef QMap<QString, QStringList> ParamMap; | ||
36 | 38 | ||
@@ -38,3 +40,3 @@ class VCardLine | |||
38 | VCardLine( const QString &identifier ); | 40 | VCardLine( const QString &identifier ); |
39 | VCardLine( const QString &identifier, const QVariant &value ); | 41 | VCardLine( const QString &identifier, const QString &value ); |
40 | VCardLine( const VCardLine& ); | 42 | VCardLine( const VCardLine& ); |
@@ -58,3 +60,4 @@ class VCardLine | |||
58 | */ | 60 | */ |
59 | void setValue( const QVariant& value ); | 61 | void setValue( const QString& value ); |
62 | void setValue( const QByteArray& value ); | ||
60 | 63 | ||
@@ -64,2 +67,18 @@ class VCardLine | |||
64 | QVariant value() const; | 67 | QVariant value() const; |
68 | QByteArray valueBytes() const; | ||
69 | |||
70 | /** | ||
71 | * Sets the group the line belongs to. | ||
72 | */ | ||
73 | void setGroup( const QString& group ); | ||
74 | |||
75 | /** | ||
76 | * Returns the group the line belongs to. | ||
77 | */ | ||
78 | QString group() const; | ||
79 | |||
80 | /** | ||
81 | * Returns whether the line belongs to a group. | ||
82 | */ | ||
83 | bool hasGroup() const; | ||
65 | 84 | ||
@@ -77,3 +96,3 @@ class VCardLine | |||
77 | * Returns the values of a special parameter. | 96 | * Returns the values of a special parameter. |
78 | * You can get a list of all parameters with @ref paramList(). | 97 | * You can get a list of all parameters with paramList(). |
79 | */ | 98 | */ |
@@ -83,3 +102,3 @@ class VCardLine | |||
83 | * Returns only the first value of a special parameter. | 102 | * Returns only the first value of a special parameter. |
84 | * You can get a list of all parameters with @ref paramList(). | 103 | * You can get a list of all parameters with paramList(). |
85 | */ | 104 | */ |
@@ -88,5 +107,5 @@ class VCardLine | |||
88 | private: | 107 | private: |
89 | QMap< QString, QStringList > *mParamMap; | 108 | ParamMap mParamMap; |
90 | QString mIdentifier; | 109 | QString mIdentifier; |
91 | QVariant mValue; | 110 | QByteArray mValue; |
92 | 111 | ||
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp index bec2a0c..7fae011 100644 --- a/kabc/vcardparser/vcardparser.cpp +++ b/kabc/vcardparser/vcardparser.cpp | |||
@@ -40,2 +40,4 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
40 | { | 40 | { |
41 | static QRegExp sep( "[\x0d\x0a]" ); | ||
42 | |||
41 | VCard currentVCard; | 43 | VCard currentVCard; |
@@ -44,7 +46,8 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
44 | 46 | ||
45 | QStringList lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), text ); | 47 | const QStringList lines = QStringList::split( sep, text ); |
46 | QStringList::Iterator it; | 48 | QStringList::ConstIterator it; |
47 | 49 | ||
48 | bool inVCard = false; | 50 | bool inVCard = false; |
49 | for ( it = lines.begin(); it != lines.end(); ++it ) { | 51 | QStringList::ConstIterator linesEnd( lines.end() ); |
52 | for ( it = lines.begin(); it != linesEnd; ++it ) { | ||
50 | 53 | ||
@@ -54,3 +57,3 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
54 | if ( (*it)[ 0 ] == ' ' || (*it)[ 0 ] == '\t' ) { // folded line => append to previous | 57 | if ( (*it)[ 0 ] == ' ' || (*it)[ 0 ] == '\t' ) { // folded line => append to previous |
55 | currentLine += (*it).remove( 0, 1 ); | 58 | currentLine += QString( *it ).remove( 0, 1 ); |
56 | continue; | 59 | continue; |
@@ -65,3 +68,3 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
65 | VCardLine vCardLine; | 68 | VCardLine vCardLine; |
66 | QString key = currentLine.left( colon ).stripWhiteSpace(); | 69 | const QString key = currentLine.left( colon ).stripWhiteSpace(); |
67 | QString value = currentLine.mid( colon + 1 ); | 70 | QString value = currentLine.mid( colon + 1 ); |
@@ -69,14 +72,33 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
69 | QStringList params = QStringList::split( ';', key ); | 72 | QStringList params = QStringList::split( ';', key ); |
70 | vCardLine.setIdentifier( params[0] ); | 73 | |
74 | // check for group | ||
75 | if ( params[0].find( '.' ) != -1 ) { | ||
76 | const QStringList groupList = QStringList::split( '.', params[0] ); | ||
77 | vCardLine.setGroup( groupList[0] ); | ||
78 | vCardLine.setIdentifier( groupList[1] ); | ||
79 | } else | ||
80 | vCardLine.setIdentifier( params[0] ); | ||
81 | |||
71 | if ( params.count() > 1 ) { // find all parameters | 82 | if ( params.count() > 1 ) { // find all parameters |
72 | for ( uint i = 1; i < params.count(); ++i ) { | 83 | QStringList::ConstIterator paramIt = params.begin(); |
73 | QStringList pair = QStringList::split( '=', params[i] ); | 84 | for ( ++paramIt; paramIt != params.end(); ++paramIt ) { |
74 | //US if ( pair.size() == 1 ) { | 85 | QStringList pair = QStringList::split( '=', *paramIt ); |
75 | if ( pair.count() == 1 ) { | 86 | if ( pair.count() == 1 ) { |
87 | // correct the fucking 2.1 'standard' | ||
88 | if ( pair[0].lower() == "quoted-printable" ) { | ||
89 | pair[0] = "encoding"; | ||
90 | pair[1] = "quoted-printable"; | ||
91 | } else if ( pair[0].lower() == "base64" ) { | ||
92 | pair[0] = "encoding"; | ||
93 | pair[1] = "base64"; | ||
94 | } else { | ||
76 | pair.prepend( "type" ); | 95 | pair.prepend( "type" ); |
96 | } | ||
77 | } | 97 | } |
78 | if ( pair[1].contains( ',' ) ) { // parameter in type=x,y,z format | 98 | // This is pretty much a faster pair[1].contains( ',' )... |
79 | QStringList args = QStringList::split( ',', pair[ 1 ] ); | 99 | if ( pair[1].find( ',' ) != -1 ) { // parameter in type=x,y,z format |
80 | for ( uint j = 0; j < args.count(); ++j ) | 100 | const QStringList args = QStringList::split( ',', pair[ 1 ] ); |
81 | vCardLine.addParameter( pair[0].lower(), args[j] ); | 101 | QStringList::ConstIterator argIt; |
102 | for ( argIt = args.begin(); argIt != args.end(); ++argIt ) | ||
103 | vCardLine.addParameter( pair[0].lower(), *argIt ); | ||
82 | } else | 104 | } else |
@@ -87,32 +109,27 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
87 | params = vCardLine.parameterList(); | 109 | params = vCardLine.parameterList(); |
88 | if ( params.contains( "encoding" ) ) { // have to decode the data | 110 | if ( params.findIndex( "encoding" ) != -1 ) { // have to decode the data |
89 | #if 0 | ||
90 | QByteArray input, output; | 111 | QByteArray input, output; |
91 | input = value.local8Bit(); | 112 | if ( vCardLine.parameter( "encoding" ).lower() == "b" || |
92 | if ( vCardLine.parameter( "encoding" ).lower() == "b" ) | 113 | vCardLine.parameter( "encoding" ).lower() == "base64" ) { |
114 | input = value.local8Bit(); | ||
93 | KCodecs::base64Decode( input, output ); | 115 | KCodecs::base64Decode( input, output ); |
94 | else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) | 116 | } else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) { |
117 | // join any qp-folded lines | ||
118 | while ( value.mid(value.length()-1,1) == "=" && it != linesEnd ) { | ||
119 | value = value.remove( value.length()-1, 1 ) + (*it); | ||
120 | ++it; | ||
121 | } | ||
122 | input = value.local8Bit(); | ||
95 | KCodecs::quotedPrintableDecode( input, output ); | 123 | KCodecs::quotedPrintableDecode( input, output ); |
96 | 124 | } | |
97 | //qDebug("VCardParser::parseVCards has to be verified"); | 125 | //PP our vcards are *supposed* to be in UTF-8 |
98 | //US I am not sure if this is correct | 126 | // if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) { |
99 | //US vCardLine.setValue( output ); | 127 | // vCardLine.setValue( QString::fromUtf8( output.data(), output.size() ) ); |
100 | QCString cs(output); | 128 | // } else |
101 | qDebug("len1 %d len2 %d ",input.size(), output.size( )); | 129 | vCardLine.setValue( output ); |
102 | #endif | 130 | //PP our vcards are *supposed* to be in UTF-8 |
103 | QCString cs = value.local8Bit(); | 131 | // } else if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) { |
104 | qDebug("****************************************** "); | 132 | // vCardLine.setValue( QString::fromUtf8( value.ascii() ) ); |
105 | qDebug("************* WARNING ******************** "); | 133 | } else |
106 | qDebug("****************************************** "); | ||
107 | qDebug("Make sure, the decoding is done after"); | ||
108 | qDebug("QVariant conversion!"); | ||
109 | qDebug("Insert Line DECODING OKAY, where this is implemented"); | ||
110 | // use for decoding the above code! | ||
111 | vCardLine.setValue( cs ); | ||
112 | } else { | ||
113 | |||
114 | //qDebug("VCardParser::parseVCards has to be verified"); | ||
115 | //US vCardLine.setValue( value.replace( "\\n", "\n" ) ); | ||
116 | vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) ); | 134 | vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) ); |
117 | } | ||
118 | 135 | ||
@@ -120,2 +137,3 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
120 | } | 137 | } |
138 | |||
121 | // we do not save the start and end tag as vcardline | 139 | // we do not save the start and end tag as vcardline |
@@ -123,4 +141,2 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
123 | inVCard = true; | 141 | inVCard = true; |
124 | //qDebug("VCardParser::parseVCards has to be verified"); | ||
125 | //US currentLine.setLength( 0 ); | ||
126 | currentLine = ""; | 142 | currentLine = ""; |
@@ -133,4 +149,2 @@ VCard::List VCardParser::parseVCards( const QString& text ) | |||
133 | vCardList.append( currentVCard ); | 149 | vCardList.append( currentVCard ); |
134 | //qDebug("VCardParser::parseVCards has to be verified"); | ||
135 | //US currentLine.setLength( 0 ); | ||
136 | currentLine = ""; | 150 | currentLine = ""; |
@@ -157,6 +171,6 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
157 | QStringList::Iterator paramIt; | 171 | QStringList::Iterator paramIt; |
158 | QStringList::Iterator valueIt; | 172 | QStringList::ConstIterator valueIt; |
159 | 173 | ||
160 | VCardLine::List lines; | 174 | VCardLine::List lines; |
161 | VCardLine::List::Iterator lineIt; | 175 | VCardLine::List::ConstIterator lineIt; |
162 | VCard::List::ConstIterator cardIt; | 176 | VCard::List::ConstIterator cardIt; |
@@ -165,5 +179,5 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
165 | 179 | ||
166 | |||
167 | // iterate over the cards | 180 | // iterate over the cards |
168 | for ( cardIt = list.begin(); cardIt != list.end(); ++cardIt ) { | 181 | VCard::List::ConstIterator listEnd( list.end() ); |
182 | for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) { | ||
169 | text.append( "BEGIN:VCARD\r\n" ); | 183 | text.append( "BEGIN:VCARD\r\n" ); |
@@ -172,4 +186,3 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
172 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { | 186 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { |
173 | VCard card = (*cardIt); | 187 | lines = (*cardIt).lines( (*identIt) ); |
174 | lines = card.lines( (*identIt) ); | ||
175 | 188 | ||
@@ -178,3 +191,6 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
178 | if ( !(*lineIt).value().asString().isEmpty() ) { | 191 | if ( !(*lineIt).value().asString().isEmpty() ) { |
179 | textLine = (*lineIt).identifier(); | 192 | if ( (*lineIt).hasGroup() ) |
193 | textLine = (*lineIt).group() + "." + (*lineIt).identifier(); | ||
194 | else | ||
195 | textLine = (*lineIt).identifier(); | ||
180 | 196 | ||
@@ -200,10 +216,3 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
200 | QByteArray input, output; | 216 | QByteArray input, output; |
201 | 217 | input = (*lineIt).valueBytes(); | |
202 | qDebug("VCardParser::createVCards has to be verified"); | ||
203 | //US input = (*lineIt).value().toByteArray(); | ||
204 | |||
205 | //US I am not sure if this is correct | ||
206 | QCString cs ((*lineIt).value().toCString()); | ||
207 | input = cs; | ||
208 | |||
209 | if ( encodingType == "b" ) | 218 | if ( encodingType == "b" ) |
@@ -213,7 +222,5 @@ QString VCardParser::createVCards( const VCard::List& list ) | |||
213 | textLine.append( ":" + QString( output ) ); | 222 | textLine.append( ":" + QString( output ) ); |
214 | } else { | 223 | } else |
215 | qDebug("VCardParser::createVCards has to be verified"); | ||
216 | //US textLine.append( ":" + (*lineIt).value().asString().replace( "\n", "\\n" ) ); | ||
217 | textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) ); | 224 | textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) ); |
218 | } | 225 | |
219 | if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line | 226 | if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line |
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index d1f823b..32b6c1e 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp | |||
@@ -22,4 +22,2 @@ | |||
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qregexp.h> | ||
24 | #include <kmdcodec.h> | ||
25 | 23 | ||
@@ -59,3 +57,2 @@ VCardTool::VCardTool() | |||
59 | mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); | 57 | mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); |
60 | mPhoneTypeMap.insert( "SIP", PhoneNumber::Sip ); | ||
61 | } | 58 | } |
@@ -66,2 +63,3 @@ VCardTool::~VCardTool() | |||
66 | 63 | ||
64 | // TODO: make list a const& | ||
67 | QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | 65 | QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) |
@@ -69,5 +67,7 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
69 | VCard::List vCardList; | 67 | VCard::List vCardList; |
68 | static const QRegExp semiExp(";"); | ||
70 | 69 | ||
71 | Addressee::List::Iterator addrIt; | 70 | Addressee::List::ConstIterator addrIt; |
72 | for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { | 71 | Addressee::List::ConstIterator listEnd( list.end() ); |
72 | for ( addrIt = list.begin(); addrIt != listEnd; ++addrIt ) { | ||
73 | VCard card; | 73 | VCard card; |
@@ -76,46 +76,41 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
76 | // ADR + LABEL | 76 | // ADR + LABEL |
77 | Address::List addresses = (*addrIt).addresses(); | 77 | const Address::List addresses = (*addrIt).addresses(); |
78 | for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { | 78 | for ( Address::List::ConstIterator it = addresses.begin(); it != addresses.end(); ++it ) { |
79 | QStringList address; | 79 | QStringList address; |
80 | 80 | ||
81 | /*US | 81 | bool isEmpty = ( (*it).postOfficeBox().isEmpty() && |
82 | address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); | 82 | (*it).extended().isEmpty() && |
83 | address.append( (*it).extended().replace( ';', "\\;" ) ); | 83 | (*it).street().isEmpty() && |
84 | address.append( (*it).street().replace( ';', "\\;" ) ); | 84 | (*it).locality().isEmpty() && |
85 | address.append( (*it).locality().replace( ';', "\\;" ) ); | 85 | (*it).region().isEmpty() && |
86 | address.append( (*it).region().replace( ';', "\\;" ) ); | 86 | (*it).postalCode().isEmpty() && |
87 | address.append( (*it).postalCode().replace( ';', "\\;" ) ); | 87 | (*it).country().isEmpty() ); |
88 | address.append( (*it).country().replace( ';', "\\;" ) ); | 88 | |
89 | */ | 89 | address.append( (*it).postOfficeBox().replace( semiExp, "\\;" ) ); |
90 | //US using the old implementation instead | 90 | address.append( (*it).extended().replace( semiExp, "\\;" ) ); |
91 | //qDebug("VCardTool::createVCards has to be verified"); | 91 | address.append( (*it).street().replace( semiExp, "\\;" ) ); |
92 | address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); | 92 | address.append( (*it).locality().replace( semiExp, "\\;" ) ); |
93 | address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); | 93 | address.append( (*it).region().replace( semiExp, "\\;" ) ); |
94 | address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); | 94 | address.append( (*it).postalCode().replace( semiExp, "\\;" ) ); |
95 | address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); | 95 | address.append( (*it).country().replace( semiExp, "\\;" ) ); |
96 | address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); | ||
97 | address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); | ||
98 | address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); | ||
99 | 96 | ||
100 | VCardLine adrLine( "ADR", address.join( ";" ) ); | 97 | VCardLine adrLine( "ADR", address.join( ";" ) ); |
98 | if ( version == VCard::v2_1 ) { | ||
99 | adrLine.addParameter( "CHARSET", "UTF-8" ); | ||
100 | adrLine.addParameter( "ENCODING", "8BIT" ); | ||
101 | } | ||
102 | |||
101 | VCardLine labelLine( "LABEL", (*it).label() ); | 103 | VCardLine labelLine( "LABEL", (*it).label() ); |
104 | if ( version == VCard::v2_1 ) { | ||
105 | labelLine.addParameter( "CHARSET", "UTF-8" ); | ||
106 | labelLine.addParameter( "ENCODING", "8BIT" ); | ||
107 | } | ||
102 | 108 | ||
103 | bool hasLabel = !(*it).label().isEmpty(); | 109 | bool hasLabel = !(*it).label().isEmpty(); |
104 | QMap<QString, int>::Iterator typeIt; | 110 | QMap<QString, int>::ConstIterator typeIt; |
105 | for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { | 111 | for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { |
106 | if ( typeIt.data() & (*it).type() ) { | 112 | if ( typeIt.data() & (*it).type() ) { |
107 | if ( version == VCard::v3_0 ) { | 113 | adrLine.addParameter( "TYPE", typeIt.key() ); |
108 | adrLine.addParameter( "TYPE", typeIt.key().lower() ); | 114 | if ( hasLabel ) |
109 | } | 115 | labelLine.addParameter( "TYPE", typeIt.key() ); |
110 | else { | ||
111 | adrLine.addParameter( "TYPE", typeIt.key() ); | ||
112 | } | ||
113 | if ( hasLabel ) { | ||
114 | if ( version == VCard::v3_0 ) { | ||
115 | labelLine.addParameter( "TYPE", typeIt.key().lower() ); | ||
116 | } | ||
117 | else { | ||
118 | labelLine.addParameter( "TYPE", typeIt.key() ); | ||
119 | } | ||
120 | } | ||
121 | } | 116 | } |
@@ -123,3 +118,4 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
123 | 118 | ||
124 | card.addLine( adrLine ); | 119 | if ( !isEmpty ) |
120 | card.addLine( adrLine ); | ||
125 | if ( hasLabel ) | 121 | if ( hasLabel ) |
@@ -139,9 +135,11 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
139 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) | 135 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) |
140 | { | ||
141 | //US using the old implementation instead | ||
142 | // qDebug("VCardTool::createVCards has to be verified"); | ||
143 | //US (*catIt).replace( ',', "\\," ); | ||
144 | (*catIt).replace( QRegExp(","), "\\," ); | 136 | (*catIt).replace( QRegExp(","), "\\," ); |
137 | |||
138 | VCardLine catLine( "CATEGORIES", categories.join( "," ) ); | ||
139 | if ( version == VCard::v2_1 ) { | ||
140 | catLine.addParameter( "CHARSET", "UTF-8" ); | ||
141 | catLine.addParameter( "ENCODING", "8BIT" ); | ||
145 | } | 142 | } |
146 | card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) ); | 143 | |
144 | card.addLine( catLine ); | ||
147 | } | 145 | } |
@@ -152,5 +150,5 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
152 | } | 150 | } |
153 | 151 | ||
154 | 152 | ||
155 | QStringList emails = (*addrIt).emails(); | 153 | const QStringList emails = (*addrIt).emails(); |
156 | bool pref = true; | 154 | bool pref = true; |
@@ -158,3 +156,7 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
158 | VCardLine line( "EMAIL", *strIt ); | 156 | VCardLine line( "EMAIL", *strIt ); |
159 | if ( pref == true ) { | 157 | if ( version == VCard::v2_1 ) { |
158 | line.addParameter( "CHARSET", "UTF-8" ); | ||
159 | line.addParameter( "ENCODING", "8BIT" ); | ||
160 | } | ||
161 | if ( pref == true && emails.count() > 1 ) { | ||
160 | line.addParameter( "TYPE", "PREF" ); | 162 | line.addParameter( "TYPE", "PREF" ); |
@@ -166,3 +168,8 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
166 | // FN | 168 | // FN |
167 | card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) ); | 169 | VCardLine fnLine( "FN", (*addrIt).formattedName() ); |
170 | if ( version == VCard::v2_1 ) { | ||
171 | fnLine.addParameter( "CHARSET", "UTF-8" ); | ||
172 | fnLine.addParameter( "ENCODING", "8BIT" ); | ||
173 | } | ||
174 | card.addLine( fnLine ); | ||
168 | 175 | ||
@@ -177,3 +184,3 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
177 | // KEY | 184 | // KEY |
178 | Key::List keys = (*addrIt).keys(); | 185 | const Key::List keys = (*addrIt).keys(); |
179 | Key::List::ConstIterator keyIt; | 186 | Key::List::ConstIterator keyIt; |
@@ -186,3 +193,8 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
186 | // MAILER | 193 | // MAILER |
187 | card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) ); | 194 | VCardLine mailerLine( "MAILER", (*addrIt).mailer() ); |
195 | if ( version == VCard::v2_1 ) { | ||
196 | mailerLine.addParameter( "CHARSET", "UTF-8" ); | ||
197 | mailerLine.addParameter( "ENCODING", "8BIT" ); | ||
198 | } | ||
199 | card.addLine( mailerLine ); | ||
188 | 200 | ||
@@ -190,19 +202,22 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
190 | QStringList name; | 202 | QStringList name; |
191 | //US using the old implementation instead | 203 | name.append( (*addrIt).familyName().replace( semiExp, "\\;" ) ); |
192 | //qDebug("VCardTool::createVCards has to be verified"); | 204 | name.append( (*addrIt).givenName().replace( semiExp, "\\;" ) ); |
193 | /*US | 205 | name.append( (*addrIt).additionalName().replace( semiExp, "\\;" ) ); |
194 | name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); | 206 | name.append( (*addrIt).prefix().replace( semiExp, "\\;" ) ); |
195 | name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); | 207 | name.append( (*addrIt).suffix().replace( semiExp, "\\;" ) ); |
196 | name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); | 208 | |
197 | name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); | 209 | VCardLine nLine( "N", name.join( ";" ) ); |
198 | name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); | 210 | if ( version == VCard::v2_1 ) { |
199 | */ | 211 | nLine.addParameter( "CHARSET", "UTF-8" ); |
200 | name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) ); | 212 | nLine.addParameter( "ENCODING", "8BIT" ); |
201 | name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) ); | 213 | } |
202 | name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) ); | 214 | card.addLine( nLine ); |
203 | name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) ); | 215 | |
204 | name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) ); | 216 | // NAME |
205 | 217 | VCardLine nameLine( "NAME", (*addrIt).name() ); | |
206 | if ( !name.join( "" ).isEmpty() ) | 218 | if ( version == VCard::v2_1 ) { |
207 | card.addLine( VCardLine( "N", name.join( ";" ) ) ); | 219 | nameLine.addParameter( "CHARSET", "UTF-8" ); |
220 | nameLine.addParameter( "ENCODING", "8BIT" ); | ||
221 | } | ||
222 | card.addLine( nameLine ); | ||
208 | 223 | ||
@@ -213,6 +228,16 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
213 | // NOTE | 228 | // NOTE |
214 | card.addLine( VCardLine( "NOTE", (*addrIt).note() ) ); | 229 | VCardLine noteLine( "NOTE", (*addrIt).note() ); |
230 | if ( version == VCard::v2_1 ) { | ||
231 | noteLine.addParameter( "CHARSET", "UTF-8" ); | ||
232 | noteLine.addParameter( "ENCODING", "8BIT" ); | ||
233 | } | ||
234 | card.addLine( noteLine ); | ||
215 | 235 | ||
216 | // ORG | 236 | // ORG |
217 | card.addLine( VCardLine( "ORG", (*addrIt).organization() ) ); | 237 | VCardLine orgLine( "ORG", (*addrIt).organization() ); |
238 | if ( version == VCard::v2_1 ) { | ||
239 | orgLine.addParameter( "CHARSET", "UTF-8" ); | ||
240 | orgLine.addParameter( "ENCODING", "8BIT" ); | ||
241 | } | ||
242 | card.addLine( orgLine ); | ||
218 | 243 | ||
@@ -229,3 +254,8 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
229 | // ROLE | 254 | // ROLE |
230 | card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); | 255 | VCardLine roleLine( "ROLE", (*addrIt).role() ); |
256 | if ( version == VCard::v2_1 ) { | ||
257 | roleLine.addParameter( "CHARSET", "UTF-8" ); | ||
258 | roleLine.addParameter( "ENCODING", "8BIT" ); | ||
259 | } | ||
260 | card.addLine( roleLine ); | ||
231 | 261 | ||
@@ -239,3 +269,3 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
239 | // TEL | 269 | // TEL |
240 | PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); | 270 | const PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); |
241 | PhoneNumber::List::ConstIterator phoneIt; | 271 | PhoneNumber::List::ConstIterator phoneIt; |
@@ -244,9 +274,6 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
244 | 274 | ||
245 | QMap<QString, int>::Iterator typeIt; | 275 | QMap<QString, int>::ConstIterator typeIt; |
246 | for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { | 276 | for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { |
247 | if ( typeIt.data() & (*phoneIt).type() ) | 277 | if ( typeIt.data() & (*phoneIt).type() ) |
248 | if ( version == VCard::v3_0 ) | 278 | line.addParameter( "TYPE", typeIt.key() ); |
249 | line.addParameter( "TYPE", typeIt.key().lower() ); | ||
250 | else | ||
251 | line.addParameter( "TYPE", typeIt.key() ); | ||
252 | } | 279 | } |
@@ -257,3 +284,8 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
257 | // TITLE | 284 | // TITLE |
258 | card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); | 285 | VCardLine titleLine( "TITLE", (*addrIt).title() ); |
286 | if ( version == VCard::v2_1 ) { | ||
287 | titleLine.addParameter( "CHARSET", "UTF-8" ); | ||
288 | titleLine.addParameter( "ENCODING", "8BIT" ); | ||
289 | } | ||
290 | card.addLine( titleLine ); | ||
259 | 291 | ||
@@ -288,3 +320,3 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
288 | // X- | 320 | // X- |
289 | QStringList customs = (*addrIt).customs(); | 321 | const QStringList customs = (*addrIt).customs(); |
290 | for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { | 322 | for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { |
@@ -295,3 +327,8 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | |||
295 | 327 | ||
296 | card.addLine( VCardLine( identifier, value ) ); | 328 | VCardLine line( identifier, value ); |
329 | if ( version == VCard::v2_1 ) { | ||
330 | line.addParameter( "CHARSET", "UTF-8" ); | ||
331 | line.addParameter( "ENCODING", "8BIT" ); | ||
332 | } | ||
333 | card.addLine( line ); | ||
297 | } | 334 | } |
@@ -306,4 +343,4 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
306 | { | 343 | { |
307 | QChar semicolonSep( ';' ); | 344 | static const QChar semicolonSep( ';' ); |
308 | QChar commaSep( ',' ); | 345 | static const QChar commaSep( ',' ); |
309 | QString identifier; | 346 | QString identifier; |
@@ -311,12 +348,15 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
311 | Addressee::List addrList; | 348 | Addressee::List addrList; |
312 | VCard::List vCardList = VCardParser::parseVCards( vcard ); | 349 | const VCard::List vCardList = VCardParser::parseVCards( vcard ); |
313 | VCard::List::Iterator cardIt; | 350 | |
314 | for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) { | 351 | VCard::List::ConstIterator cardIt; |
352 | VCard::List::ConstIterator listEnd( vCardList.end() ); | ||
353 | for ( cardIt = vCardList.begin(); cardIt != listEnd; ++cardIt ) { | ||
315 | Addressee addr; | 354 | Addressee addr; |
316 | QStringList idents = (*cardIt).identifiers(); | 355 | |
356 | const QStringList idents = (*cardIt).identifiers(); | ||
317 | QStringList::ConstIterator identIt; | 357 | QStringList::ConstIterator identIt; |
318 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { | 358 | QStringList::ConstIterator identEnd( idents.end() ); |
319 | VCard card = (*cardIt); | 359 | for ( identIt = idents.begin(); identIt != identEnd; ++identIt ) { |
320 | VCardLine::List lines = card.lines( (*identIt) ); | 360 | const VCardLine::List lines = (*cardIt).lines( (*identIt) ); |
321 | VCardLine::List::Iterator lineIt; | 361 | VCardLine::List::ConstIterator lineIt; |
322 | 362 | ||
@@ -324,4 +364,2 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
324 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { | 364 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { |
325 | QStringList params = (*lineIt).parameterList(); | ||
326 | |||
327 | identifier = (*lineIt).identifier().lower(); | 365 | identifier = (*lineIt).identifier().lower(); |
@@ -330,3 +368,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
330 | Address address; | 368 | Address address; |
331 | QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); | 369 | const QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); |
332 | if ( addrParts.count() > 0 ) | 370 | if ( addrParts.count() > 0 ) |
@@ -336,3 +374,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
336 | if ( addrParts.count() > 2 ) | 374 | if ( addrParts.count() > 2 ) |
337 | address.setStreet( addrParts[ 2 ].replace ( QRegExp("\\\\n") , "\n") ); | 375 | address.setStreet( addrParts[ 2 ] ); |
338 | if ( addrParts.count() > 3 ) | 376 | if ( addrParts.count() > 3 ) |
@@ -348,9 +386,6 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
348 | 386 | ||
349 | QStringList types = (*lineIt).parameters( "type" ); | 387 | const QStringList types = (*lineIt).parameters( "type" ); |
350 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 388 | for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) |
351 | type += mAddressTypeMap[ (*it).lower() ]; | 389 | type += mAddressTypeMap[ (*it).lower() ]; |
352 | 390 | ||
353 | if ( !type ) | ||
354 | type = Address::Home; // default | ||
355 | |||
356 | address.setType( type ); | 391 | address.setType( type ); |
@@ -360,3 +395,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
360 | // AGENT | 395 | // AGENT |
361 | if ( identifier == "agent" ) | 396 | else if ( identifier == "agent" ) |
362 | addr.setAgent( parseAgent( *lineIt ) ); | 397 | addr.setAgent( parseAgent( *lineIt ) ); |
@@ -364,3 +399,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
364 | // BDAY | 399 | // BDAY |
365 | if ( identifier == "bday" ) | 400 | else if ( identifier == "bday" ) |
366 | addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); | 401 | addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); |
@@ -368,4 +403,4 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
368 | // CATEGORIES | 403 | // CATEGORIES |
369 | if ( identifier == "categories" ) { | 404 | else if ( identifier == "categories" ) { |
370 | QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); | 405 | const QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); |
371 | addr.setCategories( categories ); | 406 | addr.setCategories( categories ); |
@@ -374,3 +409,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
374 | // CLASS | 409 | // CLASS |
375 | if ( identifier == "class" ) | 410 | else if ( identifier == "class" ) |
376 | addr.setSecrecy( parseSecrecy( *lineIt ) ); | 411 | addr.setSecrecy( parseSecrecy( *lineIt ) ); |
@@ -378,5 +413,5 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
378 | 413 | ||
379 | if ( identifier == "email" ) { | 414 | else if ( identifier == "email" ) { |
380 | QStringList types = (*lineIt).parameters( "type" ); | 415 | const QStringList types = (*lineIt).parameters( "type" ); |
381 | addr.insertEmail( (*lineIt).value().asString(), types.contains( "PREF" ) ); | 416 | addr.insertEmail( (*lineIt).value().asString(), types.findIndex( "PREF" ) != -1 ); |
382 | } | 417 | } |
@@ -384,3 +419,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
384 | // FN | 419 | // FN |
385 | if ( identifier == "fn" ) | 420 | else if ( identifier == "fn" ) |
386 | addr.setFormattedName( (*lineIt).value().asString() ); | 421 | addr.setFormattedName( (*lineIt).value().asString() ); |
@@ -388,6 +423,6 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
388 | // GEO | 423 | // GEO |
389 | if ( identifier == "geo" ) { | 424 | else if ( identifier == "geo" ) { |
390 | Geo geo; | 425 | Geo geo; |
391 | 426 | ||
392 | QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); | 427 | const QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); |
393 | geo.setLatitude( geoParts[ 0 ].toFloat() ); | 428 | geo.setLatitude( geoParts[ 0 ].toFloat() ); |
@@ -399,3 +434,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
399 | // KEY | 434 | // KEY |
400 | if ( identifier == "key" ) | 435 | else if ( identifier == "key" ) |
401 | addr.insertKey( parseKey( *lineIt ) ); | 436 | addr.insertKey( parseKey( *lineIt ) ); |
@@ -403,12 +438,10 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
403 | // LABEL | 438 | // LABEL |
404 | if ( identifier == "label" ) { | 439 | else if ( identifier == "label" ) { |
405 | int type = 0; | 440 | int type = 0; |
406 | 441 | ||
407 | QStringList types = (*lineIt).parameters( "type" ); | 442 | const QStringList types = (*lineIt).parameters( "type" ); |
408 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 443 | for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) |
409 | type += mAddressTypeMap[ (*it).lower() ]; | 444 | type += mAddressTypeMap[ (*it).lower() ]; |
410 | 445 | ||
411 | if ( !type ) | 446 | bool available = false; |
412 | type = Address::Home; | ||
413 | |||
414 | KABC::Address::List addressList = addr.addresses(); | 447 | KABC::Address::List addressList = addr.addresses(); |
@@ -419,4 +452,12 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
419 | addr.insertAddress( *it ); | 452 | addr.insertAddress( *it ); |
453 | available = true; | ||
454 | break; | ||
420 | } | 455 | } |
421 | } | 456 | } |
457 | |||
458 | if ( !available ) { // a standalone LABEL tag | ||
459 | KABC::Address address( type ); | ||
460 | address.setLabel( (*lineIt).value().asString() ); | ||
461 | addr.insertAddress( address ); | ||
462 | } | ||
422 | } | 463 | } |
@@ -424,3 +465,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
424 | // LOGO | 465 | // LOGO |
425 | if ( identifier == "logo" ) | 466 | else if ( identifier == "logo" ) |
426 | addr.setLogo( parsePicture( *lineIt ) ); | 467 | addr.setLogo( parsePicture( *lineIt ) ); |
@@ -428,3 +469,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
428 | // MAILER | 469 | // MAILER |
429 | if ( identifier == "mailer" ) | 470 | else if ( identifier == "mailer" ) |
430 | addr.setMailer( (*lineIt).value().asString() ); | 471 | addr.setMailer( (*lineIt).value().asString() ); |
@@ -432,4 +473,4 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
432 | // N | 473 | // N |
433 | if ( identifier == "n" ) { | 474 | else if ( identifier == "n" ) { |
434 | QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); | 475 | const QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); |
435 | if ( nameParts.count() > 0 ) | 476 | if ( nameParts.count() > 0 ) |
@@ -446,4 +487,8 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
446 | 487 | ||
488 | // NAME | ||
489 | else if ( identifier == "name" ) | ||
490 | addr.setName( (*lineIt).value().asString() ); | ||
491 | |||
447 | // NICKNAME | 492 | // NICKNAME |
448 | if ( identifier == "nickname" ) | 493 | else if ( identifier == "nickname" ) |
449 | addr.setNickName( (*lineIt).value().asString() ); | 494 | addr.setNickName( (*lineIt).value().asString() ); |
@@ -451,16 +496,7 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
451 | // NOTE | 496 | // NOTE |
452 | if ( identifier == "note" ) { | 497 | else if ( identifier == "note" ) |
453 | // #ifdef DESKTOP_VERSION | 498 | addr.setNote( (*lineIt).value().asString() ); |
454 | // addr.setNote( (*lineIt).value().asString() ); | ||
455 | // #else | ||
456 | QString note = (*lineIt).value().asString(); | ||
457 | if ( ! note.isEmpty() ) | ||
458 | addr.setNote( note.replace ( QRegExp("\\\\n") , "\n") ); | ||
459 | else | ||
460 | addr.setNote( note ); | ||
461 | //#endif | ||
462 | } | ||
463 | 499 | ||
464 | // ORGANIZATION | 500 | // ORGANIZATION |
465 | if ( identifier == "org" ) | 501 | else if ( identifier == "org" ) |
466 | addr.setOrganization( (*lineIt).value().asString() ); | 502 | addr.setOrganization( (*lineIt).value().asString() ); |
@@ -468,3 +504,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
468 | // PHOTO | 504 | // PHOTO |
469 | if ( identifier == "photo" ) | 505 | else if ( identifier == "photo" ) |
470 | addr.setPhoto( parsePicture( *lineIt ) ); | 506 | addr.setPhoto( parsePicture( *lineIt ) ); |
@@ -472,3 +508,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
472 | // PROID | 508 | // PROID |
473 | if ( identifier == "prodid" ) | 509 | else if ( identifier == "prodid" ) |
474 | addr.setProductId( (*lineIt).value().asString() ); | 510 | addr.setProductId( (*lineIt).value().asString() ); |
@@ -476,3 +512,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
476 | // REV | 512 | // REV |
477 | if ( identifier == "rev" ) | 513 | else if ( identifier == "rev" ) |
478 | addr.setRevision( parseDateTime( (*lineIt).value().asString() ) ); | 514 | addr.setRevision( parseDateTime( (*lineIt).value().asString() ) ); |
@@ -480,3 +516,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
480 | // ROLE | 516 | // ROLE |
481 | if ( identifier == "role" ) | 517 | else if ( identifier == "role" ) |
482 | addr.setRole( (*lineIt).value().asString() ); | 518 | addr.setRole( (*lineIt).value().asString() ); |
@@ -484,3 +520,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
484 | // SORT-STRING | 520 | // SORT-STRING |
485 | if ( identifier == "sort-string" ) | 521 | else if ( identifier == "sort-string" ) |
486 | addr.setSortString( (*lineIt).value().asString() ); | 522 | addr.setSortString( (*lineIt).value().asString() ); |
@@ -488,3 +524,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
488 | // SOUND | 524 | // SOUND |
489 | if ( identifier == "sound" ) | 525 | else if ( identifier == "sound" ) |
490 | addr.setSound( parseSound( *lineIt ) ); | 526 | addr.setSound( parseSound( *lineIt ) ); |
@@ -492,3 +528,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
492 | // TEL | 528 | // TEL |
493 | if ( identifier == "tel" ) { | 529 | else if ( identifier == "tel" ) { |
494 | PhoneNumber phone; | 530 | PhoneNumber phone; |
@@ -498,9 +534,6 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
498 | 534 | ||
499 | QStringList types = (*lineIt).parameters( "type" ); | 535 | const QStringList types = (*lineIt).parameters( "type" ); |
500 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 536 | for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) |
501 | type += mPhoneTypeMap[(*it).upper()]; | 537 | type += mPhoneTypeMap[(*it).upper()]; |
502 | 538 | ||
503 | if ( !type ) | ||
504 | type = PhoneNumber::Home; // default | ||
505 | |||
506 | phone.setType( type ); | 539 | phone.setType( type ); |
@@ -511,3 +544,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
511 | // TITLE | 544 | // TITLE |
512 | if ( identifier == "title" ) | 545 | else if ( identifier == "title" ) |
513 | addr.setTitle( (*lineIt).value().asString() ); | 546 | addr.setTitle( (*lineIt).value().asString() ); |
@@ -515,5 +548,5 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
515 | // TZ | 548 | // TZ |
516 | if ( identifier == "tz" ) { | 549 | else if ( identifier == "tz" ) { |
517 | TimeZone tz; | 550 | TimeZone tz; |
518 | QString date = (*lineIt).value().asString(); | 551 | const QString date = (*lineIt).value().asString(); |
519 | 552 | ||
@@ -529,3 +562,3 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
529 | // UID | 562 | // UID |
530 | if ( identifier == "uid" ) | 563 | else if ( identifier == "uid" ) |
531 | addr.setUid( (*lineIt).value().asString() ); | 564 | addr.setUid( (*lineIt).value().asString() ); |
@@ -533,8 +566,8 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) | |||
533 | // URL | 566 | // URL |
534 | if ( identifier == "url" ) | 567 | else if ( identifier == "url" ) |
535 | addr.setUrl( (*lineIt).value().asString() ); | 568 | addr.setUrl( KURL( (*lineIt).value().asString() ) ); |
536 | 569 | ||
537 | // X- | 570 | // X- |
538 | if ( identifier.startsWith( "x-" ) ) { | 571 | else if ( identifier.startsWith( "x-" ) ) { |
539 | QString key = (*lineIt).identifier().mid( 2 ); | 572 | const QString key = (*lineIt).identifier().mid( 2 ); |
540 | int dash = key.find( "-" ); | 573 | int dash = key.find( "-" ); |
@@ -595,27 +628,18 @@ Picture VCardTool::parsePicture( const VCardLine &line ) | |||
595 | { | 628 | { |
596 | Picture pic; | 629 | Picture pic; |
597 | 630 | ||
598 | QStringList params = line.parameterList(); | 631 | const QStringList params = line.parameterList(); |
599 | if ( params.contains( "encoding" ) ) { | 632 | if ( params.findIndex( "encoding" ) != -1 ) { |
600 | QCString cs(line.value().asCString()); | 633 | QImage img; |
601 | QByteArray input, output; | 634 | img.loadFromData( line.valueBytes() ); |
602 | input = line.value().asCString(); | 635 | pic.setData( img ); |
603 | if ( line.parameter( "encoding" ).lower() == "b" ) | 636 | } else if ( params.findIndex( "value" ) != -1 ) { |
604 | KCodecs::base64Decode( input, output ); | 637 | if ( line.parameter( "value" ).lower() == "uri" ) |
605 | else if ( line.parameter( "encoding" ).lower() == "quoted-printable" ) | 638 | pic.setUrl( line.value().asString() ); |
606 | KCodecs::quotedPrintableDecode( input, output ); | 639 | } |
607 | 640 | ||
608 | qDebug("********** DECODING OKAY ************** (picture)"); | 641 | if ( params.findIndex( "type" ) != -1 ) |
609 | pic.setData( QImage(output) ); | 642 | pic.setType( line.parameter( "type" ) ); |
610 | 643 | ||
611 | } | 644 | return pic; |
612 | else if ( params.contains( "value" ) ) { | ||
613 | if ( line.parameter( "value" ).lower() == "uri" ) | ||
614 | pic.setUrl( line.value().asString() ); | ||
615 | } | ||
616 | |||
617 | if ( params.contains( "type" ) ) | ||
618 | pic.setType( line.parameter( "type" ) ); | ||
619 | |||
620 | return pic; | ||
621 | } | 645 | } |
@@ -624,3 +648,2 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi | |||
624 | { | 648 | { |
625 | // LR fixed | ||
626 | VCardLine line( identifier ); | 649 | VCardLine line( identifier ); |
@@ -629,3 +652,2 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi | |||
629 | if ( !pic.data().isNull() ) { | 652 | if ( !pic.data().isNull() ) { |
630 | #if 0 | ||
631 | QByteArray input; | 653 | QByteArray input; |
@@ -635,12 +657,2 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi | |||
635 | line.setValue( input ); | 657 | line.setValue( input ); |
636 | #else | ||
637 | QCString input; | ||
638 | QDataStream s( input, IO_WriteOnly ); | ||
639 | s.setVersion( 4 ); | ||
640 | s << pic.data(); | ||
641 | //QCString cs(line.value().asCString()); | ||
642 | //QImage qi(cs); | ||
643 | line.setValue( input ); | ||
644 | #endif | ||
645 | |||
646 | line.addParameter( "encoding", "b" ); | 658 | line.addParameter( "encoding", "b" ); |
@@ -649,2 +661,3 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi | |||
649 | } else if ( !pic.url().isEmpty() ) { | 661 | } else if ( !pic.url().isEmpty() ) { |
662 | QByteArray ba; | ||
650 | line.setValue( pic.url() ); | 663 | line.setValue( pic.url() ); |
@@ -652,3 +665,3 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi | |||
652 | } | 665 | } |
653 | 666 | ||
654 | return line; | 667 | return line; |
@@ -660,11 +673,6 @@ Sound VCardTool::parseSound( const VCardLine &line ) | |||
660 | 673 | ||
661 | QStringList params = line.parameterList(); | 674 | const QStringList params = line.parameterList(); |
662 | if ( params.contains( "encoding" ) ) { | 675 | if ( params.findIndex( "encoding" ) != -1 ) |
663 | qDebug("VCardTool::parseSound has to be verified"); | 676 | snd.setData( line.valueBytes() ); |
664 | //US snd.setData( line.value().asByteArray() ); | 677 | else if ( params.findIndex( "value" ) != -1 ) { |
665 | //US I am not sure if this is correct | ||
666 | QCString cs(line.value().asCString()); | ||
667 | snd.setData( cs ); | ||
668 | } | ||
669 | else if ( params.contains( "value" ) ) { | ||
670 | if ( line.parameter( "value" ).lower() == "uri" ) | 678 | if ( line.parameter( "value" ).lower() == "uri" ) |
@@ -687,10 +695,3 @@ VCardLine VCardTool::createSound( const Sound &snd ) | |||
687 | if ( !snd.data().isEmpty() ) { | 695 | if ( !snd.data().isEmpty() ) { |
688 | qDebug("VCardTool::createSound has to be verified"); | 696 | line.setValue( snd.data() ); |
689 | //US line.setValue( snd.data() ); | ||
690 | |||
691 | //US I am not sure if this is correct | ||
692 | QCString cs(snd.data()); | ||
693 | line.setValue( cs ); | ||
694 | |||
695 | |||
696 | line.addParameter( "encoding", "b" ); | 697 | line.addParameter( "encoding", "b" ); |
@@ -710,11 +711,5 @@ Key VCardTool::parseKey( const VCardLine &line ) | |||
710 | 711 | ||
711 | QStringList params = line.parameterList(); | 712 | const QStringList params = line.parameterList(); |
712 | if ( params.contains( "encoding" ) ) { | 713 | if ( params.findIndex( "encoding" ) != -1 ) |
713 | qDebug("VCardTool::parseKey has to be verified"); | 714 | key.setBinaryData( line.valueBytes() ); |
714 | //US key.setBinaryData( line.value().asByteArray() ); | ||
715 | |||
716 | //US I am not sure if this is correct | ||
717 | QCString cs( line.value().asCString() ); | ||
718 | key.setBinaryData( cs ); | ||
719 | } | ||
720 | else | 715 | else |
@@ -722,3 +717,3 @@ Key VCardTool::parseKey( const VCardLine &line ) | |||
722 | 717 | ||
723 | if ( params.contains( "type" ) ) { | 718 | if ( params.findIndex( "type" ) != -1 ) { |
724 | if ( line.parameter( "type" ).lower() == "x509" ) | 719 | if ( line.parameter( "type" ).lower() == "x509" ) |
@@ -742,9 +737,3 @@ VCardLine VCardTool::createKey( const Key &key ) | |||
742 | if ( !key.binaryData().isEmpty() ) { | 737 | if ( !key.binaryData().isEmpty() ) { |
743 | qDebug("VCardTool::createKey has to be verified"); | 738 | line.setValue( key.binaryData() ); |
744 | //US line.setValue( key.binaryData() ); | ||
745 | //US I am not sure if this is correct | ||
746 | QCString cs(key.binaryData()); | ||
747 | line.setValue( cs ); | ||
748 | |||
749 | |||
750 | line.addParameter( "encoding", "b" ); | 739 | line.addParameter( "encoding", "b" ); |
@@ -798,4 +787,4 @@ Agent VCardTool::parseAgent( const VCardLine &line ) | |||
798 | 787 | ||
799 | QStringList params = line.parameterList(); | 788 | const QStringList params = line.parameterList(); |
800 | if ( params.contains( "value" ) ) { | 789 | if ( params.findIndex( "value" ) != -1 ) { |
801 | if ( line.parameter( "value" ).lower() == "uri" ) | 790 | if ( line.parameter( "value" ).lower() == "uri" ) |
@@ -804,19 +793,9 @@ Agent VCardTool::parseAgent( const VCardLine &line ) | |||
804 | QString str = line.value().asString(); | 793 | QString str = line.value().asString(); |
805 | 794 | str.replace( QRegExp("\\\\n"), "\r\n" ); | |
806 | //US using the old implementation instead | 795 | str.replace( QRegExp("\\\\N"), "\r\n" ); |
807 | qDebug("VCardTool::parseAgent has to be verified"); | 796 | str.replace( QRegExp("\\\\;"), ";" ); |
808 | /*US | 797 | str.replace( QRegExp("\\\\:"), ":" ); |
809 | str.replace( "\\n", "\r\n" ); | 798 | str.replace( QRegExp("\\\\,"), "," ); |
810 | str.replace( "\\N", "\r\n" ); | 799 | |
811 | str.replace( "\\;", ";" ); | 800 | const Addressee::List list = parseVCards( str ); |
812 | str.replace( "\\:", ":" ); | ||
813 | str.replace( "\\,", "," ); | ||
814 | */ | ||
815 | str.replace( QRegExp("\\\\n") , "\r\n" ); | ||
816 | str.replace( QRegExp("\\\\N") , "\r\n" ); | ||
817 | str.replace( QRegExp("\\\\;") , ";" ); | ||
818 | str.replace( QRegExp("\\\\:") , ":" ); | ||
819 | str.replace( QRegExp("\\\\,") , "," ); | ||
820 | |||
821 | Addressee::List list = parseVCards( str ); | ||
822 | if ( list.count() > 0 ) { | 801 | if ( list.count() > 0 ) { |
@@ -841,12 +820,3 @@ VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) | |||
841 | QString str = createVCards( list, version ); | 820 | QString str = createVCards( list, version ); |
842 | 821 | str.replace( QRegExp("\\r\\n"), "\\n" ); | |
843 | //US using the old implementation instead | ||
844 | qDebug("VCardTool::createAgent has to be verified"); | ||
845 | /*US | ||
846 | str.replace( "\r\n", "\\n" ); | ||
847 | str.replace( ";", "\\;" ); | ||
848 | str.replace( ":", "\\:" ); | ||
849 | str.replace( ",", "\\," ); | ||
850 | */ | ||
851 | str.replace( QRegExp("\r\n"), "\\n" ); | ||
852 | str.replace( QRegExp(";"), "\\;" ); | 822 | str.replace( QRegExp(";"), "\\;" ); |
@@ -885,3 +855,3 @@ QStringList VCardTool::splitString( const QChar &sep, const QString &str ) | |||
885 | pos = value.find( sep, pos ); | 855 | pos = value.find( sep, pos ); |
886 | } else | 856 | } else |
887 | pos = value.find( sep, pos + 1 ); | 857 | pos = value.find( sep, pos + 1 ); |