summaryrefslogtreecommitdiffabout
path: root/kabc/vcardparser/vcardparser.cpp
Unidiff
Diffstat (limited to 'kabc/vcardparser/vcardparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardparser/vcardparser.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp
index 7fae011..11622a0 100644
--- a/kabc/vcardparser/vcardparser.cpp
+++ b/kabc/vcardparser/vcardparser.cpp
@@ -117,30 +117,30 @@ VCard::List VCardParser::parseVCards( const QString& text )
117 // join any qp-folded lines 117 // join any qp-folded lines
118 while ( value.mid(value.length()-1,1) == "=" && it != linesEnd ) { 118 while ( value.mid(value.length()-1,1) == "=" && it != linesEnd ) {
119 value = value.remove( value.length()-1, 1 ) + (*it); 119 value = value.remove( value.length()-1, 1 ) + (*it);
120 ++it; 120 ++it;
121 } 121 }
122 input = value.local8Bit(); 122 input = value.local8Bit();
123 KCodecs::quotedPrintableDecode( input, output ); 123 KCodecs::quotedPrintableDecode( input, output );
124 } 124 }
125//PP our vcards are *supposed* to be in UTF-8 125//PP our vcards are *supposed* to be in UTF-8
126// if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) { 126// if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) {
127// vCardLine.setValue( QString::fromUtf8( output.data(), output.size() ) ); 127// vCardLine.setValue( QString::fromUtf8( output.data(), output.size() ) );
128// } else 128// } else
129 vCardLine.setValue( output ); 129 vCardLine.setValueBytes( output );
130//PP our vcards are *supposed* to be in UTF-8 130//PP our vcards are *supposed* to be in UTF-8
131// } else if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) { 131// } else if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) {
132// vCardLine.setValue( QString::fromUtf8( value.ascii() ) ); 132// vCardLine.setValue( QString::fromUtf8( value.ascii() ) );
133 } else 133 } else
134 vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) ); 134 vCardLine.setValueString( value.replace( QRegExp("\\\\n"), "\n" ) );
135 135
136 currentVCard.addLine( vCardLine ); 136 currentVCard.addLine( vCardLine );
137 } 137 }
138 138
139 // we do not save the start and end tag as vcardline 139 // we do not save the start and end tag as vcardline
140 if ( (*it).lower().startsWith( "begin:vcard" ) ) { 140 if ( (*it).lower().startsWith( "begin:vcard" ) ) {
141 inVCard = true; 141 inVCard = true;
142 currentLine = ""; 142 currentLine = "";
143 currentVCard.clear(); // flush vcard 143 currentVCard.clear(); // flush vcard
144 continue; 144 continue;
145 } 145 }
146 146
@@ -179,25 +179,25 @@ QString VCardParser::createVCards( const VCard::List& list )
179 179
180 // iterate over the cards 180 // iterate over the cards
181 VCard::List::ConstIterator listEnd( list.end() ); 181 VCard::List::ConstIterator listEnd( list.end() );
182 for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) { 182 for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) {
183 text.append( "BEGIN:VCARD\r\n" ); 183 text.append( "BEGIN:VCARD\r\n" );
184 184
185 idents = (*cardIt).identifiers(); 185 idents = (*cardIt).identifiers();
186 for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { 186 for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) {
187 lines = (*cardIt).lines( (*identIt) ); 187 lines = (*cardIt).lines( (*identIt) );
188 188
189 // iterate over the lines 189 // iterate over the lines
190 for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { 190 for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
191 if ( !(*lineIt).value().asString().isEmpty() ) { 191 if ( !(*lineIt).valueString().isEmpty() ) {
192 if ( (*lineIt).hasGroup() ) 192 if ( (*lineIt).hasGroup() )
193 textLine = (*lineIt).group() + "." + (*lineIt).identifier(); 193 textLine = (*lineIt).group() + "." + (*lineIt).identifier();
194 else 194 else
195 textLine = (*lineIt).identifier(); 195 textLine = (*lineIt).identifier();
196 196
197 params = (*lineIt).parameterList(); 197 params = (*lineIt).parameterList();
198 hasEncoding = false; 198 hasEncoding = false;
199 if ( params.count() > 0 ) { // we have parameters 199 if ( params.count() > 0 ) { // we have parameters
200 for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) { 200 for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) {
201 if ( (*paramIt) == "encoding" ) { 201 if ( (*paramIt) == "encoding" ) {
202 hasEncoding = true; 202 hasEncoding = true;
203 encodingType = (*lineIt).parameter( "encoding" ).lower(); 203 encodingType = (*lineIt).parameter( "encoding" ).lower();
@@ -212,25 +212,25 @@ QString VCardParser::createVCards( const VCard::List& list )
212 } 212 }
213 } 213 }
214 214
215 if ( hasEncoding ) { // have to encode the data 215 if ( hasEncoding ) { // have to encode the data
216 QByteArray input, output; 216 QByteArray input, output;
217 input = (*lineIt).valueBytes(); 217 input = (*lineIt).valueBytes();
218 if ( encodingType == "b" ) 218 if ( encodingType == "b" )
219 KCodecs::base64Encode( input, output ); 219 KCodecs::base64Encode( input, output );
220 else if ( encodingType == "quoted-printable" ) 220 else if ( encodingType == "quoted-printable" )
221 KCodecs::quotedPrintableEncode( input, output ); 221 KCodecs::quotedPrintableEncode( input, output );
222 textLine.append( ":" + QString( output ) ); 222 textLine.append( ":" + QString( output ) );
223 } else 223 } else
224 textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) ); 224 textLine.append( ":" + (*lineIt).valueString().replace( QRegExp("\n"), "\\n" ) );
225 225
226 if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line 226 if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line
227 for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i ) 227 for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i )
228 text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" ); 228 text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" );
229 } else 229 } else
230 text.append( textLine + "\r\n" ); 230 text.append( textLine + "\r\n" );
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 text.append( "END:VCARD\r\n" ); 235 text.append( "END:VCARD\r\n" );
236 text.append( "\r\n" ); 236 text.append( "\r\n" );