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