summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-29 00:44:07 (UTC)
committer ulf69 <ulf69>2004-09-29 00:44:07 (UTC)
commitbb0e15259ccb1883410435ad76eb0de08b7e2069 (patch) (unidiff)
tree83617ff0d7a2e188c4944783450d7370eae965f1
parent0804930f54a4d7226b62db7878eaedabdf3ebcf6 (diff)
downloadkdepimpi-bb0e15259ccb1883410435ad76eb0de08b7e2069.zip
kdepimpi-bb0e15259ccb1883410435ad76eb0de08b7e2069.tar.gz
kdepimpi-bb0e15259ccb1883410435ad76eb0de08b7e2069.tar.bz2
fixed display bug that I built in with the previous fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardv.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp
index d19a004..bc80707 100644
--- a/kabc/vcard/VCardv.cpp
+++ b/kabc/vcard/VCardv.cpp
@@ -1,299 +1,299 @@
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 26
27#include <VCardEntity.h> 27#include <VCardEntity.h>
28#include <VCardVCard.h> 28#include <VCardVCard.h>
29#include <VCardContentLine.h> 29#include <VCardContentLine.h>
30#include <VCardRToken.h> 30#include <VCardRToken.h>
31 31
32#include <VCardDefines.h> 32#include <VCardDefines.h>
33 33
34using namespace VCARD; 34using namespace VCARD;
35 35
36VCard::VCard() 36VCard::VCard()
37 :Entity() 37 :Entity()
38{ 38{
39 contentLineList_.setAutoDelete( TRUE ); 39 contentLineList_.setAutoDelete( TRUE );
40} 40}
41 41
42VCard::VCard(const VCard & x) 42VCard::VCard(const VCard & x)
43 :Entity(x), 43 :Entity(x),
44 group_(x.group_) 44 group_(x.group_)
45{ 45{
46 contentLineList_.setAutoDelete( TRUE ); 46 contentLineList_.setAutoDelete( TRUE );
47 47
48 QPtrListIterator<ContentLine> it(x.contentLineList_); 48 QPtrListIterator<ContentLine> it(x.contentLineList_);
49 for (; it.current(); ++it) { 49 for (; it.current(); ++it) {
50 ContentLine * c = new ContentLine(*it.current()); 50 ContentLine * c = new ContentLine(*it.current());
51 contentLineList_.append(c); 51 contentLineList_.append(c);
52 } 52 }
53 53
54} 54}
55 55
56VCard::VCard(const QCString & s) 56VCard::VCard(const QCString & s)
57 :Entity(s) 57 :Entity(s)
58{ 58{
59 contentLineList_.setAutoDelete( TRUE ); 59 contentLineList_.setAutoDelete( TRUE );
60} 60}
61 61
62 VCard & 62 VCard &
63VCard::operator = (VCard & x) 63VCard::operator = (VCard & x)
64{ 64{
65 if (*this == x) return *this; 65 if (*this == x) return *this;
66 66
67 group_ = x.group(); 67 group_ = x.group();
68 QPtrListIterator<ContentLine> it(x.contentLineList_); 68 QPtrListIterator<ContentLine> it(x.contentLineList_);
69 for (; it.current(); ++it) { 69 for (; it.current(); ++it) {
70 ContentLine * c = new ContentLine(*it.current()); 70 ContentLine * c = new ContentLine(*it.current());
71 contentLineList_.append(c); 71 contentLineList_.append(c);
72 } 72 }
73 73
74 Entity::operator = (x); 74 Entity::operator = (x);
75 return *this; 75 return *this;
76} 76}
77 77
78 VCard & 78 VCard &
79VCard::operator = (const QCString & s) 79VCard::operator = (const QCString & s)
80{ 80{
81 Entity::operator = (s); 81 Entity::operator = (s);
82 return *this; 82 return *this;
83} 83}
84 84
85 bool 85 bool
86VCard::operator == (VCard & x) 86VCard::operator == (VCard & x)
87{ 87{
88 x.parse(); 88 x.parse();
89 return false; 89 return false;
90} 90}
91 91
92VCard::~VCard() 92VCard::~VCard()
93{ 93{
94} 94}
95 95
96 void 96 void
97VCard::_parse() 97VCard::_parse()
98{ 98{
99 vDebug("parse() called"); 99 vDebug("parse() called");
100 QStrList l; 100 QStrList l;
101 101
102 RTokenise(strRep_, "\r\n", l); 102 RTokenise(strRep_, "\r\n", l);
103 103
104 if (l.count() < 3) { // Invalid VCARD ! 104 if (l.count() < 3) { // Invalid VCARD !
105 vDebug("Invalid vcard"); 105 vDebug("Invalid vcard");
106 return; 106 return;
107 } 107 }
108 108
109 // Get the first line 109 // Get the first line
110 QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); 110 QCString beginLine = QCString(l.at(0)).stripWhiteSpace();
111 111
112 vDebug("Begin line == \"" + beginLine + "\""); 112 vDebug("Begin line == \"" + beginLine + "\"");
113 113
114 // Remove extra blank lines 114 // Remove extra blank lines
115 while (QCString(l.last()).isEmpty()) 115 while (QCString(l.last()).isEmpty())
116 l.remove(l.last()); 116 l.remove(l.last());
117 117
118 // Now we know this is the last line 118 // Now we know this is the last line
119 QCString endLine = l.last(); 119 QCString endLine = l.last();
120 120
121 // Trash the first and last lines as we have seen them. 121 // Trash the first and last lines as we have seen them.
122 l.remove(0u); 122 l.remove(0u);
123 l.remove(l.last()); 123 l.remove(l.last());
124 124
125 /////////////////////////////////////////////////////////////// 125 ///////////////////////////////////////////////////////////////
126 // FIRST LINE 126 // FIRST LINE
127 127
128 int split = beginLine.find(':'); 128 int split = beginLine.find(':');
129 129
130 if (split == -1) { // invalid, no BEGIN 130 if (split == -1) { // invalid, no BEGIN
131 vDebug("No split"); 131 vDebug("No split");
132 return; 132 return;
133 } 133 }
134 134
135 QCString firstPart(beginLine.left(split)); 135 QCString firstPart(beginLine.left(split));
136 QCString valuePart(beginLine.mid(split + 1)); 136 QCString valuePart(beginLine.mid(split + 1));
137 137
138 split = firstPart.find('.'); 138 split = firstPart.find('.');
139 139
140 if (split != -1) { 140 if (split != -1) {
141 group_ = firstPart.left(split); 141 group_ = firstPart.left(split);
142 firstPart= firstPart.right(firstPart.length() - split - 1); 142 firstPart= firstPart.right(firstPart.length() - split - 1);
143 } 143 }
144 144
145 if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! 145 if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN !
146 vDebug("No BEGIN"); 146 vDebug("No BEGIN");
147 return; 147 return;
148 } 148 }
149 149
150 if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! 150 if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard !
151 vDebug("No VCARD"); 151 vDebug("No VCARD");
152 return; 152 return;
153 } 153 }
154 154
155 /////////////////////////////////////////////////////////////// 155 ///////////////////////////////////////////////////////////////
156 // CONTENT LINES 156 // CONTENT LINES
157 // 157 //
158 vDebug("Content lines"); 158 vDebug("Content lines");
159 159
160 // Handle folded lines. 160 // Handle folded lines.
161 161
162 QStrList refolded; 162 QStrList refolded;
163 163
164 QStrListIterator it(l); 164 QStrListIterator it(l);
165 165
166 QCString cur; 166 QCString cur;
167 167
168 for (; it.current(); ++it) { 168 for (; it.current(); ++it) {
169 169
170 cur = it.current(); 170 cur = it.current();
171 171
172 ++it; 172 ++it;
173 173
174 while ( 174 while (
175 it.current() && 175 it.current() &&
176 it.current()[0] == ' '&& 176 it.current()[0] == ' '&&
177 strlen(it.current()) != 1) 177 strlen(it.current()) != 1)
178 { 178 {
179 cur += it.current() + 1; 179 cur += it.current() + 1;
180 ++it; 180 ++it;
181 } 181 }
182 182
183 --it; 183 --it;
184 184
185 refolded.append(cur); 185 refolded.append(cur);
186 } 186 }
187 187
188 QStrListIterator it2(refolded); 188 QStrListIterator it2(refolded);
189 189
190 for (; it2.current(); ++it2) { 190 for (; it2.current(); ++it2) {
191 vDebug("New contentline using \"" + QCString(it2.current()) + "\""); 191 vDebug("New contentline using \"" + QCString(it2.current()) + "\"");
192 ContentLine * cl = new ContentLine(it2.current()); 192 ContentLine * cl = new ContentLine(it2.current());
193 193
194 cl->parse(); 194 cl->parse();
195 if (cl->value() == 0) 195 if (cl->value() == 0)
196 { 196 {
197 qDebug("Content line could not be parsed. Discarded: %s" + QCString(it2.current())); 197 qDebug("Content line could not be parsed. Discarded: %s", it2.current());
198 delete cl; 198 delete cl;
199 } 199 }
200 else 200 else
201 contentLineList_.append(cl); 201 contentLineList_.append(cl);
202 } 202 }
203 203
204 /////////////////////////////////////////////////////////////// 204 ///////////////////////////////////////////////////////////////
205 // LAST LINE 205 // LAST LINE
206 206
207 split = endLine.find(':'); 207 split = endLine.find(':');
208 208
209 if (split == -1) // invalid, no END 209 if (split == -1) // invalid, no END
210 return; 210 return;
211 211
212 firstPart = endLine.left(split); 212 firstPart = endLine.left(split);
213 valuePart = endLine.right(firstPart.length() - split - 1); 213 valuePart = endLine.right(firstPart.length() - split - 1);
214 214
215 split = firstPart.find('.'); 215 split = firstPart.find('.');
216 216
217 if (split != -1) { 217 if (split != -1) {
218 group_ = firstPart.left(split); 218 group_ = firstPart.left(split);
219 firstPart= firstPart.right(firstPart.length() - split - 1); 219 firstPart= firstPart.right(firstPart.length() - split - 1);
220 } 220 }
221 221
222 if (qstricmp(firstPart, "END") != 0) // No END ! 222 if (qstricmp(firstPart, "END") != 0) // No END !
223 return; 223 return;
224 224
225 if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! 225 if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard !
226 return; 226 return;
227} 227}
228 228
229 void 229 void
230VCard::_assemble() 230VCard::_assemble()
231{ 231{
232 vDebug("Assembling vcard"); 232 vDebug("Assembling vcard");
233 strRep_ = "BEGIN:VCARD\r\n"; 233 strRep_ = "BEGIN:VCARD\r\n";
234 strRep_ += "VERSION:3.0\r\n"; 234 strRep_ += "VERSION:3.0\r\n";
235 235
236 QPtrListIterator<ContentLine> it(contentLineList_); 236 QPtrListIterator<ContentLine> it(contentLineList_);
237 237
238 for (; it.current(); ++it) 238 for (; it.current(); ++it)
239 strRep_ += it.current()->asString() + "\r\n"; 239 strRep_ += it.current()->asString() + "\r\n";
240 240
241 strRep_ += "END:VCARD\r\n"; 241 strRep_ += "END:VCARD\r\n";
242} 242}
243 243
244 bool 244 bool
245VCard::has(EntityType t) 245VCard::has(EntityType t)
246{ 246{
247 parse(); 247 parse();
248 return contentLine(t) == 0 ? false : true; 248 return contentLine(t) == 0 ? false : true;
249} 249}
250 250
251 bool 251 bool
252VCard::has(const QCString & s) 252VCard::has(const QCString & s)
253{ 253{
254 parse(); 254 parse();
255 return contentLine(s) == 0 ? false : true; 255 return contentLine(s) == 0 ? false : true;
256} 256}
257 257
258 void 258 void
259VCard::add(const ContentLine & cl) 259VCard::add(const ContentLine & cl)
260{ 260{
261 parse(); 261 parse();
262 ContentLine * c = new ContentLine(cl); 262 ContentLine * c = new ContentLine(cl);
263 contentLineList_.append(c); 263 contentLineList_.append(c);
264} 264}
265 265
266 void 266 void
267VCard::add(const QCString & s) 267VCard::add(const QCString & s)
268{ 268{
269 parse(); 269 parse();
270 ContentLine * c = new ContentLine(s); 270 ContentLine * c = new ContentLine(s);
271 contentLineList_.append(c); 271 contentLineList_.append(c);
272} 272}
273 273
274 ContentLine * 274 ContentLine *
275VCard::contentLine(EntityType t) 275VCard::contentLine(EntityType t)
276{ 276{
277 parse(); 277 parse();
278 QPtrListIterator<ContentLine> it(contentLineList_); 278 QPtrListIterator<ContentLine> it(contentLineList_);
279 279
280 for (; it.current(); ++it) 280 for (; it.current(); ++it)
281 if (it.current()->entityType() == t) 281 if (it.current()->entityType() == t)
282 return it.current(); 282 return it.current();
283 283
284 return 0; 284 return 0;
285} 285}
286 286
287 ContentLine * 287 ContentLine *
288VCard::contentLine(const QCString & s) 288VCard::contentLine(const QCString & s)
289{ 289{
290 parse(); 290 parse();
291 QPtrListIterator<ContentLine> it(contentLineList_); 291 QPtrListIterator<ContentLine> it(contentLineList_);
292 292
293 for (; it.current(); ++it) 293 for (; it.current(); ++it)
294 if (it.current()->entityType() == EntityNameToEntityType(s)) 294 if (it.current()->entityType() == EntityNameToEntityType(s))
295 return it.current(); 295 return it.current();
296 296
297 return 0; 297 return 0;
298} 298}
299 299