-rw-r--r-- | kabc/vcard/ContentLine.cpp | 30 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 77 |
2 files changed, 65 insertions, 42 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index c368172..2f88cde 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -180,142 +180,170 @@ ContentLine::_parse() | |||
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 |
274 | ContentLine::_assemble() | 274 | ContentLine::_assemble() |
275 | { | 275 | { |
276 | //strRep_.truncate(0); | ||
277 | QString line; | ||
278 | if (!group_.isEmpty()) | ||
279 | line = group_ + '.'; | ||
280 | line += name_; | ||
281 | ParamListIterator it(paramList_); | ||
282 | for (; it.current(); ++it) | ||
283 | line += ";" + it.current()->asString(); | ||
284 | |||
285 | if (value_ != 0) | ||
286 | line += ":" + value_->asString(); | ||
287 | |||
288 | line = line.replace( QRegExp( "\n" ), "\\n" ); | ||
289 | |||
290 | // Fold lines longer than 72 chars | ||
291 | const int maxLen = 72; | ||
292 | uint cursor = 0; | ||
293 | QString cut; | ||
294 | while( line.length() > ( cursor + 1 ) * maxLen ) { | ||
295 | cut += line.mid( cursor * maxLen, maxLen ); | ||
296 | cut += "\r\n "; | ||
297 | ++cursor; | ||
298 | } | ||
299 | cut += line.mid( cursor * maxLen ); | ||
300 | strRep_ = cut.latin1(); | ||
301 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | ||
302 | #if 0 | ||
276 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); | 303 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); |
277 | strRep_.truncate(0); | 304 | strRep_.truncate(0); |
278 | 305 | ||
279 | QCString line; | 306 | QCString line; |
280 | 307 | ||
281 | if (!group_.isEmpty()) | 308 | if (!group_.isEmpty()) |
282 | line += group_ + '.'; | 309 | line += group_ + '.'; |
283 | 310 | ||
284 | line += name_; | 311 | line += name_; |
285 | 312 | ||
286 | vDebug("Adding parameters"); | 313 | vDebug("Adding parameters"); |
287 | ParamListIterator it(paramList_); | 314 | ParamListIterator it(paramList_); |
288 | 315 | ||
289 | for (; it.current(); ++it) | 316 | for (; it.current(); ++it) |
290 | line += ";" + it.current()->asString(); | 317 | line += ";" + it.current()->asString(); |
291 | 318 | ||
292 | vDebug("Adding value"); | 319 | vDebug("Adding value"); |
293 | if (value_ != 0) | 320 | if (value_ != 0) |
294 | line += ":" + value_->asString(); | 321 | line += ":" + value_->asString(); |
295 | else | 322 | else |
296 | vDebug("No value"); | 323 | vDebug("No value"); |
297 | 324 | ||
298 | // Quote newlines | 325 | // Quote newlines |
299 | line = line.replace( QRegExp( "\n" ), "\\n" ); | 326 | line = line.replace( QRegExp( "\n" ), "\\n" ); |
300 | 327 | ||
301 | // Fold lines longer than 72 chars | 328 | // Fold lines longer than 72 chars |
302 | const int maxLen = 72; | 329 | const int maxLen = 72; |
303 | uint cursor = 0; | 330 | uint cursor = 0; |
304 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 331 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
305 | strRep_ += line.mid( cursor * maxLen, maxLen ); | 332 | strRep_ += line.mid( cursor * maxLen, maxLen ); |
306 | strRep_ += "\r\n "; | 333 | strRep_ += "\r\n "; |
307 | ++cursor; | 334 | ++cursor; |
308 | } | 335 | } |
309 | strRep_ += line.mid( cursor * maxLen ); | 336 | strRep_ += line.mid( cursor * maxLen ); |
310 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | 337 | qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); |
338 | #endif | ||
311 | } | 339 | } |
312 | 340 | ||
313 | void | 341 | void |
314 | ContentLine::clear() | 342 | ContentLine::clear() |
315 | { | 343 | { |
316 | group_.truncate(0); | 344 | group_.truncate(0); |
317 | name_.truncate(0); | 345 | name_.truncate(0); |
318 | paramList_.clear(); | 346 | paramList_.clear(); |
319 | delete value_; | 347 | delete value_; |
320 | value_ = 0; | 348 | value_ = 0; |
321 | } | 349 | } |
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index bc80707..49bfe43 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -1,299 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qstringlist.h> | ||
27 | #include <qstring.h> | ||
28 | #include <qvaluelist.h> | ||
26 | 29 | ||
27 | #include <VCardEntity.h> | 30 | #include <VCardEntity.h> |
28 | #include <VCardVCard.h> | 31 | #include <VCardVCard.h> |
29 | #include <VCardContentLine.h> | 32 | #include <VCardContentLine.h> |
30 | #include <VCardRToken.h> | 33 | #include <VCardRToken.h> |
31 | 34 | ||
32 | #include <VCardDefines.h> | 35 | #include <VCardDefines.h> |
33 | 36 | ||
34 | using namespace VCARD; | 37 | using namespace VCARD; |
35 | 38 | ||
36 | VCard::VCard() | 39 | VCard::VCard() |
37 | :Entity() | 40 | :Entity() |
38 | { | 41 | { |
39 | contentLineList_.setAutoDelete( TRUE ); | 42 | contentLineList_.setAutoDelete( TRUE ); |
40 | } | 43 | } |
41 | 44 | ||
42 | VCard::VCard(const VCard & x) | 45 | VCard::VCard(const VCard & x) |
43 | :Entity(x), | 46 | :Entity(x), |
44 | group_(x.group_) | 47 | group_(x.group_) |
45 | { | 48 | { |
46 | contentLineList_.setAutoDelete( TRUE ); | 49 | contentLineList_.setAutoDelete( TRUE ); |
47 | 50 | ||
48 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 51 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
49 | for (; it.current(); ++it) { | 52 | for (; it.current(); ++it) { |
50 | ContentLine * c = new ContentLine(*it.current()); | 53 | ContentLine * c = new ContentLine(*it.current()); |
51 | contentLineList_.append(c); | 54 | contentLineList_.append(c); |
52 | } | 55 | } |
53 | 56 | ||
54 | } | 57 | } |
55 | 58 | ||
56 | VCard::VCard(const QCString & s) | 59 | VCard::VCard(const QCString & s) |
57 | :Entity(s) | 60 | :Entity(s) |
58 | { | 61 | { |
59 | contentLineList_.setAutoDelete( TRUE ); | 62 | contentLineList_.setAutoDelete( TRUE ); |
60 | } | 63 | } |
61 | 64 | ||
62 | VCard & | 65 | VCard & |
63 | VCard::operator = (VCard & x) | 66 | VCard::operator = (VCard & x) |
64 | { | 67 | { |
65 | if (*this == x) return *this; | 68 | if (*this == x) return *this; |
66 | 69 | ||
67 | group_ = x.group(); | 70 | group_ = x.group(); |
68 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 71 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
69 | for (; it.current(); ++it) { | 72 | for (; it.current(); ++it) { |
70 | ContentLine * c = new ContentLine(*it.current()); | 73 | ContentLine * c = new ContentLine(*it.current()); |
71 | contentLineList_.append(c); | 74 | contentLineList_.append(c); |
72 | } | 75 | } |
73 | 76 | ||
74 | Entity::operator = (x); | 77 | Entity::operator = (x); |
75 | return *this; | 78 | return *this; |
76 | } | 79 | } |
77 | 80 | ||
78 | VCard & | 81 | VCard & |
79 | VCard::operator = (const QCString & s) | 82 | VCard::operator = (const QCString & s) |
80 | { | 83 | { |
81 | Entity::operator = (s); | 84 | Entity::operator = (s); |
82 | return *this; | 85 | return *this; |
83 | } | 86 | } |
84 | 87 | ||
85 | bool | 88 | bool |
86 | VCard::operator == (VCard & x) | 89 | VCard::operator == (VCard & x) |
87 | { | 90 | { |
88 | x.parse(); | 91 | x.parse(); |
89 | return false; | 92 | return false; |
90 | } | 93 | } |
91 | 94 | ||
92 | VCard::~VCard() | 95 | VCard::~VCard() |
93 | { | 96 | { |
94 | } | 97 | } |
95 | 98 | ||
96 | void | 99 | void |
97 | VCard::_parse() | 100 | VCard::_parse() |
98 | { | 101 | { |
99 | vDebug("parse() called"); | 102 | |
100 | QStrList l; | 103 | QStringList l; |
104 | QStrList sl; | ||
101 | 105 | ||
102 | RTokenise(strRep_, "\r\n", l); | 106 | RTokenise(strRep_, "\r\n", sl); |
103 | 107 | ||
104 | if (l.count() < 3) { // Invalid VCARD ! | 108 | if (sl.count() < 3) { // Invalid VCARD ! |
105 | vDebug("Invalid vcard"); | 109 | //qDebug("invalid vcard "); |
106 | return; | 110 | return; |
107 | } | 111 | } |
108 | 112 | l = QStringList::fromStrList( sl ); | |
109 | // Get the first line | 113 | // Get the first line |
110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); | 114 | QString beginLine = l[0].stripWhiteSpace(); |
111 | |||
112 | vDebug("Begin line == \"" + beginLine + "\""); | ||
113 | 115 | ||
114 | // Remove extra blank lines | 116 | // Remove extra blank lines |
115 | while (QCString(l.last()).isEmpty()) | 117 | while (l.last().isEmpty()) |
116 | l.remove(l.last()); | 118 | l.remove(l.last()); |
117 | 119 | ||
118 | // Now we know this is the last line | 120 | // Now we know this is the last line |
119 | QCString endLine = l.last(); | 121 | QString endLine = l.last(); |
120 | 122 | ||
121 | // Trash the first and last lines as we have seen them. | 123 | // Trash the first and last lines as we have seen them. |
122 | l.remove(0u); | 124 | l.remove(l.first()); |
123 | l.remove(l.last()); | 125 | l.remove(l.last()); |
124 | 126 | ||
125 | /////////////////////////////////////////////////////////////// | 127 | /////////////////////////////////////////////////////////////// |
126 | // FIRST LINE | 128 | // FIRST LINE |
127 | 129 | ||
128 | int split = beginLine.find(':'); | 130 | int split = beginLine.find(':'); |
129 | 131 | ||
130 | if (split == -1) { // invalid, no BEGIN | 132 | if (split == -1) { // invalid, no BEGIN |
131 | vDebug("No split"); | 133 | vDebug("No split"); |
132 | return; | 134 | return; |
133 | } | 135 | } |
134 | 136 | ||
135 | QCString firstPart(beginLine.left(split)); | 137 | QString firstPart(beginLine.left(split)); |
136 | QCString valuePart(beginLine.mid(split + 1)); | 138 | QString valuePart(beginLine.mid(split + 1)); |
137 | 139 | ||
138 | split = firstPart.find('.'); | 140 | split = firstPart.find('.'); |
139 | 141 | ||
140 | if (split != -1) { | 142 | if (split != -1) { |
141 | group_ = firstPart.left(split); | 143 | group_ = firstPart.left(split); |
142 | firstPart= firstPart.right(firstPart.length() - split - 1); | 144 | firstPart= firstPart.right(firstPart.length() - split - 1); |
143 | } | 145 | } |
144 | 146 | ||
145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! | 147 | if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! |
146 | vDebug("No BEGIN"); | 148 | qDebug("no BEGIN in vcard "); |
147 | return; | 149 | return; |
148 | } | 150 | } |
149 | 151 | ||
150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! | 152 | if (valuePart.left(5) != "VCARD") { // Not a vcard ! |
151 | vDebug("No VCARD"); | 153 | qDebug("not a VCARD "); |
152 | return; | 154 | return; |
153 | } | 155 | } |
154 | 156 | ||
155 | /////////////////////////////////////////////////////////////// | 157 | /////////////////////////////////////////////////////////////// |
156 | // CONTENT LINES | 158 | // CONTENT LINES |
157 | // | 159 | // |
158 | vDebug("Content lines"); | 160 | vDebug("Content lines"); |
159 | 161 | ||
160 | // Handle folded lines. | 162 | // Handle folded lines. |
161 | 163 | ||
162 | QStrList refolded; | 164 | QStringList refolded; |
163 | |||
164 | QStrListIterator it(l); | ||
165 | 165 | ||
166 | QCString cur; | ||
167 | 166 | ||
168 | for (; it.current(); ++it) { | 167 | QStringList::Iterator it = l.begin(); |
169 | 168 | ||
170 | cur = it.current(); | 169 | QString cur; |
171 | 170 | ||
171 | for (; it != l.end(); ++it) { | ||
172 | cur = (*it); | ||
172 | ++it; | 173 | ++it; |
173 | 174 | while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { | |
174 | while ( | 175 | cur += (*it) ; |
175 | it.current() && | ||
176 | it.current()[0] == ' '&& | ||
177 | strlen(it.current()) != 1) | ||
178 | { | ||
179 | cur += it.current() + 1; | ||
180 | ++it; | 176 | ++it; |
181 | } | 177 | } |
182 | |||
183 | --it; | 178 | --it; |
184 | |||
185 | refolded.append(cur); | 179 | refolded.append(cur); |
186 | } | 180 | } |
187 | 181 | QStringList::Iterator it2 = refolded.begin(); | |
188 | QStrListIterator it2(refolded); | 182 | for (; it2 != refolded.end(); ++it2) { |
189 | 183 | ContentLine * cl = new ContentLine(QCString((*it2).latin1())); | |
190 | for (; it2.current(); ++it2) { | ||
191 | vDebug("New contentline using \"" + QCString(it2.current()) + "\""); | ||
192 | ContentLine * cl = new ContentLine(it2.current()); | ||
193 | |||
194 | cl->parse(); | 184 | cl->parse(); |
195 | if (cl->value() == 0) | 185 | if (cl->value() == 0) |
196 | { | 186 | { |
197 | qDebug("Content line could not be parsed. Discarded: %s", it2.current()); | 187 | qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); |
198 | delete cl; | 188 | delete cl; |
199 | } | 189 | } |
200 | else | 190 | else |
201 | contentLineList_.append(cl); | 191 | contentLineList_.append(cl); |
202 | } | 192 | } |
203 | 193 | ||
204 | /////////////////////////////////////////////////////////////// | 194 | /////////////////////////////////////////////////////////////// |
205 | // LAST LINE | 195 | // LAST LINE |
206 | 196 | ||
197 | |||
198 | // LR: sorry, but the remaining code in this method makes no sense | ||
199 | |||
200 | #if 0 | ||
207 | split = endLine.find(':'); | 201 | split = endLine.find(':'); |
208 | 202 | ||
209 | if (split == -1) // invalid, no END | 203 | if (split == -1) // invalid, no END |
210 | return; | 204 | return; |
211 | 205 | ||
212 | firstPart = endLine.left(split); | 206 | firstPart = endLine.left(split); |
213 | valuePart = endLine.right(firstPart.length() - split - 1); | 207 | valuePart = endLine.right(firstPart.length() - split - 1); |
214 | 208 | ||
215 | split = firstPart.find('.'); | 209 | split = firstPart.find('.'); |
216 | 210 | ||
217 | if (split != -1) { | 211 | if (split != -1) { |
218 | group_ = firstPart.left(split); | 212 | group_ = firstPart.left(split); |
219 | firstPart= firstPart.right(firstPart.length() - split - 1); | 213 | firstPart= firstPart.right(firstPart.length() - split - 1); |
220 | } | 214 | } |
221 | 215 | ||
222 | if (qstricmp(firstPart, "END") != 0) // No END ! | 216 | if (qstricmp(firstPart, "END") != 0) // No END ! |
223 | return; | 217 | return; |
224 | 218 | ||
225 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! | 219 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! |
226 | return; | 220 | return; |
221 | #endif | ||
227 | } | 222 | } |
228 | 223 | ||
229 | void | 224 | void |
230 | VCard::_assemble() | 225 | VCard::_assemble() |
231 | { | 226 | { |
232 | vDebug("Assembling vcard"); | 227 | vDebug("Assembling vcard"); |
233 | strRep_ = "BEGIN:VCARD\r\n"; | 228 | strRep_ = "BEGIN:VCARD\r\n"; |
234 | strRep_ += "VERSION:3.0\r\n"; | 229 | strRep_ += "VERSION:3.0\r\n"; |
235 | 230 | ||
236 | QPtrListIterator<ContentLine> it(contentLineList_); | 231 | QPtrListIterator<ContentLine> it(contentLineList_); |
237 | 232 | ||
238 | for (; it.current(); ++it) | 233 | for (; it.current(); ++it) |
239 | strRep_ += it.current()->asString() + "\r\n"; | 234 | strRep_ += it.current()->asString() + "\r\n"; |
240 | 235 | ||
241 | strRep_ += "END:VCARD\r\n"; | 236 | strRep_ += "END:VCARD\r\n"; |
242 | } | 237 | } |
243 | 238 | ||
244 | bool | 239 | bool |
245 | VCard::has(EntityType t) | 240 | VCard::has(EntityType t) |
246 | { | 241 | { |
247 | parse(); | 242 | parse(); |
248 | return contentLine(t) == 0 ? false : true; | 243 | return contentLine(t) == 0 ? false : true; |
249 | } | 244 | } |
250 | 245 | ||
251 | bool | 246 | bool |
252 | VCard::has(const QCString & s) | 247 | VCard::has(const QCString & s) |
253 | { | 248 | { |
254 | parse(); | 249 | parse(); |
255 | return contentLine(s) == 0 ? false : true; | 250 | return contentLine(s) == 0 ? false : true; |
256 | } | 251 | } |
257 | 252 | ||
258 | void | 253 | void |
259 | VCard::add(const ContentLine & cl) | 254 | VCard::add(const ContentLine & cl) |
260 | { | 255 | { |
261 | parse(); | 256 | parse(); |
262 | ContentLine * c = new ContentLine(cl); | 257 | ContentLine * c = new ContentLine(cl); |
263 | contentLineList_.append(c); | 258 | contentLineList_.append(c); |
264 | } | 259 | } |
265 | 260 | ||
266 | void | 261 | void |
267 | VCard::add(const QCString & s) | 262 | VCard::add(const QCString & s) |
268 | { | 263 | { |
269 | parse(); | 264 | parse(); |
270 | ContentLine * c = new ContentLine(s); | 265 | ContentLine * c = new ContentLine(s); |
271 | contentLineList_.append(c); | 266 | contentLineList_.append(c); |
272 | } | 267 | } |
273 | 268 | ||
274 | ContentLine * | 269 | ContentLine * |
275 | VCard::contentLine(EntityType t) | 270 | VCard::contentLine(EntityType t) |
276 | { | 271 | { |
277 | parse(); | 272 | parse(); |
278 | QPtrListIterator<ContentLine> it(contentLineList_); | 273 | QPtrListIterator<ContentLine> it(contentLineList_); |
279 | 274 | ||
280 | for (; it.current(); ++it) | 275 | for (; it.current(); ++it) |
281 | if (it.current()->entityType() == t) | 276 | if (it.current()->entityType() == t) |
282 | return it.current(); | 277 | return it.current(); |
283 | 278 | ||
284 | return 0; | 279 | return 0; |
285 | } | 280 | } |
286 | 281 | ||
287 | ContentLine * | 282 | ContentLine * |
288 | VCard::contentLine(const QCString & s) | 283 | VCard::contentLine(const QCString & s) |
289 | { | 284 | { |
290 | parse(); | 285 | parse(); |
291 | QPtrListIterator<ContentLine> it(contentLineList_); | 286 | QPtrListIterator<ContentLine> it(contentLineList_); |
292 | 287 | ||
293 | for (; it.current(); ++it) | 288 | for (; it.current(); ++it) |
294 | if (it.current()->entityType() == EntityNameToEntityType(s)) | 289 | if (it.current()->entityType() == EntityNameToEntityType(s)) |
295 | return it.current(); | 290 | return it.current(); |
296 | 291 | ||
297 | return 0; | 292 | return 0; |
298 | } | 293 | } |
299 | 294 | ||