vcard21parser.h
00001 /* 00002 This file is part of libkabc. 00003 00004 Copyright (c) 2002 Mark Westcott <mark@houseoffish.org> 00005 Copyright (c) 2000 George Staikos <staikos@kde.org> 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KABC_VCARD21FORMAT_H 00023 #define KABC_VCARD21FORMAT_H 00024 00025 #include <tqdatetime.h> 00026 #include <kdebug.h> 00027 #include <tqregexp.h> 00028 #include <tqstring.h> 00029 #include <kurl.h> 00030 #include <tqvaluelist.h> 00031 00032 #include "addressee.h" 00033 #include "addressbook.h" 00034 #include "phonenumber.h" 00035 00036 00037 #define VCARD_BEGIN "begin:vcard" 00038 #define VCARD_END "end:vcard" 00039 #define VCARD_BEGIN_N "begin" 00040 #define VCARD_END_N "end" 00041 #define VCARD_VERSION "version" 00042 00043 #define VCARD_FN "fn" 00044 #define VCARD_N "n" 00045 00046 // optional 00047 #define VCARD_NAME "name" 00048 #define VCARD_NICKNAME "nickname" 00049 #define VCARD_PHOTO "photo" 00050 #define VCARD_BDAY "bday" 00051 #define VCARD_ADR "adr" 00052 00053 // types 00054 #define VCARD_ADR_DOM "dom" 00055 #define VCARD_ADR_INTL "intl" 00056 #define VCARD_ADR_POSTAL "postal" 00057 #define VCARD_ADR_PARCEL "parcel" 00058 #define VCARD_ADR_HOME "home" 00059 #define VCARD_ADR_WORK "work" 00060 #define VCARD_ADR_PREF "pref" 00061 // values 00062 #define VCARD_ADR_POBOX "PO Box" 00063 #define VCARD_ADR_EXTADR "Extended Address" 00064 #define VCARD_ADR_STREET "Street" 00065 #define VCARD_ADR_LOCALITY "Locality" 00066 #define VCARD_ADR_REGION "Region" 00067 #define VCARD_ADR_POSTCODE "Postal Code" 00068 #define VCARD_ADR_COUNTRY "Country Name" 00069 #define VCARD_LABEL "label" 00070 #define VCARD_PROFILE "profile" 00071 #define VCARD_SOURCE "source" 00072 #define VCARD_TEL "tel" 00073 // types 00074 #define VCARD_TEL_HOME "home" 00075 #define VCARD_TEL_WORK "work" 00076 #define VCARD_TEL_PREF "pref" 00077 #define VCARD_TEL_VOICE "voice" 00078 #define VCARD_TEL_FAX "fax" 00079 #define VCARD_TEL_MSG "msg" 00080 #define VCARD_TEL_CELL "cell" 00081 #define VCARD_TEL_PAGER "pager" 00082 #define VCARD_TEL_BBS "bbs" 00083 #define VCARD_TEL_MODEM "modem" 00084 #define VCARD_TEL_CAR "car" 00085 #define VCARD_TEL_ISDN "isdn" 00086 #define VCARD_TEL_VIDEO "video" 00087 #define VCARD_TEL_PCS "pcs" 00088 #define VCARD_EMAIL "email" 00089 // types 00090 #define VCARD_EMAIL_PREF "pref" 00091 #define VCARD_EMAIL_INTERNET "internet" 00092 #define VCARD_EMAIL_X400 "x400" 00093 #define VCARD_TZ "tz" 00094 #define VCARD_GEO "geo" 00095 #define VCARD_MAILER "mailer" 00096 #define VCARD_TITLE "title" 00097 #define VCARD_ROLE "role" 00098 #define VCARD_LOGO "logo" 00099 #define VCARD_AGENT "agent" 00100 #define VCARD_ORG "org" 00101 #define VCARD_CATEGORIES "categories" 00102 #define VCARD_NOTE "note" 00103 #define VCARD_PRODID "prodid" 00104 #define VCARD_REV "rev" 00105 #define VCARD_SOUND "sound" 00106 #define VCARD_UID "uid" 00107 #define VCARD_URL "url" 00108 #define VCARD_CLASS "class" 00109 #define VCARD_CLASS_PUBLIC "public" 00110 #define VCARD_CLASS_PRIVATE "private" 00111 #define VCARD_CLASS_CONFIDENTIAL "confidential" 00112 #define VCARD_KEY "key" 00113 // types 00114 #define VCARD_KEY_X509 "x509" 00115 #define VCARD_KEY_PGP "pgp" 00116 00117 #define VCARD_QUOTED_PRINTABLE "quoted-printable" 00118 // this one is a temporary hack until we support TYPE=VALUE 00119 #define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" 00120 #define VCARD_BASE64 "base64" 00121 00122 #define VC_STATE_BEGIN 1 00123 #define VC_STATE_BODY 2 00124 #define VC_STATE_END 4 00125 #define VC_STATE_HAVE_N 8 00126 #define VC_STATE_HAVE_VERSION 16 00127 00128 #define VC_ERR_NO_BEGIN 1 00129 #define VC_ERR_NO_END 2 00130 #define VC_ERR_INVALID_LINE 3 00131 #define VC_ERR_INTERNAL 4 00132 #define VC_ERR_INVALID_NAME 5 00133 #define VC_ERR_MISSING_MANDATORY 6 00134 00135 namespace KABC { 00136 00137 class AddressBook; 00138 00142 class KABC_EXPORT_DEPRECATED VCard21Parser 00143 { 00144 public: 00145 00149 VCard21Parser(); 00150 00154 virtual ~VCard21Parser(); 00155 00163 void readFromString( KABC::AddressBook *ab, const TQString &str ); 00164 00173 KABC::Addressee readFromString( const TQString &data); 00174 00181 static KABC::Address readAddressFromQStringList (const TQStringList &data, const int type); 00182 }; 00183 00184 } 00185 00189 class KABC_EXPORT VCardLineX 00190 { 00191 public: 00192 TQString name; 00193 bool qualified; 00194 TQValueList<TQString> qualifiers; 00195 TQValueList<TQString> parameters; 00196 bool isValid() const; 00197 }; 00198 00202 class KABC_EXPORT VCard21ParserImpl 00203 { 00204 friend class VCardLineX; 00205 00206 public: 00207 VCard21ParserImpl(); 00208 virtual ~VCard21ParserImpl(); 00209 static VCard21ParserImpl *parseVCard(const TQString& vc, int *err = NULL); 00210 TQString getValue(const TQString& name, const TQString& qualifier); 00211 TQString getValue(const TQString& name); 00212 TQStringList getValues(const TQString& name, const TQString& qualifier); 00213 TQStringList getValues(const TQString& name); 00214 00215 TQValueList<VCardLineX> *_vcdata; 00216 00217 private: 00218 VCard21ParserImpl (TQValueList<VCardLineX> *_vcd); 00219 }; 00220 00221 #endif