summaryrefslogtreecommitdiffstats
path: root/kabc/vcard/testread.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kabc/vcard/testread.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kabc/vcard/testread.cpp')
-rw-r--r--kabc/vcard/testread.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/kabc/vcard/testread.cpp b/kabc/vcard/testread.cpp
new file mode 100644
index 000000000..919c6616d
--- /dev/null
+++ b/kabc/vcard/testread.cpp
@@ -0,0 +1,129 @@
+#include <iostream>
+#include <stdlib.h>
+#include <assert.h>
+
+#include <qfile.h>
+#include <qtextstream.h>
+
+#include <VCard.h>
+
+using namespace std;
+
+int main(int argc, char * argv[])
+{
+ if (argc != 2) {
+ cerr << "Usage: " << argv[0] << " <filename>" << endl;
+ exit(1);
+ }
+
+ QFile f(argv[1]);
+
+ QCString str;
+
+ if (!f.open(IO_ReadOnly)) {
+ cerr << "Couldn't open file \"" << argv[1] << endl;
+ exit(1);
+ }
+
+ QTextStream t(&f);
+
+ while (!t.eof())
+ str += t.readLine().utf8() + '\n';
+
+ using namespace VCARD;
+
+ // Iterate through all vCards in the file.
+
+ cout << "--------- begin ----------" << endl;
+ cout << str.data();
+ cout << "--------- end ----------" << endl;
+
+ VCardEntity e(str);
+
+ VCardListIterator it(e.cardList());
+
+ for (; it.current(); ++it) {
+
+ cerr << "****************** VCARD ********************" << endl;
+
+ // Create a vcard using the string representation.
+ VCard & v (*it.current());
+
+ if (v.has(EntityEmail)) {
+ cerr << "Email parameter found" << endl;
+
+ QCString s = v.contentLine(EntityEmail)->value()->asString();
+
+ cerr << "Email value == " << s << endl;
+ }
+
+ if (v.has(EntityNickname)) {
+ cerr << "Nickname parameter found" << endl;
+
+ cerr << "Nickname value == " <<
+ v.contentLine(EntityNickname)->value()->asString() <<
+ endl;
+ }
+
+ if (v.has(EntityRevision)) {
+
+ cerr << "Revision parameter found" << endl;
+
+ DateValue * d =
+ (DateValue *)
+ v.contentLine(EntityRevision)->value();
+
+ assert(d != 0);
+
+ cerr << "Revision date: " << endl;
+ cerr << "Day : " << d->day() << endl;
+ cerr << "Month : " << d->month() << endl;
+ cerr << "Year : " << d->year() << endl;
+
+ if (d->hasTime()) {
+ cerr << "Revision date has a time component" << endl;
+ cerr << "Revision time: " << endl;
+ cerr << "Hour : " << d->hour() << endl;
+ cerr << "Minute : " << d->minute() << endl;
+ cerr << "Second : " << d->second() << endl;
+
+ }
+ else cerr << "Revision date does NOT have a time component" << endl;
+ }
+
+ if (v.has(EntityURL)) {
+ cerr << "URL Parameter found" << endl;
+
+ cerr << "URL Value == " <<
+ v.contentLine(EntityURL)->value()->asString() <<
+ endl;
+
+ URIValue * urlVal =
+ (URIValue *)v.contentLine(EntityURL)->value();
+
+ assert(urlVal != 0);
+
+ cerr << "URL scheme == " <<
+ urlVal->scheme() << endl;
+
+ cerr << "URL scheme specific part == " <<
+ urlVal->schemeSpecificPart() << endl;
+ }
+
+ if (v.has(EntityN)) {
+ cerr << "N Parameter found" << endl;
+
+ NValue * n =
+ (NValue *)(v.contentLine(EntityN)->value());
+
+ cerr << "Family name == " << n->family() << endl;
+ cerr << "Given name == " << n->given() << endl;
+ cerr << "Middle name == " << n->middle() << endl;
+ cerr << "Prefix == " << n->prefix() << endl;
+ cerr << "Suffix == " << n->suffix() << endl;
+ }
+
+ cerr << "***************** END VCARD ******************" << endl;
+ }
+}
+