24 #include <tqcstring.h>
25 #include <tqstrlist.h>
27 #include <VCardEntity.h>
28 #include <VCardVCard.h>
29 #include <VCardContentLine.h>
30 #include <VCardRToken.h>
32 #include <VCardDefines.h>
34 using namespace VCARD;
39 contentLineList_.setAutoDelete(
true );
42 VCard::VCard(
const VCard & x)
45 contentLineList_(x.contentLineList_)
49 VCard::VCard(
const TQCString & s)
55 VCard::operator = (VCard & x)
57 if (*
this == x)
return *
this;
60 contentLineList_ = x.contentLineList_;
62 Entity::operator = (x);
67 VCard::operator = (
const TQCString & s)
69 Entity::operator = (s);
74 VCard::operator == (VCard & x)
87 vDebug(
"parse() called");
90 RTokenise(strRep_,
"\r\n", l);
93 vDebug(
"Invalid vcard");
98 TQCString beginLine = TQCString(l.at(0)).stripWhiteSpace();
100 vDebug(
"Begin line == \"" + beginLine +
"\"");
103 while (TQCString(l.last()).isEmpty())
107 TQCString endLine = l.last();
116 int split = beginLine.find(
':');
123 TQCString firstPart(beginLine.left(split));
124 TQCString valuePart(beginLine.mid(split + 1));
126 split = firstPart.find(
'.');
129 group_ = firstPart.left(split);
130 firstPart = firstPart.right(firstPart.length() - split - 1);
133 if (tqstrnicmp(firstPart,
"BEGIN", 5) != 0) {
138 if (tqstrnicmp(valuePart,
"VCARD", 5) != 0) {
146 vDebug(
"Content lines");
152 TQStrListIterator it(l);
156 for (; it.current(); ++it) {
164 it.current()[0] ==
' ' &&
165 strlen(it.current()) != 1)
167 cur += it.current() + 1;
173 refolded.append(cur);
176 TQStrListIterator it2(refolded);
178 for (; it2.current(); ++it2) {
180 vDebug(
"New contentline using \"" + TQCString(it2.current()) +
"\"");
181 ContentLine * cl =
new ContentLine(it2.current());
185 contentLineList_.append(cl);
191 split = endLine.find(
':');
196 firstPart = endLine.left(split);
197 valuePart = endLine.right(firstPart.length() - split - 1);
199 split = firstPart.find(
'.');
202 group_ = firstPart.left(split);
203 firstPart = firstPart.right(firstPart.length() - split - 1);
206 if (tqstricmp(firstPart,
"END") != 0)
209 if (tqstricmp(valuePart,
"VCARD") != 0)
216 vDebug(
"Assembling vcard");
217 strRep_ =
"BEGIN:VCARD\r\n";
218 strRep_ +=
"VERSION:3.0\r\n";
220 TQPtrListIterator<ContentLine> it(contentLineList_);
222 for (; it.current(); ++it)
223 strRep_ += it.current()->asString() +
"\r\n";
225 strRep_ +=
"END:VCARD\r\n";
229 VCard::has(EntityType t)
232 return contentLine(t) == 0 ? false :
true;
236 VCard::has(
const TQCString & s)
239 return contentLine(s) == 0 ? false :
true;
243 VCard::add(
const ContentLine & cl)
246 ContentLine * c =
new ContentLine(cl);
247 contentLineList_.append(c);
251 VCard::add(
const TQCString & s)
254 ContentLine * c =
new ContentLine(s);
255 contentLineList_.append(c);
259 VCard::contentLine(EntityType t)
262 TQPtrListIterator<ContentLine> it(contentLineList_);
264 for (; it.current(); ++it)
265 if (it.current()->entityType() == t)
272 VCard::contentLine(
const TQCString & s)
275 TQPtrListIterator<ContentLine> it(contentLineList_);
277 for (; it.current(); ++it)
278 if (it.current()->entityType() == EntityNameToEntityType(s))