summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-15 09:31:52 (UTC)
committer zautrix <zautrix>2005-01-15 09:31:52 (UTC)
commitf9f60d23806530a5bccae372e5eeebee6d528f20 (patch) (unidiff)
treecaa83ca3e29a14a3423a6f4a7f22119148eaef04
parenta423c235d0cbc39292102042ed8f4a953e0e37f9 (diff)
downloadkdepimpi-f9f60d23806530a5bccae372e5eeebee6d528f20.zip
kdepimpi-f9f60d23806530a5bccae372e5eeebee6d528f20.tar.gz
kdepimpi-f9f60d23806530a5bccae372e5eeebee6d528f20.tar.bz2
crash 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 49bfe43..1166aac 100644
--- a/kabc/vcard/VCardv.cpp
+++ b/kabc/vcard/VCardv.cpp
@@ -28,193 +28,193 @@
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30#include <VCardEntity.h> 30#include <VCardEntity.h>
31#include <VCardVCard.h> 31#include <VCardVCard.h>
32#include <VCardContentLine.h> 32#include <VCardContentLine.h>
33#include <VCardRToken.h> 33#include <VCardRToken.h>
34 34
35#include <VCardDefines.h> 35#include <VCardDefines.h>
36 36
37using namespace VCARD; 37using namespace VCARD;
38 38
39VCard::VCard() 39VCard::VCard()
40 :Entity() 40 :Entity()
41{ 41{
42 contentLineList_.setAutoDelete( TRUE ); 42 contentLineList_.setAutoDelete( TRUE );
43} 43}
44 44
45VCard::VCard(const VCard & x) 45VCard::VCard(const VCard & x)
46 :Entity(x), 46 :Entity(x),
47 group_(x.group_) 47 group_(x.group_)
48{ 48{
49 contentLineList_.setAutoDelete( TRUE ); 49 contentLineList_.setAutoDelete( TRUE );
50 50
51 QPtrListIterator<ContentLine> it(x.contentLineList_); 51 QPtrListIterator<ContentLine> it(x.contentLineList_);
52 for (; it.current(); ++it) { 52 for (; it.current(); ++it) {
53 ContentLine * c = new ContentLine(*it.current()); 53 ContentLine * c = new ContentLine(*it.current());
54 contentLineList_.append(c); 54 contentLineList_.append(c);
55 } 55 }
56 56
57} 57}
58 58
59VCard::VCard(const QCString & s) 59VCard::VCard(const QCString & s)
60 :Entity(s) 60 :Entity(s)
61{ 61{
62 contentLineList_.setAutoDelete( TRUE ); 62 contentLineList_.setAutoDelete( TRUE );
63} 63}
64 64
65 VCard & 65 VCard &
66VCard::operator = (VCard & x) 66VCard::operator = (VCard & x)
67{ 67{
68 if (*this == x) return *this; 68 if (*this == x) return *this;
69 69
70 group_ = x.group(); 70 group_ = x.group();
71 QPtrListIterator<ContentLine> it(x.contentLineList_); 71 QPtrListIterator<ContentLine> it(x.contentLineList_);
72 for (; it.current(); ++it) { 72 for (; it.current(); ++it) {
73 ContentLine * c = new ContentLine(*it.current()); 73 ContentLine * c = new ContentLine(*it.current());
74 contentLineList_.append(c); 74 contentLineList_.append(c);
75 } 75 }
76 76
77 Entity::operator = (x); 77 Entity::operator = (x);
78 return *this; 78 return *this;
79} 79}
80 80
81 VCard & 81 VCard &
82VCard::operator = (const QCString & s) 82VCard::operator = (const QCString & s)
83{ 83{
84 Entity::operator = (s); 84 Entity::operator = (s);
85 return *this; 85 return *this;
86} 86}
87 87
88 bool 88 bool
89VCard::operator == (VCard & x) 89VCard::operator == (VCard & x)
90{ 90{
91 x.parse(); 91 x.parse();
92 return false; 92 return false;
93} 93}
94 94
95VCard::~VCard() 95VCard::~VCard()
96{ 96{
97} 97}
98 98
99 void 99 void
100VCard::_parse() 100VCard::_parse()
101{ 101{
102 102
103 QStringList l; 103 QStringList l;
104 QStrList sl; 104 QStrList sl;
105 105
106 RTokenise(strRep_, "\r\n", sl); 106 RTokenise(strRep_, "\r\n", sl);
107 107
108 if (sl.count() < 3) { // Invalid VCARD ! 108 if (sl.count() < 3) { // Invalid VCARD !
109 //qDebug("invalid vcard "); 109 //qDebug("invalid vcard ");
110 return; 110 return;
111 } 111 }
112 l = QStringList::fromStrList( sl ); 112 l = QStringList::fromStrList( sl );
113 // Get the first line 113 // Get the first line
114 QString beginLine = l[0].stripWhiteSpace(); 114 QString beginLine = l[0].stripWhiteSpace();
115 115
116 // Remove extra blank lines 116 // Remove extra blank lines
117 while (l.last().isEmpty()) 117 while (l.last().isEmpty())
118 l.remove(l.last()); 118 l.remove(l.last());
119 119
120 // Now we know this is the last line 120 // Now we know this is the last line
121 QString endLine = l.last(); 121 QString endLine = l.last();
122 122
123 // Trash the first and last lines as we have seen them. 123 // Trash the first and last lines as we have seen them.
124 l.remove(l.first()); 124 l.remove(l.begin());
125 l.remove(l.last()); 125 l.remove(l.last());
126 126
127 /////////////////////////////////////////////////////////////// 127 ///////////////////////////////////////////////////////////////
128 // FIRST LINE 128 // FIRST LINE
129 129
130 int split = beginLine.find(':'); 130 int split = beginLine.find(':');
131 131
132 if (split == -1) { // invalid, no BEGIN 132 if (split == -1) { // invalid, no BEGIN
133 vDebug("No split"); 133 vDebug("No split");
134 return; 134 return;
135 } 135 }
136 136
137 QString firstPart(beginLine.left(split)); 137 QString firstPart(beginLine.left(split));
138 QString valuePart(beginLine.mid(split + 1)); 138 QString valuePart(beginLine.mid(split + 1));
139 139
140 split = firstPart.find('.'); 140 split = firstPart.find('.');
141 141
142 if (split != -1) { 142 if (split != -1) {
143 group_ = firstPart.left(split); 143 group_ = firstPart.left(split);
144 firstPart= firstPart.right(firstPart.length() - split - 1); 144 firstPart= firstPart.right(firstPart.length() - split - 1);
145 } 145 }
146 146
147 if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! 147 if (firstPart.left(5) != "BEGIN" ) { // No BEGIN !
148 qDebug("no BEGIN in vcard "); 148 qDebug("no BEGIN in vcard ");
149 return; 149 return;
150 } 150 }
151 151
152 if (valuePart.left(5) != "VCARD") { // Not a vcard ! 152 if (valuePart.left(5) != "VCARD") { // Not a vcard !
153 qDebug("not a VCARD "); 153 qDebug("not a VCARD ");
154 return; 154 return;
155 } 155 }
156 156
157 /////////////////////////////////////////////////////////////// 157 ///////////////////////////////////////////////////////////////
158 // CONTENT LINES 158 // CONTENT LINES
159 // 159 //
160 vDebug("Content lines"); 160 vDebug("Content lines");
161 161
162 // Handle folded lines. 162 // Handle folded lines.
163 163
164 QStringList refolded; 164 QStringList refolded;
165 165
166 166
167 QStringList::Iterator it = l.begin(); 167 QStringList::Iterator it = l.begin();
168 168
169 QString cur; 169 QString cur;
170 170
171 for (; it != l.end(); ++it) { 171 for (; it != l.end(); ++it) {
172 cur = (*it); 172 cur = (*it);
173 ++it; 173 ++it;
174 while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { 174 while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) {
175 cur += (*it) ; 175 cur += (*it) ;
176 ++it; 176 ++it;
177 } 177 }
178 --it; 178 --it;
179 refolded.append(cur); 179 refolded.append(cur);
180 } 180 }
181 QStringList::Iterator it2 = refolded.begin(); 181 QStringList::Iterator it2 = refolded.begin();
182 for (; it2 != refolded.end(); ++it2) { 182 for (; it2 != refolded.end(); ++it2) {
183 ContentLine * cl = new ContentLine(QCString((*it2).latin1())); 183 ContentLine * cl = new ContentLine(QCString((*it2).latin1()));
184 cl->parse(); 184 cl->parse();
185 if (cl->value() == 0) 185 if (cl->value() == 0)
186 { 186 {
187 qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); 187 qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1());
188 delete cl; 188 delete cl;
189 } 189 }
190 else 190 else
191 contentLineList_.append(cl); 191 contentLineList_.append(cl);
192 } 192 }
193 193
194 /////////////////////////////////////////////////////////////// 194 ///////////////////////////////////////////////////////////////
195 // LAST LINE 195 // LAST LINE
196 196
197 197
198 // LR: sorry, but the remaining code in this method makes no sense 198 // LR: sorry, but the remaining code in this method makes no sense
199 199
200#if 0 200#if 0
201 split = endLine.find(':'); 201 split = endLine.find(':');
202 202
203 if (split == -1) // invalid, no END 203 if (split == -1) // invalid, no END
204 return; 204 return;
205 205
206 firstPart = endLine.left(split); 206 firstPart = endLine.left(split);
207 valuePart = endLine.right(firstPart.length() - split - 1); 207 valuePart = endLine.right(firstPart.length() - split - 1);
208 208
209 split = firstPart.find('.'); 209 split = firstPart.find('.');
210 210
211 if (split != -1) { 211 if (split != -1) {
212 group_ = firstPart.left(split); 212 group_ = firstPart.left(split);
213 firstPart= firstPart.right(firstPart.length() - split - 1); 213 firstPart= firstPart.right(firstPart.length() - split - 1);
214 } 214 }
215 215
216 if (qstricmp(firstPart, "END") != 0) // No END ! 216 if (qstricmp(firstPart, "END") != 0) // No END !
217 return; 217 return;
218 218
219 if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! 219 if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard !
220 return; 220 return;