summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/VCardv.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/VCardv.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardv.cpp77
1 files changed, 36 insertions, 41 deletions
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
@@ -23,6 +23,9 @@
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>
@@ -96,30 +99,29 @@ VCard::~VCard()
96 void 99 void
97VCard::_parse() 100VCard::_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 ///////////////////////////////////////////////////////////////
@@ -132,8 +134,8 @@ VCard::_parse()
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
@@ -142,13 +144,13 @@ VCard::_parse()
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
@@ -159,42 +161,30 @@ VCard::_parse()
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
@@ -204,6 +194,10 @@ VCard::_parse()
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
@@ -224,6 +218,7 @@ VCard::_parse()
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