summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/ContentLine.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp
index 2f88cde..0a2f97d 100644
--- a/kabc/vcard/ContentLine.cpp
+++ b/kabc/vcard/ContentLine.cpp
@@ -140,50 +140,55 @@ ContentLine::operator = (const QCString & s)
140 bool 140 bool
141ContentLine::operator == (ContentLine & x) 141ContentLine::operator == (ContentLine & x)
142{ 142{
143 x.parse(); 143 x.parse();
144 144
145 QPtrListIterator<Param> it(x.paramList()); 145 QPtrListIterator<Param> it(x.paramList());
146 146
147 if (!paramList_.find(it.current())) 147 if (!paramList_.find(it.current()))
148 return false; 148 return false;
149 149
150 return true; 150 return true;
151} 151}
152 152
153ContentLine::~ContentLine() 153ContentLine::~ContentLine()
154{ 154{
155 delete value_; 155 delete value_;
156 value_ = 0; 156 value_ = 0;
157} 157}
158 158
159 void 159 void
160ContentLine::_parse() 160ContentLine::_parse()
161{ 161{
162 vDebug("parse"); 162 vDebug("parse");
163 163
164 // Unqote newlines 164 // Unfold folded lines
165 // NLR
166 strRep_ = strRep_.replace( QRegExp( "\\r" ), "" );
167 // Unqote newlines
165 strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); 168 strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" );
169 //NLR
170 strRep_ = strRep_.replace( QRegExp( "\\\\r" ), "\r" );
166 171
167 int split = strRep_.find(':'); 172 int split = strRep_.find(':');
168 173
169 if (split == -1) { // invalid content line 174 if (split == -1) { // invalid content line
170 vDebug("No ':'"); 175 vDebug("No ':'");
171 return; 176 return;
172 } 177 }
173 178
174 QCString firstPart(strRep_.left(split)); 179 QCString firstPart(strRep_.left(split));
175 QCString valuePart(strRep_.mid(split + 1)); 180 QCString valuePart(strRep_.mid(split + 1));
176 181
177 split = firstPart.find('.'); 182 split = firstPart.find('.');
178 183
179 if (split != -1) { 184 if (split != -1) {
180 group_ = firstPart.left(split); 185 group_ = firstPart.left(split);
181 firstPart= firstPart.mid(split + 1); 186 firstPart= firstPart.mid(split + 1);
182 } 187 }
183 188
184 vDebug("Group == " + group_); 189 vDebug("Group == " + group_);
185 vDebug("firstPart == " + firstPart); 190 vDebug("firstPart == " + firstPart);
186 vDebug("valuePart == " + valuePart); 191 vDebug("valuePart == " + valuePart);
187 192
188 // Now we have the group, the name and param list together and the value. 193 // Now we have the group, the name and param list together and the value.
189 194
@@ -264,48 +269,49 @@ ContentLine::_parse()
264 case ValueGeo: value_ = new GeoValue; break; 269 case ValueGeo: value_ = new GeoValue; break;
265 case ValueText: 270 case ValueText:
266 case ValueUnknown: 271 case ValueUnknown:
267 default: value_ = new TextValue; break; 272 default: value_ = new TextValue; break;
268 } 273 }
269 274
270 *value_ = valuePart; 275 *value_ = valuePart;
271} 276}
272 277
273 void 278 void
274ContentLine::_assemble() 279ContentLine::_assemble()
275{ 280{
276 //strRep_.truncate(0); 281 //strRep_.truncate(0);
277 QString line; 282 QString line;
278 if (!group_.isEmpty()) 283 if (!group_.isEmpty())
279 line = group_ + '.'; 284 line = group_ + '.';
280 line += name_; 285 line += name_;
281 ParamListIterator it(paramList_); 286 ParamListIterator it(paramList_);
282 for (; it.current(); ++it) 287 for (; it.current(); ++it)
283 line += ";" + it.current()->asString(); 288 line += ";" + it.current()->asString();
284 289
285 if (value_ != 0) 290 if (value_ != 0)
286 line += ":" + value_->asString(); 291 line += ":" + value_->asString();
287 292
293 line = line.replace( QRegExp( "\r" ), "\\r" );
288 line = line.replace( QRegExp( "\n" ), "\\n" ); 294 line = line.replace( QRegExp( "\n" ), "\\n" );
289 295
290 // Fold lines longer than 72 chars 296 // Fold lines longer than 72 chars
291 const int maxLen = 72; 297 const int maxLen = 72;
292 uint cursor = 0; 298 uint cursor = 0;
293 QString cut; 299 QString cut;
294 while( line.length() > ( cursor + 1 ) * maxLen ) { 300 while( line.length() > ( cursor + 1 ) * maxLen ) {
295 cut += line.mid( cursor * maxLen, maxLen ); 301 cut += line.mid( cursor * maxLen, maxLen );
296 cut += "\r\n "; 302 cut += "\r\n ";
297 ++cursor; 303 ++cursor;
298 } 304 }
299 cut += line.mid( cursor * maxLen ); 305 cut += line.mid( cursor * maxLen );
300 strRep_ = cut.latin1(); 306 strRep_ = cut.latin1();
301 //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); 307 //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data());
302#if 0 308#if 0
303 vDebug("Assemble (argl) - my name is \"" + name_ + "\""); 309 vDebug("Assemble (argl) - my name is \"" + name_ + "\"");
304 strRep_.truncate(0); 310 strRep_.truncate(0);
305 311
306 QCString line; 312 QCString line;
307 313
308 if (!group_.isEmpty()) 314 if (!group_.isEmpty())
309 line += group_ + '.'; 315 line += group_ + '.';
310 316
311 line += name_; 317 line += name_;