summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/VCardv.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/vcard/VCardv.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kabc/vcard/VCardv.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardv.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp
index bad2ef1..5dd675d 100644
--- a/kabc/vcard/VCardv.cpp
+++ b/kabc/vcard/VCardv.cpp
@@ -18,17 +18,17 @@
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 <q3cstring.h>
25#include <qstrlist.h> 25#include <q3strlist.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qvaluelist.h> 28#include <q3valuelist.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
@@ -45,44 +45,44 @@ VCard::VCard()
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 Q3PtrListIterator<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 Q3CString & 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 Q3PtrListIterator<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 Q3CString & 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
@@ -98,21 +98,22 @@ VCard::~VCard()
98 98
99 void 99 void
100VCard::_parse() 100VCard::_parse()
101{ 101{
102 102
103 QStringList l; 103 QStringList l;
104 QStrList sl; 104 Q3StrList 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 for(Q3StrList::iterator i=sl.begin();i!=sl.end();++i)
113 l.push_back(*i);
113 // Get the first line 114 // Get the first line
114 QString beginLine = l[0].stripWhiteSpace(); 115 QString beginLine = l[0].stripWhiteSpace();
115 116
116 // Remove extra blank lines 117 // Remove extra blank lines
117 while (l.last().isEmpty()) 118 while (l.last().isEmpty())
118 l.remove(l.last()); 119 l.remove(l.last());
@@ -177,13 +178,13 @@ VCard::_parse()
177 } 178 }
178 --it; 179 --it;
179 refolded.append(cur); 180 refolded.append(cur);
180 } 181 }
181 QStringList::Iterator it2 = refolded.begin(); 182 QStringList::Iterator it2 = refolded.begin();
182 for (; it2 != refolded.end(); ++it2) { 183 for (; it2 != refolded.end(); ++it2) {
183 ContentLine * cl = new ContentLine(QCString((*it2).latin1())); 184 ContentLine * cl = new ContentLine(Q3CString((*it2).latin1()));
184 cl->parse(); 185 cl->parse();
185 if (cl->value() == 0) 186 if (cl->value() == 0)
186 { 187 {
187 qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); 188 qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1());
188 delete cl; 189 delete cl;
189 } 190 }
@@ -225,13 +226,13 @@ VCard::_parse()
225VCard::_assemble() 226VCard::_assemble()
226{ 227{
227 vDebug("Assembling vcard"); 228 vDebug("Assembling vcard");
228 strRep_ = "BEGIN:VCARD\r\n"; 229 strRep_ = "BEGIN:VCARD\r\n";
229 strRep_ += "VERSION:3.0\r\n"; 230 strRep_ += "VERSION:3.0\r\n";
230 231
231 QPtrListIterator<ContentLine> it(contentLineList_); 232 Q3PtrListIterator<ContentLine> it(contentLineList_);
232 233
233 for (; it.current(); ++it) 234 for (; it.current(); ++it)
234 strRep_ += it.current()->asString() + "\r\n"; 235 strRep_ += it.current()->asString() + "\r\n";
235 236
236 strRep_ += "END:VCARD\r\n"; 237 strRep_ += "END:VCARD\r\n";
237} 238}
@@ -241,13 +242,13 @@ VCard::has(EntityType t)
241{ 242{
242 parse(); 243 parse();
243 return contentLine(t) == 0 ? false : true; 244 return contentLine(t) == 0 ? false : true;
244} 245}
245 246
246 bool 247 bool
247VCard::has(const QCString & s) 248VCard::has(const Q3CString & s)
248{ 249{
249 parse(); 250 parse();
250 return contentLine(s) == 0 ? false : true; 251 return contentLine(s) == 0 ? false : true;
251} 252}
252 253
253 void 254 void
@@ -256,37 +257,37 @@ VCard::add(const ContentLine & cl)
256 parse(); 257 parse();
257 ContentLine * c = new ContentLine(cl); 258 ContentLine * c = new ContentLine(cl);
258 contentLineList_.append(c); 259 contentLineList_.append(c);
259} 260}
260 261
261 void 262 void
262VCard::add(const QCString & s) 263VCard::add(const Q3CString & s)
263{ 264{
264 parse(); 265 parse();
265 ContentLine * c = new ContentLine(s); 266 ContentLine * c = new ContentLine(s);
266 contentLineList_.append(c); 267 contentLineList_.append(c);
267} 268}
268 269
269 ContentLine * 270 ContentLine *
270VCard::contentLine(EntityType t) 271VCard::contentLine(EntityType t)
271{ 272{
272 parse(); 273 parse();
273 QPtrListIterator<ContentLine> it(contentLineList_); 274 Q3PtrListIterator<ContentLine> it(contentLineList_);
274 275
275 for (; it.current(); ++it) 276 for (; it.current(); ++it)
276 if (it.current()->entityType() == t) 277 if (it.current()->entityType() == t)
277 return it.current(); 278 return it.current();
278 279
279 return 0; 280 return 0;
280} 281}
281 282
282 ContentLine * 283 ContentLine *
283VCard::contentLine(const QCString & s) 284VCard::contentLine(const Q3CString & s)
284{ 285{
285 parse(); 286 parse();
286 QPtrListIterator<ContentLine> it(contentLineList_); 287 Q3PtrListIterator<ContentLine> it(contentLineList_);
287 288
288 for (; it.current(); ++it) 289 for (; it.current(); ++it)
289 if (it.current()->entityType() == EntityNameToEntityType(s)) 290 if (it.current()->entityType() == EntityNameToEntityType(s))
290 return it.current(); 291 return it.current();
291 292
292 return 0; 293 return 0;