summaryrefslogtreecommitdiffabout
path: root/kabc/vcard
Unidiff
Diffstat (limited to 'kabc/vcard') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/ContentLine.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp
index f7e04a9..c368172 100644
--- a/kabc/vcard/ContentLine.cpp
+++ b/kabc/vcard/ContentLine.cpp
@@ -118,203 +118,204 @@ ContentLine::operator = (ContentLine & x)
118 { 118 {
119 Param *p = new Param; 119 Param *p = new Param;
120 p->setName( it.current()->name() ); 120 p->setName( it.current()->name() );
121 p->setValue( it.current()->value() ); 121 p->setValue( it.current()->value() );
122 paramList_.append(p); 122 paramList_.append(p);
123 } 123 }
124 124
125 value_ = x.value_->clone(); 125 value_ = x.value_->clone();
126 126
127 Entity::operator = (x); 127 Entity::operator = (x);
128 return *this; 128 return *this;
129} 129}
130 130
131 ContentLine & 131 ContentLine &
132ContentLine::operator = (const QCString & s) 132ContentLine::operator = (const QCString & s)
133{ 133{
134 Entity::operator = (s); 134 Entity::operator = (s);
135 delete value_; 135 delete value_;
136 value_ = 0; 136 value_ = 0;
137 return *this; 137 return *this;
138} 138}
139 139
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 // Unqote newlines
165 strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); 165 strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" );
166 166
167 int split = strRep_.find(':'); 167 int split = strRep_.find(':');
168 168
169 if (split == -1) { // invalid content line 169 if (split == -1) { // invalid content line
170 vDebug("No ':'"); 170 vDebug("No ':'");
171 return; 171 return;
172 } 172 }
173 173
174 QCString firstPart(strRep_.left(split)); 174 QCString firstPart(strRep_.left(split));
175 QCString valuePart(strRep_.mid(split + 1)); 175 QCString valuePart(strRep_.mid(split + 1));
176 176
177 split = firstPart.find('.'); 177 split = firstPart.find('.');
178 178
179 if (split != -1) { 179 if (split != -1) {
180 group_ = firstPart.left(split); 180 group_ = firstPart.left(split);
181 firstPart= firstPart.mid(split + 1); 181 firstPart= firstPart.mid(split + 1);
182 } 182 }
183 183
184 vDebug("Group == " + group_); 184 vDebug("Group == " + group_);
185 vDebug("firstPart == " + firstPart); 185 vDebug("firstPart == " + firstPart);
186 vDebug("valuePart == " + valuePart); 186 vDebug("valuePart == " + valuePart);
187 187
188 // Now we have the group, the name and param list together and the value. 188 // Now we have the group, the name and param list together and the value.
189 189
190 QStrList l; 190 QStrList l;
191 191
192 RTokenise(firstPart, ";", l); 192 RTokenise(firstPart, ";", l);
193 193
194 if (l.count() == 0) {// invalid - no name ! 194 if (l.count() == 0) {// invalid - no name !
195 vDebug("No name for this content line !"); 195 vDebug("No name for this content line !");
196 return; 196 return;
197 } 197 }
198 198
199 name_ = l.at(0); 199 name_ = l.at(0);
200 200
201 // Now we have the name, so the rest of 'l' is the params. 201 // Now we have the name, so the rest of 'l' is the params.
202 // Remove the name part. 202 // Remove the name part.
203 l.remove(0u); 203 l.remove(0u);
204 204
205 entityType_= EntityNameToEntityType(name_); 205 entityType_= EntityNameToEntityType(name_);
206 paramType_= EntityTypeToParamType(entityType_); 206 paramType_= EntityTypeToParamType(entityType_);
207 207
208 unsigned int i = 0; 208 unsigned int i = 0;
209 209
210 // For each parameter, create a new parameter of the correct type. 210 // For each parameter, create a new parameter of the correct type.
211 211
212 QStrListIterator it(l); 212 QStrListIterator it(l);
213 213
214 for (; it.current(); ++it, i++) { 214 for (; it.current(); ++it, i++) {
215 215
216 QCString str = *it; 216 QCString str = *it;
217 217
218 split = str.find("="); 218 split = str.find("=");
219 if (split < 0 ) { 219 if (split < 0 ) {
220 vDebug("No '=' in paramter."); 220 vDebug("No '=' in paramter.");
221 continue; 221 continue;
222 } 222 }
223 223
224 QCString paraName = str.left(split); 224 QCString paraName = str.left(split);
225 QCString paraValue = str.mid(split + 1); 225 QCString paraValue = str.mid(split + 1);
226 226
227 QStrList paraValues; 227 QStrList paraValues;
228 RTokenise(paraValue, ",", paraValues); 228 RTokenise(paraValue, ",", paraValues);
229 229
230 QStrListIterator it2( paraValues ); 230 QStrListIterator it2( paraValues );
231 231
232 for(; it2.current(); ++it2) { 232 for(; it2.current(); ++it2) {
233 233
234 Param *p = new Param; 234 Param *p = new Param;
235 p->setName( paraName ); 235 p->setName( paraName );
236 p->setValue( *it2 ); 236 p->setValue( *it2 );
237 237
238 paramList_.append(p); 238 paramList_.append(p);
239 } 239 }
240 } 240 }
241 241
242 // Create a new value of the correct type. 242 // Create a new value of the correct type.
243 243
244 valueType_ = EntityTypeToValueType(entityType_); 244 valueType_ = EntityTypeToValueType(entityType_);
245 245
246 //kdDebug(5710) << "valueType: " << valueType_ << endl; 246 //kdDebug(5710) << "valueType: " << valueType_ << endl;
247 247
248 switch (valueType_) { 248 switch (valueType_) {
249 249
250 case ValueSound: value_ = new SoundValue;break; 250 case ValueSound: value_ = new SoundValue;break;
251 case ValueAgent: value_ = new AgentValue;break; 251 case ValueAgent: value_ = new AgentValue;break;
252 case ValueAddress: value_ = new AdrValue; break; 252 case ValueAddress: value_ = new AdrValue; break;
253 case ValueTel: value_ = new TelValue; break; 253 case ValueTel: value_ = new TelValue; break;
254 case ValueTextBin: value_ = new TextBinValue;break; 254 case ValueTextBin: value_ = new TextBinValue;break;
255 case ValueOrg: value_ = new OrgValue; break; 255 case ValueOrg: value_ = new OrgValue; break;
256 case ValueN: value_ = new NValue; break; 256 case ValueN: value_ = new NValue; break;
257 case ValueUTC: value_ = new UTCValue; break; 257 case ValueUTC: value_ = new UTCValue; break;
258 case ValueURI: value_ = new URIValue; break; 258 case ValueURI: value_ = new URIValue; break;
259 case ValueClass: value_ = new ClassValue;break; 259 case ValueClass: value_ = new ClassValue;break;
260 case ValueFloat: value_ = new FloatValue;break; 260 case ValueFloat: value_ = new FloatValue;break;
261 case ValueImage: value_ = new ImageValue;break; 261 case ValueImage: value_ = new ImageValue;break;
262 case ValueDate: value_ = new DateValue; break; 262 case ValueDate: value_ = new DateValue; break;
263 case ValueTextList: value_ = new TextListValue;break; 263 case ValueTextList: value_ = new TextListValue;break;
264 case ValueGeo: value_ = new GeoValue; break; 264 case ValueGeo: value_ = new GeoValue; break;
265 case ValueText: 265 case ValueText:
266 case ValueUnknown: 266 case ValueUnknown:
267 default: value_ = new TextValue; break; 267 default: value_ = new TextValue; break;
268 } 268 }
269 269
270 *value_ = valuePart; 270 *value_ = valuePart;
271} 271}
272 272
273 void 273 void
274ContentLine::_assemble() 274ContentLine::_assemble()
275{ 275{
276 vDebug("Assemble (argl) - my name is \"" + name_ + "\""); 276 vDebug("Assemble (argl) - my name is \"" + name_ + "\"");
277 strRep_.truncate(0); 277 strRep_.truncate(0);
278 278
279 QCString line; 279 QCString line;
280 280
281 if (!group_.isEmpty()) 281 if (!group_.isEmpty())
282 line += group_ + '.'; 282 line += group_ + '.';
283 283
284 line += name_; 284 line += name_;
285 285
286 vDebug("Adding parameters"); 286 vDebug("Adding parameters");
287 ParamListIterator it(paramList_); 287 ParamListIterator it(paramList_);
288 288
289 for (; it.current(); ++it) 289 for (; it.current(); ++it)
290 line += ";" + it.current()->asString(); 290 line += ";" + it.current()->asString();
291 291
292 vDebug("Adding value"); 292 vDebug("Adding value");
293 if (value_ != 0) 293 if (value_ != 0)
294 line += ":" + value_->asString(); 294 line += ":" + value_->asString();
295 else 295 else
296 vDebug("No value"); 296 vDebug("No value");
297 297
298 // Quote newlines 298 // Quote newlines
299 line = line.replace( QRegExp( "\n" ), "\\n" ); 299 line = line.replace( QRegExp( "\n" ), "\\n" );
300 300
301 // Fold lines longer than 72 chars 301 // Fold lines longer than 72 chars
302 const int maxLen = 72; 302 const int maxLen = 72;
303 uint cursor = 0; 303 uint cursor = 0;
304 while( line.length() > ( cursor + 1 ) * maxLen ) { 304 while( line.length() > ( cursor + 1 ) * maxLen ) {
305 strRep_ += line.mid( cursor * maxLen, maxLen ); 305 strRep_ += line.mid( cursor * maxLen, maxLen );
306 strRep_ += "\r\n "; 306 strRep_ += "\r\n ";
307 ++cursor; 307 ++cursor;
308 } 308 }
309 strRep_ += line.mid( cursor * maxLen ); 309 strRep_ += line.mid( cursor * maxLen );
310 //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data());
310} 311}
311 312
312 void 313 void
313ContentLine::clear() 314ContentLine::clear()
314{ 315{
315 group_.truncate(0); 316 group_.truncate(0);
316 name_.truncate(0); 317 name_.truncate(0);
317 paramList_.clear(); 318 paramList_.clear();
318 delete value_; 319 delete value_;
319 value_ = 0; 320 value_ = 0;
320} 321}