summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/address.cpp630
-rw-r--r--kabc/address.h346
-rw-r--r--kabc/addressbook.cpp655
-rw-r--r--kabc/addressbook.h337
-rw-r--r--kabc/addressee.cpp1616
-rw-r--r--kabc/addressee.h817
-rw-r--r--kabc/addresseedialog.cpp264
-rw-r--r--kabc/addresseedialog.h160
-rw-r--r--kabc/addresseelist.cpp292
-rw-r--r--kabc/addresseelist.h218
-rw-r--r--kabc/agent.cpp155
-rw-r--r--kabc/agent.h129
-rw-r--r--kabc/distributionlist.cpp293
-rw-r--r--kabc/distributionlist.h219
-rw-r--r--kabc/distributionlistdialog.cpp396
-rw-r--r--kabc/distributionlistdialog.h140
-rw-r--r--kabc/distributionlisteditor.cpp335
-rw-r--r--kabc/distributionlisteditor.h86
-rw-r--r--kabc/field.cpp550
-rw-r--r--kabc/field.h178
-rw-r--r--kabc/formatfactory.cpp181
-rw-r--r--kabc/formatfactory.h104
-rw-r--r--kabc/formatplugin.h81
-rw-r--r--kabc/formats/binaryformat.cpp236
-rw-r--r--kabc/formats/binaryformat.h76
-rw-r--r--kabc/formats/vcardformatplugin2.cpp123
-rw-r--r--kabc/formats/vcardformatplugin2.h68
-rw-r--r--kabc/geo.cpp116
-rw-r--r--kabc/geo.h106
-rw-r--r--kabc/kabc.pro214
-rw-r--r--kabc/kabcE.pro202
-rw-r--r--kabc/key.cpp160
-rw-r--r--kabc/key.h155
-rw-r--r--kabc/phonenumber.cpp204
-rw-r--r--kabc/phonenumber.h165
-rw-r--r--kabc/picture.cpp141
-rw-r--r--kabc/picture.h134
-rw-r--r--kabc/plugin.cpp61
-rw-r--r--kabc/plugin.h50
-rw-r--r--kabc/plugins/dir/resourcedir.cpp363
-rw-r--r--kabc/plugins/dir/resourcedir.h115
-rw-r--r--kabc/plugins/dir/resourcedirconfig.cpp123
-rw-r--r--kabc/plugins/dir/resourcedirconfig.h61
-rw-r--r--kabc/plugins/file/resourcefile.cpp389
-rw-r--r--kabc/plugins/file/resourcefile.h162
-rw-r--r--kabc/plugins/file/resourcefileconfig.cpp144
-rw-r--r--kabc/plugins/file/resourcefileconfig.h65
-rw-r--r--kabc/plugins/ldap/resourceldap.cpp444
-rw-r--r--kabc/plugins/ldap/resourceldap.h99
-rw-r--r--kabc/plugins/ldap/resourceldapconfig.cpp254
-rw-r--r--kabc/plugins/ldap/resourceldapconfig.h100
-rw-r--r--kabc/resource.cpp95
-rw-r--r--kabc/resource.h134
-rw-r--r--kabc/secrecy.cpp107
-rw-r--r--kabc/secrecy.h102
-rw-r--r--kabc/sound.cpp117
-rw-r--r--kabc/sound.h123
-rw-r--r--kabc/stdaddressbook.cpp249
-rw-r--r--kabc/stdaddressbook.h151
-rw-r--r--kabc/timezone.cpp92
-rw-r--r--kabc/timezone.h94
-rw-r--r--kabc/vcard/AdrParam.cpp126
-rw-r--r--kabc/vcard/AdrValue.cpp140
-rw-r--r--kabc/vcard/AgentParam.cpp103
-rw-r--r--kabc/vcard/AgentValue.cpp81
-rw-r--r--kabc/vcard/ClassValue.cpp120
-rw-r--r--kabc/vcard/ContentLine.cpp289
-rw-r--r--kabc/vcard/DateParam.cpp82
-rw-r--r--kabc/vcard/DateValue.cpp434
-rw-r--r--kabc/vcard/EmailParam.cpp116
-rw-r--r--kabc/vcard/Entity.cpp134
-rw-r--r--kabc/vcard/Enum.cpp482
-rw-r--r--kabc/vcard/FloatValue.cpp120
-rw-r--r--kabc/vcard/GeoValue.cpp100
-rw-r--r--kabc/vcard/ImageParam.cpp81
-rw-r--r--kabc/vcard/ImageValue.cpp81
-rw-r--r--kabc/vcard/ImgValue.cpp81
-rw-r--r--kabc/vcard/LangValue.cpp127
-rw-r--r--kabc/vcard/NValue.cpp128
-rw-r--r--kabc/vcard/OrgValue.cpp107
-rw-r--r--kabc/vcard/Param.cpp129
-rw-r--r--kabc/vcard/PhoneNumberValue.cpp81
-rw-r--r--kabc/vcard/README15
-rw-r--r--kabc/vcard/RToken.cpp88
-rw-r--r--kabc/vcard/SoundValue.cpp81
-rw-r--r--kabc/vcard/SourceParam.cpp112
-rw-r--r--kabc/vcard/TelParam.cpp81
-rw-r--r--kabc/vcard/TelValue.cpp81
-rw-r--r--kabc/vcard/TextBinParam.cpp81
-rw-r--r--kabc/vcard/TextBinValue.cpp104
-rw-r--r--kabc/vcard/TextListValue.cpp107
-rw-r--r--kabc/vcard/TextParam.cpp82
-rw-r--r--kabc/vcard/TextValue.cpp86
-rw-r--r--kabc/vcard/URIValue.cpp133
-rw-r--r--kabc/vcard/UTCValue.cpp110
-rw-r--r--kabc/vcard/VCardEntity.cpp119
-rw-r--r--kabc/vcard/VCardv.cpp282
-rw-r--r--kabc/vcard/Value.cpp82
-rw-r--r--kabc/vcard/include/VCard.h43
-rw-r--r--kabc/vcard/include/VCardAdrParam.h64
-rw-r--r--kabc/vcard/include/VCardAdrValue.h83
-rw-r--r--kabc/vcard/include/VCardAgentParam.h60
-rw-r--r--kabc/vcard/include/VCardAgentValue.h44
-rw-r--r--kabc/vcard/include/VCardClassValue.h56
-rw-r--r--kabc/vcard/include/VCardContentLine.h77
-rw-r--r--kabc/vcard/include/VCardDateParam.h44
-rw-r--r--kabc/vcard/include/VCardDateValue.h99
-rw-r--r--kabc/vcard/include/VCardDefines.h52
-rw-r--r--kabc/vcard/include/VCardEmailParam.h56
-rw-r--r--kabc/vcard/include/VCardEntity.h67
-rw-r--r--kabc/vcard/include/VCardEnum.h120
-rw-r--r--kabc/vcard/include/VCardFloatValue.h51
-rw-r--r--kabc/vcard/include/VCardGeoValue.h49
-rw-r--r--kabc/vcard/include/VCardGroup.h39
-rw-r--r--kabc/vcard/include/VCardImageParam.h44
-rw-r--r--kabc/vcard/include/VCardImageValue.h44
-rw-r--r--kabc/vcard/include/VCardImgValue.h39
-rw-r--r--kabc/vcard/include/VCardLangValue.h51
-rw-r--r--kabc/vcard/include/VCardNValue.h56
-rw-r--r--kabc/vcard/include/VCardOrgValue.h50
-rw-r--r--kabc/vcard/include/VCardParam.h59
-rw-r--r--kabc/vcard/include/VCardPhoneNumberValue.h39
-rw-r--r--kabc/vcard/include/VCardRToken.h38
-rw-r--r--kabc/vcard/include/VCardSndValue.h39
-rw-r--r--kabc/vcard/include/VCardSoundValue.h44
-rw-r--r--kabc/vcard/include/VCardSourceParam.h58
-rw-r--r--kabc/vcard/include/VCardTelParam.h51
-rw-r--r--kabc/vcard/include/VCardTelValue.h44
-rw-r--r--kabc/vcard/include/VCardTextBinParam.h44
-rw-r--r--kabc/vcard/include/VCardTextBinValue.h67
-rw-r--r--kabc/vcard/include/VCardTextListValue.h51
-rw-r--r--kabc/vcard/include/VCardTextParam.h44
-rw-r--r--kabc/vcard/include/VCardTextValue.h41
-rw-r--r--kabc/vcard/include/VCardURIValue.h52
-rw-r--r--kabc/vcard/include/VCardUTCValue.h58
-rw-r--r--kabc/vcard/include/VCardVCard.h63
-rw-r--r--kabc/vcard/include/VCardVCardEntity.h56
-rw-r--r--kabc/vcard/include/VCardValue.h46
-rw-r--r--kabc/vcard/include/generated/AdrParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/AdrValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/AgentParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/AgentValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/ClassValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/ContentLine-generated.h23
-rw-r--r--kabc/vcard/include/generated/DateParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/DateValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/EmailParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/FloatValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/GeoValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/Group-generated.h23
-rw-r--r--kabc/vcard/include/generated/ImageParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/ImageValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/ImgParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/ImgValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/LangValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/NValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/Name-generated.h22
-rw-r--r--kabc/vcard/include/generated/OrgValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/Param-generated.h23
-rw-r--r--kabc/vcard/include/generated/ParamName-generated.h22
-rw-r--r--kabc/vcard/include/generated/ParamValue-generated.h22
-rw-r--r--kabc/vcard/include/generated/PhoneNumberValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/SoundValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/SourceParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/TelParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/TelValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/TextBinParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/TextBinValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/TextListValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/TextNSParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/TextParam-generated.h23
-rw-r--r--kabc/vcard/include/generated/TextValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/URIValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/UTCValue-generated.h23
-rw-r--r--kabc/vcard/include/generated/VCard-generated.h23
-rw-r--r--kabc/vcard/include/generated/VCardEntity-generated.h23
-rw-r--r--kabc/vcard/include/generated/Value-generated.h23
-rw-r--r--kabc/vcard/include/generated/generate2
-rw-r--r--kabc/vcard/include/generated/generateHeaders.awk40
-rw-r--r--kabc/vcard/include/generated/headerBodies34
-rw-r--r--kabc/vcard/testread.cpp129
-rw-r--r--kabc/vcard/testwrite.cpp41
-rw-r--r--kabc/vcard/vCard-all.cpp37
-rw-r--r--kabc/vcard21parser.cpp606
-rw-r--r--kabc/vcard21parser.h225
-rw-r--r--kabc/vcardconverter.cpp115
-rw-r--r--kabc/vcardconverter.h120
-rw-r--r--kabc/vcardformatimpl.cpp1023
-rw-r--r--kabc/vcardformatimpl.h112
-rw-r--r--kabc/vcardformatplugin.cpp66
-rw-r--r--kabc/vcardformatplugin.h56
-rw-r--r--kabc/vcardparser/vcard.cpp144
-rw-r--r--kabc/vcardparser/vcard.h90
-rw-r--r--kabc/vcardparser/vcardline.cpp148
-rw-r--r--kabc/vcardparser/vcardline.h99
-rw-r--r--kabc/vcardparser/vcardparser.cpp233
-rw-r--r--kabc/vcardparser/vcardparser.h40
-rw-r--r--kabc/vcardparser/vcardtool.cpp883
-rw-r--r--kabc/vcardparser/vcardtool.h88
199 files changed, 26169 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
new file mode 100644
index 0000000..26e0b6a
--- a/dev/null
+++ b/kabc/address.cpp
@@ -0,0 +1,630 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+//US added kglobal.h
+#include <kglobal.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <ksimpleconfig.h>
+#include <kstandarddirs.h>
+
+#include <qfile.h>
+
+#include "address.h"
+
+using namespace KABC;
+
+QMap<QString, QString> Address::mISOMap;
+
+Address::Address() :
+ mEmpty( true ), mType( 0 )
+{
+ mId = KApplication::randomString( 10 );
+}
+
+Address::Address( int type ) :
+ mEmpty( true ), mType( type )
+{
+ mId = KApplication::randomString( 10 );
+}
+
+bool Address::operator==( const Address &a ) const
+{
+ if ( mPostOfficeBox != a.mPostOfficeBox ) return false;
+ if ( mExtended != a.mExtended ) return false;
+ if ( mStreet != a.mStreet ) return false;
+ if ( mLocality != a.mLocality ) return false;
+ if ( mRegion != a.mRegion ) return false;
+ if ( mPostalCode != a.mPostalCode ) return false;
+ if ( mCountry != a.mCountry ) return false;
+ if ( mLabel != a.mLabel ) return false;
+
+ return true;
+}
+
+bool Address::operator!=( const Address &a ) const
+{
+ return !( a == *this );
+}
+
+bool Address::isEmpty() const
+{
+ if ( mPostOfficeBox.isEmpty() &&
+ mExtended.isEmpty() &&
+ mStreet.isEmpty() &&
+ mLocality.isEmpty() &&
+ mRegion.isEmpty() &&
+ mPostalCode.isEmpty() &&
+ mCountry.isEmpty() &&
+ mLabel.isEmpty() ) {
+ return true;
+ }
+ return false;
+}
+
+void Address::clear()
+{
+ *this = Address();
+}
+
+void Address::setId( const QString &id )
+{
+ mEmpty = false;
+
+ mId = id;
+}
+
+QString Address::id() const
+{
+ return mId;
+}
+
+void Address::setType( int type )
+{
+ mEmpty = false;
+
+ mType = type;
+}
+
+int Address::type() const
+{
+ return mType;
+}
+
+QString Address::typeLabel() const
+{
+ QString label;
+ bool first = true;
+
+ TypeList list = typeList();
+
+ TypeList::Iterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
+ label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
+ if ( first )
+ first = false;
+ }
+ }
+
+ return label;
+}
+
+void Address::setPostOfficeBox( const QString &s )
+{
+ mEmpty = false;
+
+ mPostOfficeBox = s;
+}
+
+QString Address::postOfficeBox() const
+{
+ return mPostOfficeBox;
+}
+
+QString Address::postOfficeBoxLabel()
+{
+ return i18n("Post Office Box");
+}
+
+
+void Address::setExtended( const QString &s )
+{
+ mEmpty = false;
+
+ mExtended = s;
+}
+
+QString Address::extended() const
+{
+ return mExtended;
+}
+
+QString Address::extendedLabel()
+{
+ return i18n("Extended Address Information");
+}
+
+
+void Address::setStreet( const QString &s )
+{
+ mEmpty = false;
+
+ mStreet = s;
+}
+
+QString Address::street() const
+{
+ return mStreet;
+}
+
+QString Address::streetLabel()
+{
+ return i18n("Street");
+}
+
+
+void Address::setLocality( const QString &s )
+{
+ mEmpty = false;
+
+ mLocality = s;
+}
+
+QString Address::locality() const
+{
+ return mLocality;
+}
+
+QString Address::localityLabel()
+{
+ return i18n("Locality");
+}
+
+
+void Address::setRegion( const QString &s )
+{
+ mEmpty = false;
+
+ mRegion = s;
+}
+
+QString Address::region() const
+{
+ return mRegion;
+}
+
+QString Address::regionLabel()
+{
+ return i18n("Region");
+}
+
+
+void Address::setPostalCode( const QString &s )
+{
+ mEmpty = false;
+
+ mPostalCode = s;
+}
+
+QString Address::postalCode() const
+{
+ return mPostalCode;
+}
+
+QString Address::postalCodeLabel()
+{
+ return i18n("Postal Code");
+}
+
+
+void Address::setCountry( const QString &s )
+{
+ mEmpty = false;
+
+ mCountry = s;
+}
+
+QString Address::country() const
+{
+ return mCountry;
+}
+
+QString Address::countryLabel()
+{
+ return i18n("Country");
+}
+
+
+void Address::setLabel( const QString &s )
+{
+ mEmpty = false;
+
+ mLabel = s;
+}
+
+QString Address::label() const
+{
+ return mLabel;
+}
+
+QString Address::labelLabel()
+{
+ return i18n("Delivery Label");
+}
+
+Address::TypeList Address::typeList()
+{
+ TypeList list;
+
+ list << Dom << Intl << Postal << Parcel << Home << Work << Pref;
+
+ return list;
+}
+
+QString Address::typeLabel( int type )
+{
+ switch ( type ) {
+ case Dom:
+ return i18n("Domestic");
+ break;
+ case Intl:
+ return i18n("International");
+ break;
+ case Postal:
+ return i18n("Postal");
+ break;
+ case Parcel:
+ return i18n("Parcel");
+ break;
+ case Home:
+ return i18n("Home Address", "Home");
+ break;
+ case Work:
+ return i18n("Work Address", "Work");
+ break;
+ case Pref:
+ return i18n("Preferred Address");
+ break;
+ default:
+ return i18n("Other");
+ break;
+ }
+}
+
+void Address::dump() const
+{
+ qDebug("Address::dump() +++++++++++++++++ ");
+#if 0
+ kdDebug(5700) << " Address {" << endl;
+ kdDebug(5700) << " Id: " << id() << endl;
+ kdDebug(5700) << " Extended: " << extended() << endl;
+ kdDebug(5700) << " Street: " << street() << endl;
+ kdDebug(5700) << " Postal Code: " << postalCode() << endl;
+ kdDebug(5700) << " Locality: " << locality() << endl;
+ kdDebug(5700) << " }" << endl;
+#endif
+}
+
+
+QString Address::formattedAddress( const QString &realName
+ , const QString &orgaName ) const
+{
+ QString ciso;
+ QString addrTemplate;
+ QString ret;
+
+ // **************************************************************
+ // LR: currently we have no iso handling - we will format the address manually here
+
+ QString text;
+ if ( !street().isEmpty() )
+ text += street() + "\n";
+
+ if ( !postOfficeBox().isEmpty() )
+ text += postOfficeBox() + "\n";
+
+ text += locality() + QString(" ") + region();
+
+ if ( !postalCode().isEmpty() )
+ text += QString(", ") + postalCode();
+
+ text += "\n";
+
+ if ( !country().isEmpty() )
+ text += country() + "\n";
+
+ text += extended();
+
+
+ return text;
+ // **************************************************************
+
+ // FIXME: first check for iso-country-field and prefer that one
+ if ( !country().isEmpty() ) {
+ ciso = countryToISO( country() );
+ } else {
+ // fall back to our own country
+ ciso = KGlobal::locale()->country();
+ }
+ //qDebug("ciso %s ",ciso.latin1() );
+ KSimpleConfig entry( locate( "locale",
+ QString( "l10n/" ) + ciso + QString( "/entry.desktop" ) ) );
+ entry.setGroup( "KCM Locale" );
+
+ // decide whether this needs special business address formatting
+ if ( orgaName.isNull() ) {
+ addrTemplate = entry.readEntry( "AddressFormat" );
+ } else {
+ addrTemplate = entry.readEntry( "BusinessAddressFormat" );
+ if ( addrTemplate.isEmpty() )
+ addrTemplate = entry.readEntry( "AddressFormat" );
+ }
+
+ // in the case there's no format found at all, default to what we've always
+ // used:
+ if ( addrTemplate.isEmpty() ) {
+ qDebug("address format database incomplete****************** ");
+ kdWarning(5700) << "address format database incomplete "
+ << "(no format for locale " << ciso
+ << " found). Using default address formatting." << endl;
+ addrTemplate = "%0(%n\\n)%0(%cm\\n)%0(%s\\n)%0(PO BOX %p\\n)%0(%l%w%r)%,%z";
+ }
+
+ // scan
+ parseAddressTemplateSection( addrTemplate, ret, realName, orgaName );
+
+ // now add the country line if needed (formatting this time according to
+ // the rules of our own system country )
+ if ( !country().isEmpty() ) {
+ KSimpleConfig entry( locate( "locale", QString( "l10n/" )
+ + KGlobal::locale()->country() + QString( "/entry.desktop" ) ) );
+ entry.setGroup( "KCM Locale" );
+ QString cpos = entry.readEntry( "AddressCountryPosition" );
+ if ( "BELOW" == cpos || cpos.isEmpty() ) {
+ ret = ret + "\n\n" + country().upper();
+ } else if ( "below" == cpos ) {
+ ret = ret + "\n\n" + country();
+ } else if ( "ABOVE" == cpos ) {
+ ret = country().upper() + "\n\n" + ret;
+ } else if ( "above" == cpos ) {
+ ret = country() + "\n\n" + ret;
+ }
+ }
+
+ return ret;
+}
+
+bool Address::parseAddressTemplateSection( const QString &tsection,
+ QString &result, const QString &realName, const QString &orgaName ) const
+{
+ // This method first parses and substitutes any bracketed sections and
+ // after that replaces any tags with their values. If a bracketed section
+ // or a tag evaluate to zero, they are not just removed but replaced
+ // with a placeholder. This is because in the last step conditionals are
+ // resolved which depend on information about zero-evaluations.
+ result = tsection;
+ int stpos = 0;
+ bool ret = false;
+
+ // first check for brackets that have to be evaluated first
+ int fpos = result.find( KABC_FMTTAG_purgeempty, stpos );
+ while ( -1 != fpos ) {
+ int bpos1 = fpos + KABC_FMTTAG_purgeempty.length();
+ int bpos2;
+ // expect opening bracket and find next balanced closing bracket. If
+ // next char is no opening bracket, continue parsing (no valid tag)
+ if ( '(' == result[bpos1] ) {
+ bpos2 = findBalancedBracket( result, bpos1 );
+ if ( -1 != bpos2 ) {
+ // we have balanced brackets, recursively parse:
+ QString rplstr;
+ bool purge = !parseAddressTemplateSection( result.mid( bpos1+1,
+ bpos2-bpos1-1 ), rplstr,
+ realName, orgaName );
+ if ( purge ) {
+ // purge -> remove all
+ // replace with !_P_!, so conditional tags work later
+ result.replace( fpos, bpos2 - fpos + 1, "!_P_!" );
+ // leave stpos as it is
+ } else {
+ // no purge -> replace with recursively parsed string
+ result.replace( fpos, bpos2 - fpos + 1, rplstr );
+ ret = true;
+ stpos = fpos + rplstr.length();
+ }
+ } else {
+ // unbalanced brackets: keep on parsing (should not happen
+ // and will result in bad formatting)
+ stpos = bpos1;
+ }
+ }
+ fpos = result.find( KABC_FMTTAG_purgeempty, stpos );
+ }
+
+ // after sorting out all purge tags, we just search'n'replace the rest,
+ // keeping track of whether at least one tag evaluates to something.
+ // The following macro needs QString for R_FIELD
+ // It substitutes !_P_! for empty fields so conditional tags work later
+#define REPLTAG(R_TAG,R_FIELD) \
+ if ( result.contains(R_TAG, false) ) { \
+ QString rpl = R_FIELD.isEmpty() ? QString("!_P_!") : R_FIELD; \
+ result.replace( R_TAG, rpl ); \
+ if ( !R_FIELD.isEmpty() ) { \
+ ret = true; \
+ } \
+ }
+ REPLTAG( KABC_FMTTAG_realname, realName );
+ REPLTAG( KABC_FMTTAG_REALNAME, realName.upper() );
+ REPLTAG( KABC_FMTTAG_company, orgaName );
+ REPLTAG( KABC_FMTTAG_COMPANY, orgaName.upper() );
+ REPLTAG( KABC_FMTTAG_pobox, postOfficeBox() );
+ REPLTAG( KABC_FMTTAG_street, street() );
+ REPLTAG( KABC_FMTTAG_STREET, street().upper() );
+ REPLTAG( KABC_FMTTAG_zipcode, postalCode() );
+ REPLTAG( KABC_FMTTAG_location, locality() );
+ REPLTAG( KABC_FMTTAG_LOCATION, locality().upper() );
+ REPLTAG( KABC_FMTTAG_region, region() );
+ REPLTAG( KABC_FMTTAG_REGION, region().upper() );
+ result.replace( KABC_FMTTAG_newline, "\n" );
+#undef REPLTAG
+
+ // conditional comma
+ fpos = result.find( KABC_FMTTAG_condcomma, 0 );
+ while ( -1 != fpos ) {
+ QString str1 = result.mid( fpos - 5, 5 );
+ QString str2 = result.mid( fpos + 2, 5 );
+ if ( str1 != "!_P_!" && str2 != "!_P_!" ) {
+ result.replace( fpos, 2, ", " );
+ } else {
+ result.remove( fpos, 2 );
+ }
+ fpos = result.find( KABC_FMTTAG_condcomma, fpos );
+ }
+ // conditional whitespace
+ fpos = result.find( KABC_FMTTAG_condwhite, 0 );
+ while ( -1 != fpos ) {
+ QString str1 = result.mid( fpos - 5, 5 );
+ QString str2 = result.mid( fpos + 2, 5 );
+ if ( str1 != "!_P_!" && str2 != "!_P_!" ) {
+ result.replace( fpos, 2, " " );
+ } else {
+ result.remove( fpos, 2 );
+ }
+ fpos = result.find( KABC_FMTTAG_condwhite, fpos );
+ }
+
+ // remove purged:
+//US my QT version does not support remove. So lets do it the old fashioned way.
+//US result.remove( "!_P_!" );
+ int n = result.find("!_P_!");
+ if (n >= 0)
+ result.remove( n, 5 );
+
+ return ret;
+}
+
+int Address::findBalancedBracket( const QString &tsection, int pos ) const
+{
+ int balancecounter = 0;
+ for( unsigned int i = pos + 1; i < tsection.length(); i++ ) {
+ if ( ')' == tsection.at(i) && 0 == balancecounter ) {
+ // found end of brackets
+ return i;
+ } else
+ if ( '(' == tsection.at(i) ) {
+ // nested brackets
+ balancecounter++;
+ }
+ }
+ return -1;
+}
+
+QString Address::countryToISO( const QString &cname )
+{
+ // we search a map file for translations from country names to
+ // iso codes, storing caching things in a QMap for faster future
+ // access.
+/*US
+
+ QString isoCode = mISOMap[ cname ];
+ if ( !isoCode.isEmpty() )
+ return isoCode;
+
+ QString mapfile = KGlobal::dirs()->findResource( "data",
+ QString::fromLatin1( "kabc/countrytransl.map" ) );
+
+ QFile file( mapfile );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream s( &file );
+ QString strbuf = s.readLine();
+ while( !strbuf.isNull() ) {
+ if ( strbuf.startsWith( cname ) ) {
+ int index = strbuf.findRev('\t');
+ strbuf = strbuf.mid(index+1, 2);
+ file.close();
+ mISOMap[ cname ] = strbuf;
+ return strbuf;
+ }
+ strbuf = s.readLine();
+ }
+ file.close();
+ }
+*/
+ // fall back to system country
+ mISOMap[ cname ] = KGlobal::locale()->country();
+ return KGlobal::locale()->country();
+}
+
+QString Address::ISOtoCountry( const QString &ISOname )
+{
+/*US
+ // get country name from ISO country code (e.g. "no" -> i18n("Norway"))
+ QString mapfile = KGlobal::dirs()->findResource( "data",
+ QString::fromLatin1( "kabc/countrytransl.map" ) );
+
+kdWarning() << "MAPFILE : " << mapfile << endl;
+ QFile file( mapfile );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream s( &file );
+ QString searchStr = "\t" + ISOname.simplifyWhiteSpace().lower();
+kdWarning() << "Suche : " << searchStr << endl;
+ QString strbuf = s.readLine();
+ int pos;
+ while( !strbuf.isNull() ) {
+ if ( (pos=strbuf.find( searchStr )) != -1 ) {
+ file.close();
+ return i18n(strbuf.left(pos).utf8());
+ }
+ strbuf = s.readLine();
+ }
+ file.close();
+ }
+*/
+ return ISOname;
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Address &addr )
+{
+ return s << addr.mId << addr.mType << addr.mPostOfficeBox <<
+ addr.mExtended << addr.mStreet << addr.mLocality <<
+ addr.mRegion << addr.mPostalCode << addr.mCountry <<
+ addr.mLabel;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Address &addr )
+{
+ s >> addr.mId >> addr.mType >> addr.mPostOfficeBox >> addr.mExtended >>
+ addr.mStreet >> addr.mLocality >> addr.mRegion >>
+ addr.mPostalCode >> addr.mCountry >> addr.mLabel;
+
+ addr.mEmpty = false;
+
+ return s;
+}
diff --git a/kabc/address.h b/kabc/address.h
new file mode 100644
index 0000000..ad132a7
--- a/dev/null
+++ b/kabc/address.h
@@ -0,0 +1,346 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_ADDRESS_H
+#define KABC_ADDRESS_H
+
+#include <qmap.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+
+// template tags for address formatting localization
+#define KABC_FMTTAG_realname QString("%n")
+#define KABC_FMTTAG_REALNAME QString("%N")
+#define KABC_FMTTAG_company QString("%cm")
+#define KABC_FMTTAG_COMPANY QString("%CM")
+#define KABC_FMTTAG_pobox QString("%p")
+#define KABC_FMTTAG_street QString("%s")
+#define KABC_FMTTAG_STREET QString("%S")
+#define KABC_FMTTAG_zipcode QString("%z")
+#define KABC_FMTTAG_location QString("%l")
+#define KABC_FMTTAG_LOCATION QString("%L")
+#define KABC_FMTTAG_region QString("%r")
+#define KABC_FMTTAG_REGION QString("%R")
+#define KABC_FMTTAG_newline QString("\\n")
+#define KABC_FMTTAG_condcomma QString("%,")
+#define KABC_FMTTAG_condwhite QString("%w")
+#define KABC_FMTTAG_purgeempty QString("%0")
+
+namespace KABC {
+
+/**
+ @short Postal address information.
+
+ This class represents information about a postal address.
+*/
+class Address
+{
+ friend QDataStream &operator<<( QDataStream &, const Address & );
+ friend QDataStream &operator>>( QDataStream &, Address & );
+
+ public:
+ /**
+ List of addresses.
+ */
+ typedef QValueList<Address> List;
+ typedef QValueList<int> TypeList;
+
+ /**
+ Address types:
+
+ @li @p Dom - domestic
+ @li @p Intl - international
+ @li @p Postal - postal
+ @li @p Parcel - parcel
+ @li @p Home - home address
+ @li @p Work - address at work
+ @li @p Pref - preferred address
+ */
+ enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
+ Pref = 64 };
+
+ /**
+ Constructor that creates an empty Address, which is initialized
+ with a unique id (see @ref id()).
+ */
+ Address();
+
+ /**
+ This is like @ref Address() just above, with the difference
+ that you can specify the type.
+ */
+ Address( int );
+
+ bool operator==( const Address & ) const;
+ bool operator!=( const Address & ) const;
+
+ /**
+ Returns true, if the address is empty.
+ */
+ bool isEmpty() const;
+
+ /**
+ Clears all entries of the address.
+ */
+ void clear();
+
+ /**
+ Sets the unique id.
+ */
+ void setId( const QString & );
+
+ /*
+ Returns the unique id.
+ */
+ QString id() const;
+
+ /**
+ Sets the type of address. See enum for definiton of types.
+
+ @param type type, can be a bitwise or of multiple types.
+ */
+ void setType( int type );
+
+ /**
+ Returns the type of address. Can be a bitwise or of multiple types.
+ */
+ int type() const;
+
+ /**
+ Returns a translated string of all types the address has.
+ */
+ QString typeLabel() const;
+
+ /**
+ Sets the post office box.
+ */
+ void setPostOfficeBox( const QString & );
+
+ /**
+ Returns the post office box.
+ */
+ QString postOfficeBox() const;
+
+ /**
+ Returns the translated label for post office box field.
+ */
+ static QString postOfficeBoxLabel();
+
+ /**
+ Sets the extended address information.
+ */
+ void setExtended( const QString & );
+
+ /**
+ Returns the extended address information.
+ */
+ QString extended() const;
+
+ /**
+ Returns the translated label for extended field.
+ */
+ static QString extendedLabel();
+
+ /**
+ Sets the street (including number).
+ */
+ void setStreet( const QString & );
+
+ /**
+ Returns the street.
+ */
+ QString street() const;
+
+ /**
+ Returns the translated label for street field.
+ */
+ static QString streetLabel();
+
+ /**
+ Sets the locality, e.g. city.
+ */
+ void setLocality( const QString & );
+
+ /**
+ Returns the locality.
+ */
+ QString locality() const;
+
+ /**
+ Returns the translated label for locality field.
+ */
+ static QString localityLabel();
+
+ /**
+ Sets the region, e.g. state.
+ */
+ void setRegion( const QString & );
+
+ /**
+ Returns the region.
+ */
+ QString region() const;
+
+ /**
+ Returns the translated label for region field.
+ */
+ static QString regionLabel();
+
+ /**
+ Sets the postal code.
+ */
+ void setPostalCode( const QString & );
+
+ /**
+ Returns the postal code.
+ */
+ QString postalCode() const;
+
+ /**
+ Returns the translated label for postal code field.
+ */
+ static QString postalCodeLabel();
+
+ /**
+ Sets the country.
+ */
+ void setCountry( const QString & );
+
+ /**
+ Returns the country.
+ */
+ QString country() const;
+
+ /**
+ Returns the translated label for country field.
+ */
+ static QString countryLabel();
+
+ /**
+ Sets the delivery label. This is the literal text to be used as label.
+ */
+ void setLabel( const QString & );
+
+ /**
+ Returns the delivery label.
+ */
+ QString label() const;
+
+ /**
+ Returns the translated label for delivery label field.
+ */
+ static QString labelLabel();
+
+ /**
+ Returns the list of available types.
+ */
+ static TypeList typeList();
+
+ /**
+ Returns the translated label for a special type.
+ */
+ static QString typeLabel( int type );
+
+ /**
+ Used for debug output.
+ */
+ void dump() const;
+
+ /**
+ Returns this address formatted according to the country-specific
+ address formatting rules. The formatting rules applied depend on
+ either the addresses {@link #country country} field, or (if the
+ latter is empty) on the system country setting. If companyName is
+ provided, an available business address format will be preferred.
+
+ @param realName the formatted name of the contact
+ @param orgaName the name of the organization or company
+ @return the formatted address (containing newline characters)
+ */
+ QString formattedAddress( const QString &realName=QString::null
+ , const QString &orgaName=QString::null ) const;
+
+ /**
+ Returns ISO code for a localized country name. Only localized country
+ names will be understood. This might be replaced by a KLocale method in
+ the future.
+ @param cname name of the country
+ @return two digit ISO code
+ */
+ static QString countryToISO( const QString &cname );
+
+ /**
+ Returns a localized country name for a ISO code.
+ This might be replaced by a KLocale method in the future.
+ @param ISOname two digit ISO code
+ @return localized name of the country
+ @since 3.2
+ */
+ static QString ISOtoCountry( const QString &ISOname );
+
+ private:
+ /**
+ Parses a snippet of an address template
+ @param tsection the template string to be parsed
+ @param result QString reference in which the result will be stored
+ @return true if at least one tag evaluated positively, else false
+ */
+ bool parseAddressTemplateSection( const QString &tsection
+ , QString &result
+ , const QString &realName
+ , const QString &orgaName ) const;
+
+ /**
+ Finds the balanced closing bracket starting from the opening bracket at
+ pos in tsection.
+ @return position of closing bracket, -1 for unbalanced brackets
+ */
+ int findBalancedBracket( const QString &tsection, int pos ) const;
+
+ bool mEmpty;
+
+ QString mId;
+ int mType;
+
+ QString mPostOfficeBox;
+ QString mExtended;
+ QString mStreet;
+ QString mLocality;
+ QString mRegion;
+ QString mPostalCode;
+ QString mCountry;
+ QString mLabel;
+
+ static QMap<QString, QString> mISOMap;
+};
+
+QDataStream &operator<<( QDataStream &, const Address & );
+QDataStream &operator>>( QDataStream &, Address & );
+
+}
+
+#endif
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
new file mode 100644
index 0000000..203efc2
--- a/dev/null
+++ b/kabc/addressbook.cpp
@@ -0,0 +1,655 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KAB_EMBEDDED
+
+#include <qfile.h>
+#include <qregexp.h>
+#include <qtimer.h>
+
+#include <kapplication.h>
+#include <kinstance.h>
+#include <kstandarddirs.h>
+
+#include "errorhandler.h"
+
+#else //KAB_EMBEDDED
+#include <qptrlist.h>
+#endif //KAB_EMBEDDED
+
+#include <kglobal.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include "addressbook.h"
+#include "resource.h"
+
+#ifndef KAB_EMBEDDED
+#include "addressbook.moc"
+#endif //KAB_EMBEDDED
+
+using namespace KABC;
+
+struct AddressBook::AddressBookData
+{
+ Addressee::List mAddressees;
+ Addressee::List mRemovedAddressees;
+ Field::List mAllFields;
+ KConfig *mConfig;
+ KRES::Manager<Resource> *mManager;
+#ifndef KAB_EMBEDDED
+ ErrorHandler *mErrorHandler;
+#endif //KAB_EMBEDDED
+};
+
+struct AddressBook::Iterator::IteratorData
+{
+ Addressee::List::Iterator mIt;
+};
+
+struct AddressBook::ConstIterator::ConstIteratorData
+{
+ Addressee::List::ConstIterator mIt;
+};
+
+AddressBook::Iterator::Iterator()
+{
+ d = new IteratorData;
+}
+
+AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
+{
+ d = new IteratorData;
+ d->mIt = i.d->mIt;
+}
+
+AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
+{
+ if( this == &i ) return *this; // guard against self assignment
+ delete d; // delete the old data the Iterator was completely constructed before
+ d = new IteratorData;
+ d->mIt = i.d->mIt;
+ return *this;
+}
+
+AddressBook::Iterator::~Iterator()
+{
+ delete d;
+}
+
+const Addressee &AddressBook::Iterator::operator*() const
+{
+ return *(d->mIt);
+}
+
+Addressee &AddressBook::Iterator::operator*()
+{
+ return *(d->mIt);
+}
+
+Addressee *AddressBook::Iterator::operator->()
+{
+ return &(*(d->mIt));
+}
+
+AddressBook::Iterator &AddressBook::Iterator::operator++()
+{
+ (d->mIt)++;
+ return *this;
+}
+
+AddressBook::Iterator &AddressBook::Iterator::operator++(int)
+{
+ (d->mIt)++;
+ return *this;
+}
+
+AddressBook::Iterator &AddressBook::Iterator::operator--()
+{
+ (d->mIt)--;
+ return *this;
+}
+
+AddressBook::Iterator &AddressBook::Iterator::operator--(int)
+{
+ (d->mIt)--;
+ return *this;
+}
+
+bool AddressBook::Iterator::operator==( const Iterator &it )
+{
+ return ( d->mIt == it.d->mIt );
+}
+
+bool AddressBook::Iterator::operator!=( const Iterator &it )
+{
+ return ( d->mIt != it.d->mIt );
+}
+
+
+AddressBook::ConstIterator::ConstIterator()
+{
+ d = new ConstIteratorData;
+}
+
+AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
+{
+ d = new ConstIteratorData;
+ d->mIt = i.d->mIt;
+}
+
+AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
+{
+ if( this == &i ) return *this; // guard for self assignment
+ delete d; // delete the old data because the Iterator was really constructed before
+ d = new ConstIteratorData;
+ d->mIt = i.d->mIt;
+ return *this;
+}
+
+AddressBook::ConstIterator::~ConstIterator()
+{
+ delete d;
+}
+
+const Addressee &AddressBook::ConstIterator::operator*() const
+{
+ return *(d->mIt);
+}
+
+const Addressee* AddressBook::ConstIterator::operator->() const
+{
+ return &(*(d->mIt));
+}
+
+AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
+{
+ (d->mIt)++;
+ return *this;
+}
+
+AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
+{
+ (d->mIt)++;
+ return *this;
+}
+
+AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
+{
+ (d->mIt)--;
+ return *this;
+}
+
+AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
+{
+ (d->mIt)--;
+ return *this;
+}
+
+bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
+{
+ return ( d->mIt == it.d->mIt );
+}
+
+bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
+{
+ return ( d->mIt != it.d->mIt );
+}
+
+
+AddressBook::AddressBook()
+{
+ init(0);
+}
+
+AddressBook::AddressBook( const QString &config )
+{
+ init(config);
+}
+
+void AddressBook::init(const QString &config)
+{
+ d = new AddressBookData;
+ if (config != 0) {
+ d->mConfig = new KConfig( config );
+// qDebug("AddressBook::init 1 config=%s",config.latin1() );
+ }
+ else {
+ d->mConfig = 0;
+// qDebug("AddressBook::init 1 config=0");
+ }
+
+#ifndef KAB_EMBEDDED
+ d->mErrorHandler = 0;
+#endif //KAB_EMBEDDED
+ d->mManager = new KRES::Manager<Resource>( "contact" );
+ d->mManager->readConfig( d->mConfig );
+}
+
+AddressBook::~AddressBook()
+{
+ delete d->mConfig; d->mConfig = 0;
+ delete d->mManager; d->mManager = 0;
+#ifndef KAB_EMBEDDED
+ delete d->mErrorHandler; d->mErrorHandler = 0;
+#endif //KAB_EMBEDDED
+ delete d; d = 0;
+}
+
+bool AddressBook::load()
+{
+ kdDebug(5700) << "AddressBook::load()" << endl;
+
+ clear();
+
+ KRES::Manager<Resource>::ActiveIterator it;
+ bool ok = true;
+ for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
+ if ( !(*it)->load() ) {
+ error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
+ ok = false;
+ }
+
+ // mark all addressees as unchanged
+ Addressee::List::Iterator addrIt;
+ for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt )
+ (*addrIt).setChanged( false );
+
+ return ok;
+}
+
+bool AddressBook::save( Ticket *ticket )
+{
+ kdDebug(5700) << "AddressBook::save()"<< endl;
+
+ if ( ticket->resource() ) {
+ deleteRemovedAddressees();
+
+ return ticket->resource()->save( ticket );
+ }
+
+ return false;
+}
+
+AddressBook::Iterator AddressBook::begin()
+{
+ Iterator it = Iterator();
+ it.d->mIt = d->mAddressees.begin();
+ return it;
+}
+
+AddressBook::ConstIterator AddressBook::begin() const
+{
+ ConstIterator it = ConstIterator();
+ it.d->mIt = d->mAddressees.begin();
+ return it;
+}
+
+AddressBook::Iterator AddressBook::end()
+{
+ Iterator it = Iterator();
+ it.d->mIt = d->mAddressees.end();
+ return it;
+}
+
+AddressBook::ConstIterator AddressBook::end() const
+{
+ ConstIterator it = ConstIterator();
+ it.d->mIt = d->mAddressees.end();
+ return it;
+}
+
+void AddressBook::clear()
+{
+ d->mAddressees.clear();
+}
+
+Ticket *AddressBook::requestSaveTicket( Resource *resource )
+{
+ kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
+
+ if ( !resource )
+ {
+ qDebug("AddressBook::requestSaveTicket no resource" );
+ resource = standardResource();
+ }
+
+ KRES::Manager<Resource>::ActiveIterator it;
+ for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
+ if ( (*it) == resource ) {
+ if ( (*it)->readOnly() || !(*it)->isOpen() )
+ return 0;
+ else
+ return (*it)->requestSaveTicket();
+ }
+ }
+
+ return 0;
+}
+
+void AddressBook::insertAddressee( const Addressee &a )
+{
+ Addressee::List::Iterator it;
+ for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
+ if ( a.uid() == (*it).uid() ) {
+ bool changed = false;
+ Addressee addr = a;
+ if ( addr != (*it) )
+ changed = true;
+
+ (*it) = a;
+ if ( (*it).resource() == 0 )
+ (*it).setResource( standardResource() );
+
+ if ( changed ) {
+ (*it).setRevision( QDateTime::currentDateTime() );
+ (*it).setChanged( true );
+ }
+
+ return;
+ }
+ }
+ d->mAddressees.append( a );
+ Addressee& addr = d->mAddressees.last();
+ if ( addr.resource() == 0 )
+ addr.setResource( standardResource() );
+
+ addr.setChanged( true );
+}
+
+void AddressBook::removeAddressee( const Addressee &a )
+{
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( a.uid() == (*it).uid() ) {
+ removeAddressee( it );
+ return;
+ }
+ }
+}
+
+void AddressBook::removeAddressee( const Iterator &it )
+{
+ d->mRemovedAddressees.append( (*it) );
+ d->mAddressees.remove( it.d->mIt );
+}
+
+AddressBook::Iterator AddressBook::find( const Addressee &a )
+{
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( a.uid() == (*it).uid() ) {
+ return it;
+ }
+ }
+ return end();
+}
+
+Addressee AddressBook::findByUid( const QString &uid )
+{
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( uid == (*it).uid() ) {
+ return *it;
+ }
+ }
+ return Addressee();
+}
+
+Addressee::List AddressBook::allAddressees()
+{
+ return d->mAddressees;
+}
+
+Addressee::List AddressBook::findByName( const QString &name )
+{
+ Addressee::List results;
+
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( name == (*it).name() ) {
+ results.append( *it );
+ }
+ }
+
+ return results;
+}
+
+Addressee::List AddressBook::findByEmail( const QString &email )
+{
+ Addressee::List results;
+ QStringList mailList;
+
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ mailList = (*it).emails();
+ for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
+ if ( email == (*ite) ) {
+ results.append( *it );
+ }
+ }
+ }
+
+ return results;
+}
+
+Addressee::List AddressBook::findByCategory( const QString &category )
+{
+ Addressee::List results;
+
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( (*it).hasCategory( category) ) {
+ results.append( *it );
+ }
+ }
+
+ return results;
+}
+
+void AddressBook::dump() const
+{
+ kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
+
+ ConstIterator it;
+ for( it = begin(); it != end(); ++it ) {
+ (*it).dump();
+ }
+
+ kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
+}
+
+QString AddressBook::identifier()
+{
+ QStringList identifier;
+
+
+ KRES::Manager<Resource>::ActiveIterator it;
+ for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
+ if ( !(*it)->identifier().isEmpty() )
+ identifier.append( (*it)->identifier() );
+ }
+
+ return identifier.join( ":" );
+}
+
+Field::List AddressBook::fields( int category )
+{
+ if ( d->mAllFields.isEmpty() ) {
+ d->mAllFields = Field::allFields();
+ }
+
+ if ( category == Field::All ) return d->mAllFields;
+
+ Field::List result;
+ Field::List::ConstIterator it;
+ for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
+ if ( (*it)->category() & category ) result.append( *it );
+ }
+
+ return result;
+}
+
+bool AddressBook::addCustomField( const QString &label, int category,
+ const QString &key, const QString &app )
+{
+ if ( d->mAllFields.isEmpty() ) {
+ d->mAllFields = Field::allFields();
+ }
+#ifndef KAB_EMBEDDED
+ QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
+#else //KAB_EMBEDDED
+ QString a = app.isNull() ? KGlobal::getAppName() : app;
+#endif //KAB_EMBEDDED
+
+ QString k = key.isNull() ? label : key;
+
+ Field *field = Field::createCustomField( label, category, k, a );
+
+ if ( !field ) return false;
+
+ d->mAllFields.append( field );
+
+ return true;
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
+{
+ if (!ab.d) return s;
+
+ return s << ab.d->mAddressees;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
+{
+ if (!ab.d) return s;
+
+ s >> ab.d->mAddressees;
+
+ return s;
+}
+
+bool AddressBook::addResource( Resource *resource )
+{
+ qDebug("AddressBook::addResource 1");
+
+ if ( !resource->open() ) {
+ kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
+ return false;
+ }
+
+ resource->setAddressBook( this );
+
+ d->mManager->add( resource );
+ return true;
+}
+
+bool AddressBook::removeResource( Resource *resource )
+{
+ resource->close();
+
+ if ( resource == standardResource() )
+ d->mManager->setStandardResource( 0 );
+
+ resource->setAddressBook( 0 );
+
+ d->mManager->remove( resource );
+ return true;
+}
+
+QPtrList<Resource> AddressBook::resources()
+{
+ QPtrList<Resource> list;
+
+// qDebug("AddressBook::resources() 1");
+
+ KRES::Manager<Resource>::ActiveIterator it;
+ for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
+ list.append( *it );
+
+ return list;
+}
+
+#ifndef KAB_EMBEDDED
+void AddressBook::setErrorHandler( ErrorHandler *handler )
+{
+ delete d->mErrorHandler;
+ d->mErrorHandler = handler;
+}
+#endif //KAB_EMBEDDED
+
+void AddressBook::error( const QString& msg )
+{
+#ifndef KAB_EMBEDDED
+ if ( !d->mErrorHandler ) // create default error handler
+ d->mErrorHandler = new ConsoleErrorHandler;
+
+ if ( d->mErrorHandler )
+ d->mErrorHandler->error( msg );
+ else
+ kdError(5700) << "no error handler defined" << endl;
+#else //KAB_EMBEDDED
+ kdDebug(5700) << "msg" << endl;
+ qDebug(msg);
+#endif //KAB_EMBEDDED
+}
+
+void AddressBook::deleteRemovedAddressees()
+{
+ Addressee::List::Iterator it;
+ for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
+ Resource *resource = (*it).resource();
+ if ( resource && !resource->readOnly() && resource->isOpen() )
+ resource->removeAddressee( *it );
+ }
+
+ d->mRemovedAddressees.clear();
+}
+
+void AddressBook::setStandardResource( Resource *resource )
+{
+// qDebug("AddressBook::setStandardResource 1");
+ d->mManager->setStandardResource( resource );
+}
+
+Resource *AddressBook::standardResource()
+{
+ return d->mManager->standardResource();
+}
+
+KRES::Manager<Resource> *AddressBook::resourceManager()
+{
+ return d->mManager;
+}
+
+void AddressBook::cleanUp()
+{
+ KRES::Manager<Resource>::ActiveIterator it;
+ for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
+ if ( !(*it)->readOnly() && (*it)->isOpen() )
+ (*it)->cleanUp();
+ }
+}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
new file mode 100644
index 0000000..3383fc0
--- a/dev/null
+++ b/kabc/addressbook.h
@@ -0,0 +1,337 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_ADDRESSBOOK_H
+#define KABC_ADDRESSBOOK_H
+
+#include <qobject.h>
+
+#include <kresources/manager.h>
+#include <qptrlist.h>
+
+#ifndef KAB_EMBEDDED
+
+#else //KAB_EMBEDDED
+#endif //KAB_EMBEDDED
+
+
+#include "addressee.h"
+#include "field.h"
+
+namespace KABC {
+
+class ErrorHandler;
+class Resource;
+class Ticket;
+
+/**
+ @short Address Book
+
+ This class provides access to a collection of address book entries.
+*/
+class AddressBook : public QObject
+{
+ Q_OBJECT
+
+ friend QDataStream &operator<<( QDataStream &, const AddressBook & );
+ friend QDataStream &operator>>( QDataStream &, AddressBook & );
+ friend class StdAddressBook;
+
+ public:
+ /**
+ @short Address Book Iterator
+
+ This class provides an iterator for address book entries.
+ */
+ class Iterator
+ {
+ public:
+ Iterator();
+ Iterator( const Iterator & );
+ ~Iterator();
+
+ Iterator &operator=( const Iterator & );
+ const Addressee &operator*() const;
+ Addressee &operator*();
+ Addressee* operator->();
+ Iterator &operator++();
+ Iterator &operator++(int);
+ Iterator &operator--();
+ Iterator &operator--(int);
+ bool operator==( const Iterator &it );
+ bool operator!=( const Iterator &it );
+
+ struct IteratorData;
+ IteratorData *d;
+ };
+
+ /**
+ @short Address Book Const Iterator
+
+ This class provides a const iterator for address book entries.
+ */
+ class ConstIterator
+ {
+ public:
+ ConstIterator();
+ ConstIterator( const ConstIterator & );
+ ~ConstIterator();
+
+ ConstIterator &operator=( const ConstIterator & );
+ const Addressee &operator*() const;
+ const Addressee* operator->() const;
+ ConstIterator &operator++();
+ ConstIterator &operator++(int);
+ ConstIterator &operator--();
+ ConstIterator &operator--(int);
+ bool operator==( const ConstIterator &it );
+ bool operator!=( const ConstIterator &it );
+
+ struct ConstIteratorData;
+ ConstIteratorData *d;
+ };
+
+ /**
+ Constructs a address book object.
+
+ @param format File format class.
+ */
+ AddressBook();
+ AddressBook( const QString &config );
+ virtual ~AddressBook();
+
+ /**
+ Requests a ticket for saving the addressbook. Calling this function locks
+ the addressbook for all other processes. If the address book is already
+ locked the function returns 0. You need the returned @ref Ticket object
+ for calling the @ref save() function.
+
+ @see save()
+ */
+ Ticket *requestSaveTicket( Resource *resource=0 );
+
+ /**
+ Load address book from file.
+ */
+ bool load();
+
+ /**
+ Save address book. The address book is saved to the file, the Ticket
+ object has been requested for by @ref requestSaveTicket().
+
+ @param ticket a ticket object returned by @ref requestSaveTicket()
+ */
+ bool save( Ticket *ticket );
+
+ /**
+ Returns a iterator for first entry of address book.
+ */
+ Iterator begin();
+
+ /**
+ Returns a const iterator for first entry of address book.
+ */
+ ConstIterator begin() const;
+
+ /**
+ Returns a iterator for first entry of address book.
+ */
+ Iterator end();
+
+ /**
+ Returns a const iterator for first entry of address book.
+ */
+ ConstIterator end() const;
+
+ /**
+ Removes all entries from address book.
+ */
+ void clear();
+
+ /**
+ Insert an Addressee object into address book. If an object with the same
+ unique id already exists in the address book it it replaced by the new
+ one. If not the new object is appended to the address book.
+ */
+ void insertAddressee( const Addressee & );
+
+ /**
+ Removes entry from the address book.
+ */
+ void removeAddressee( const Addressee & );
+
+ /**
+ This is like @ref removeAddressee() just above, with the difference that
+ the first element is a iterator, returned by @ref begin().
+ */
+ void removeAddressee( const Iterator & );
+
+ /**
+ Find the specified entry in address book. Returns end(), if the entry
+ couldn't be found.
+ */
+ Iterator find( const Addressee & );
+
+ /**
+ Find the entry specified by an unique id. Returns an empty Addressee
+ object, if the address book does not contain an entry with this id.
+ */
+ Addressee findByUid( const QString & );
+
+
+ /**
+ Returns a list of all addressees in the address book. This list can
+ be sorted with @ref KABC::AddresseeList for example.
+ */
+ Addressee::List allAddressees();
+
+ /**
+ Find all entries with the specified name in the address book. Returns
+ an empty list, if no entries could be found.
+ */
+ Addressee::List findByName( const QString & );
+
+ /**
+ Find all entries with the specified email address in the address book.
+ Returns an empty list, if no entries could be found.
+ */
+ Addressee::List findByEmail( const QString & );
+
+ /**
+ Find all entries wich have the specified category in the address book.
+ Returns an empty list, if no entries could be found.
+ */
+ Addressee::List findByCategory( const QString & );
+
+ /**
+ Return a string identifying this addressbook.
+ */
+ virtual QString identifier();
+
+ /**
+ Used for debug output.
+ */
+ void dump() const;
+
+ void emitAddressBookLocked() { emit addressBookLocked( this ); }
+ void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
+ void emitAddressBookChanged() { emit addressBookChanged( this ); }
+
+ /**
+ Return list of all Fields known to the address book which are associated
+ with the given field category.
+ */
+ Field::List fields( int category = Field::All );
+
+ /**
+ Add custom field to address book.
+
+ @param label User visible label of the field.
+ @param category Ored list of field categories.
+ @param key Identifier used as key for reading and writing the field.
+ @param app String used as application key for reading and writing
+ the field.
+ */
+ bool addCustomField( const QString &label, int category = Field::All,
+ const QString &key = QString::null,
+ const QString &app = QString::null );
+
+
+ /**
+ Add address book resource.
+ */
+ bool addResource( Resource * );
+
+ /**
+ Remove address book resource.
+ */
+ bool removeResource( Resource * );
+
+ /**
+ Return pointer list of all resources.
+ */
+ QPtrList<Resource> resources();
+
+ /**
+ Set the @p ErrorHandler, that is used by @ref error() to
+ provide gui-independend error messages.
+ */
+ void setErrorHandler( ErrorHandler * );
+
+ /**
+ Shows gui independend error messages.
+ */
+ void error( const QString& );
+
+ /**
+ Query all resources to clean up their lock files
+ */
+ void cleanUp();
+
+ signals:
+ /**
+ Emitted, when the address book has changed on disk.
+ */
+ void addressBookChanged( AddressBook * );
+
+ /**
+ Emitted, when the address book has been locked for writing.
+ */
+ void addressBookLocked( AddressBook * );
+
+ /**
+ Emitted, when the address book has been unlocked.
+ */
+ void addressBookUnlocked( AddressBook * );
+
+ protected:
+ void deleteRemovedAddressees();
+ void setStandardResource( Resource * );
+ Resource *standardResource();
+ KRES::Manager<Resource> *resourceManager();
+
+ private:
+#ifndef KAB_EMBEDDED
+ QPtrList<Resource> mDummy; // Remove in KDE 4
+#endif //KAB_EMBEDDED
+
+#ifdef KAB_EMBEDDED
+//US optimization
+ void init(const QString &config);
+#endif //KAB_EMBEDDED
+
+
+ struct AddressBookData;
+ AddressBookData *d;
+};
+
+QDataStream &operator<<( QDataStream &, const AddressBook & );
+QDataStream &operator>>( QDataStream &, AddressBook & );
+
+}
+
+#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
new file mode 100644
index 0000000..5cb194a
--- a/dev/null
+++ b/kabc/addressee.cpp
@@ -0,0 +1,1616 @@
+/*** Warning! This file has been generated by the script makeaddressee ***/
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <kconfig.h>
+
+#include <ksharedptr.h>
+#include <kdebug.h>
+#include <kapplication.h>
+#include <klocale.h>
+//US
+#include <kstandarddirs.h>
+
+//US #include "resource.h"
+#include "addressee.h"
+
+using namespace KABC;
+
+static bool matchBinaryPattern( int value, int pattern );
+
+struct Addressee::AddresseeData : public KShared
+{
+ QString uid;
+ QString name;
+ QString formattedName;
+ QString familyName;
+ QString givenName;
+ QString additionalName;
+ QString prefix;
+ QString suffix;
+ QString nickName;
+ QDateTime birthday;
+ QString mailer;
+ TimeZone timeZone;
+ Geo geo;
+ QString title;
+ QString role;
+ QString organization;
+ QString note;
+ QString productId;
+ QDateTime revision;
+ QString sortString;
+ KURL url;
+ Secrecy secrecy;
+ Picture logo;
+ Picture photo;
+ Sound sound;
+ Agent agent;
+
+ PhoneNumber::List phoneNumbers;
+ Address::List addresses;
+ Key::List keys;
+ QStringList emails;
+ QStringList categories;
+ QStringList custom;
+
+ Resource *resource;
+
+ bool empty :1;
+ bool changed :1;
+};
+
+Addressee::Addressee()
+{
+ mData = new AddresseeData;
+ mData->empty = true;
+ mData->changed = false;
+ mData->resource = 0;
+}
+
+Addressee::~Addressee()
+{
+}
+
+Addressee::Addressee( const Addressee &a )
+{
+ mData = a.mData;
+}
+
+Addressee &Addressee::operator=( const Addressee &a )
+{
+ mData = a.mData;
+ return (*this);
+}
+
+Addressee Addressee::copy()
+{
+ Addressee a;
+ *(a.mData) = *mData;
+ return a;
+}
+
+void Addressee::detach()
+{
+ if ( mData.count() == 1 ) return;
+ *this = copy();
+}
+
+bool Addressee::operator==( const Addressee &a ) const
+{
+ if ( uid() != a.uid() ) return false;
+ if ( mData->name != a.mData->name ) return false;
+ if ( mData->formattedName != a.mData->formattedName ) return false;
+ if ( mData->familyName != a.mData->familyName ) return false;
+ if ( mData->givenName != a.mData->givenName ) return false;
+ if ( mData->additionalName != a.mData->additionalName ) return false;
+ if ( mData->prefix != a.mData->prefix ) return false;
+ if ( mData->suffix != a.mData->suffix ) return false;
+ if ( mData->nickName != a.mData->nickName ) return false;
+ if ( mData->birthday != a.mData->birthday ) return false;
+ if ( mData->mailer != a.mData->mailer ) return false;
+ if ( mData->timeZone != a.mData->timeZone ) return false;
+ if ( mData->geo != a.mData->geo ) return false;
+ if ( mData->title != a.mData->title ) return false;
+ if ( mData->role != a.mData->role ) return false;
+ if ( mData->organization != a.mData->organization ) return false;
+ if ( mData->note != a.mData->note ) return false;
+ if ( mData->productId != a.mData->productId ) return false;
+ if ( mData->revision != a.mData->revision ) return false;
+ if ( mData->sortString != a.mData->sortString ) return false;
+ if ( mData->secrecy != a.mData->secrecy ) return false;
+ if ( mData->logo != a.mData->logo ) return false;
+ if ( mData->photo != a.mData->photo ) return false;
+ if ( mData->sound != a.mData->sound ) return false;
+ if ( mData->agent != a.mData->agent ) return false;
+ if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
+ ( mData->url != a.mData->url ) ) return false;
+ if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
+ if ( mData->addresses != a.mData->addresses ) return false;
+ if ( mData->keys != a.mData->keys ) return false;
+ if ( mData->emails != a.mData->emails ) return false;
+ if ( mData->categories != a.mData->categories ) return false;
+ if ( mData->custom != a.mData->custom ) return false;
+
+ return true;
+}
+
+bool Addressee::operator!=( const Addressee &a ) const
+{
+ return !( a == *this );
+}
+
+bool Addressee::isEmpty() const
+{
+ return mData->empty;
+}
+
+void Addressee::setUid( const QString &id )
+{
+ if ( id == mData->uid ) return;
+ detach();
+ mData->empty = false;
+ mData->uid = id;
+}
+
+QString Addressee::uid() const
+{
+ if ( mData->uid.isEmpty() )
+ mData->uid = KApplication::randomString( 10 );
+
+ return mData->uid;
+}
+
+QString Addressee::uidLabel()
+{
+ return i18n("Unique Identifier");
+}
+
+void Addressee::setName( const QString &name )
+{
+ if ( name == mData->name ) return;
+ detach();
+ mData->empty = false;
+ mData->name = name;
+}
+
+QString Addressee::name() const
+{
+ return mData->name;
+}
+
+QString Addressee::nameLabel()
+{
+ return i18n("Name");
+}
+
+
+void Addressee::setFormattedName( const QString &formattedName )
+{
+ if ( formattedName == mData->formattedName ) return;
+ detach();
+ mData->empty = false;
+ mData->formattedName = formattedName;
+}
+
+QString Addressee::formattedName() const
+{
+ return mData->formattedName;
+}
+
+QString Addressee::formattedNameLabel()
+{
+ return i18n("Formatted Name");
+}
+
+
+void Addressee::setFamilyName( const QString &familyName )
+{
+ if ( familyName == mData->familyName ) return;
+ detach();
+ mData->empty = false;
+ mData->familyName = familyName;
+}
+
+QString Addressee::familyName() const
+{
+ return mData->familyName;
+}
+
+QString Addressee::familyNameLabel()
+{
+ return i18n("Family Name");
+}
+
+
+void Addressee::setGivenName( const QString &givenName )
+{
+ if ( givenName == mData->givenName ) return;
+ detach();
+ mData->empty = false;
+ mData->givenName = givenName;
+}
+
+QString Addressee::givenName() const
+{
+ return mData->givenName;
+}
+
+QString Addressee::givenNameLabel()
+{
+ return i18n("Given Name");
+}
+
+
+void Addressee::setAdditionalName( const QString &additionalName )
+{
+ if ( additionalName == mData->additionalName ) return;
+ detach();
+ mData->empty = false;
+ mData->additionalName = additionalName;
+}
+
+QString Addressee::additionalName() const
+{
+ return mData->additionalName;
+}
+
+QString Addressee::additionalNameLabel()
+{
+ return i18n("Additional Names");
+}
+
+
+void Addressee::setPrefix( const QString &prefix )
+{
+ if ( prefix == mData->prefix ) return;
+ detach();
+ mData->empty = false;
+ mData->prefix = prefix;
+}
+
+QString Addressee::prefix() const
+{
+ return mData->prefix;
+}
+
+QString Addressee::prefixLabel()
+{
+ return i18n("Honorific Prefixes");
+}
+
+
+void Addressee::setSuffix( const QString &suffix )
+{
+ if ( suffix == mData->suffix ) return;
+ detach();
+ mData->empty = false;
+ mData->suffix = suffix;
+}
+
+QString Addressee::suffix() const
+{
+ return mData->suffix;
+}
+
+QString Addressee::suffixLabel()
+{
+ return i18n("Honorific Suffixes");
+}
+
+
+void Addressee::setNickName( const QString &nickName )
+{
+ if ( nickName == mData->nickName ) return;
+ detach();
+ mData->empty = false;
+ mData->nickName = nickName;
+}
+
+QString Addressee::nickName() const
+{
+ return mData->nickName;
+}
+
+QString Addressee::nickNameLabel()
+{
+ return i18n("Nick Name");
+}
+
+
+void Addressee::setBirthday( const QDateTime &birthday )
+{
+ if ( birthday == mData->birthday ) return;
+ detach();
+ mData->empty = false;
+ mData->birthday = birthday;
+}
+
+QDateTime Addressee::birthday() const
+{
+ return mData->birthday;
+}
+
+QString Addressee::birthdayLabel()
+{
+ return i18n("Birthday");
+}
+
+
+QString Addressee::homeAddressStreetLabel()
+{
+ return i18n("Home Address Street");
+}
+
+
+QString Addressee::homeAddressLocalityLabel()
+{
+ return i18n("Home Address Locality");
+}
+
+
+QString Addressee::homeAddressRegionLabel()
+{
+ return i18n("Home Address Region");
+}
+
+
+QString Addressee::homeAddressPostalCodeLabel()
+{
+ return i18n("Home Address Postal Code");
+}
+
+
+QString Addressee::homeAddressCountryLabel()
+{
+ return i18n("Home Address Country");
+}
+
+
+QString Addressee::homeAddressLabelLabel()
+{
+ return i18n("Home Address Label");
+}
+
+
+QString Addressee::businessAddressStreetLabel()
+{
+ return i18n("Business Address Street");
+}
+
+
+QString Addressee::businessAddressLocalityLabel()
+{
+ return i18n("Business Address Locality");
+}
+
+
+QString Addressee::businessAddressRegionLabel()
+{
+ return i18n("Business Address Region");
+}
+
+
+QString Addressee::businessAddressPostalCodeLabel()
+{
+ return i18n("Business Address Postal Code");
+}
+
+
+QString Addressee::businessAddressCountryLabel()
+{
+ return i18n("Business Address Country");
+}
+
+
+QString Addressee::businessAddressLabelLabel()
+{
+ return i18n("Business Address Label");
+}
+
+
+QString Addressee::homePhoneLabel()
+{
+ return i18n("Home Phone");
+}
+
+
+QString Addressee::businessPhoneLabel()
+{
+ return i18n("Business Phone");
+}
+
+
+QString Addressee::mobilePhoneLabel()
+{
+ return i18n("Mobile Phone");
+}
+
+
+QString Addressee::homeFaxLabel()
+{
+ return i18n("Home Fax");
+}
+
+
+QString Addressee::businessFaxLabel()
+{
+ return i18n("Business Fax");
+}
+
+
+QString Addressee::carPhoneLabel()
+{
+ return i18n("Car Phone");
+}
+
+
+QString Addressee::isdnLabel()
+{
+ return i18n("ISDN");
+}
+
+
+QString Addressee::pagerLabel()
+{
+ return i18n("Pager");
+}
+
+
+QString Addressee::emailLabel()
+{
+ return i18n("Email Address");
+}
+
+
+void Addressee::setMailer( const QString &mailer )
+{
+ if ( mailer == mData->mailer ) return;
+ detach();
+ mData->empty = false;
+ mData->mailer = mailer;
+}
+
+QString Addressee::mailer() const
+{
+ return mData->mailer;
+}
+
+QString Addressee::mailerLabel()
+{
+ return i18n("Mail Client");
+}
+
+
+void Addressee::setTimeZone( const TimeZone &timeZone )
+{
+ if ( timeZone == mData->timeZone ) return;
+ detach();
+ mData->empty = false;
+ mData->timeZone = timeZone;
+}
+
+TimeZone Addressee::timeZone() const
+{
+ return mData->timeZone;
+}
+
+QString Addressee::timeZoneLabel()
+{
+ return i18n("Time Zone");
+}
+
+
+void Addressee::setGeo( const Geo &geo )
+{
+ if ( geo == mData->geo ) return;
+ detach();
+ mData->empty = false;
+ mData->geo = geo;
+}
+
+Geo Addressee::geo() const
+{
+ return mData->geo;
+}
+
+QString Addressee::geoLabel()
+{
+ return i18n("Geographic Position");
+}
+
+
+void Addressee::setTitle( const QString &title )
+{
+ if ( title == mData->title ) return;
+ detach();
+ mData->empty = false;
+ mData->title = title;
+}
+
+QString Addressee::title() const
+{
+ return mData->title;
+}
+
+QString Addressee::titleLabel()
+{
+ return i18n("Title");
+}
+
+
+void Addressee::setRole( const QString &role )
+{
+ if ( role == mData->role ) return;
+ detach();
+ mData->empty = false;
+ mData->role = role;
+}
+
+QString Addressee::role() const
+{
+ return mData->role;
+}
+
+QString Addressee::roleLabel()
+{
+ return i18n("Role");
+}
+
+
+void Addressee::setOrganization( const QString &organization )
+{
+ if ( organization == mData->organization ) return;
+ detach();
+ mData->empty = false;
+ mData->organization = organization;
+}
+
+QString Addressee::organization() const
+{
+ return mData->organization;
+}
+
+QString Addressee::organizationLabel()
+{
+ return i18n("Organization");
+}
+
+
+void Addressee::setNote( const QString &note )
+{
+ if ( note == mData->note ) return;
+ detach();
+ mData->empty = false;
+ mData->note = note;
+}
+
+QString Addressee::note() const
+{
+ return mData->note;
+}
+
+QString Addressee::noteLabel()
+{
+ return i18n("Note");
+}
+
+
+void Addressee::setProductId( const QString &productId )
+{
+ if ( productId == mData->productId ) return;
+ detach();
+ mData->empty = false;
+ mData->productId = productId;
+}
+
+QString Addressee::productId() const
+{
+ return mData->productId;
+}
+
+QString Addressee::productIdLabel()
+{
+ return i18n("Product Identifier");
+}
+
+
+void Addressee::setRevision( const QDateTime &revision )
+{
+ if ( revision == mData->revision ) return;
+ detach();
+ mData->empty = false;
+ mData->revision = revision;
+}
+
+QDateTime Addressee::revision() const
+{
+ return mData->revision;
+}
+
+QString Addressee::revisionLabel()
+{
+ return i18n("Revision Date");
+}
+
+
+void Addressee::setSortString( const QString &sortString )
+{
+ if ( sortString == mData->sortString ) return;
+ detach();
+ mData->empty = false;
+ mData->sortString = sortString;
+}
+
+QString Addressee::sortString() const
+{
+ return mData->sortString;
+}
+
+QString Addressee::sortStringLabel()
+{
+ return i18n("Sort String");
+}
+
+
+void Addressee::setUrl( const KURL &url )
+{
+ if ( url == mData->url ) return;
+ detach();
+ mData->empty = false;
+ mData->url = url;
+}
+
+KURL Addressee::url() const
+{
+ return mData->url;
+}
+
+QString Addressee::urlLabel()
+{
+ return i18n("URL");
+}
+
+
+void Addressee::setSecrecy( const Secrecy &secrecy )
+{
+ if ( secrecy == mData->secrecy ) return;
+ detach();
+ mData->empty = false;
+ mData->secrecy = secrecy;
+}
+
+Secrecy Addressee::secrecy() const
+{
+ return mData->secrecy;
+}
+
+QString Addressee::secrecyLabel()
+{
+ return i18n("Security Class");
+}
+
+
+void Addressee::setLogo( const Picture &logo )
+{
+ if ( logo == mData->logo ) return;
+ detach();
+ mData->empty = false;
+ mData->logo = logo;
+}
+
+Picture Addressee::logo() const
+{
+ return mData->logo;
+}
+
+QString Addressee::logoLabel()
+{
+ return i18n("Logo");
+}
+
+
+void Addressee::setPhoto( const Picture &photo )
+{
+ if ( photo == mData->photo ) return;
+ detach();
+ mData->empty = false;
+ mData->photo = photo;
+}
+
+Picture Addressee::photo() const
+{
+ return mData->photo;
+}
+
+QString Addressee::photoLabel()
+{
+ return i18n("Photo");
+}
+
+
+void Addressee::setSound( const Sound &sound )
+{
+ if ( sound == mData->sound ) return;
+ detach();
+ mData->empty = false;
+ mData->sound = sound;
+}
+
+Sound Addressee::sound() const
+{
+ return mData->sound;
+}
+
+QString Addressee::soundLabel()
+{
+ return i18n("Sound");
+}
+
+
+void Addressee::setAgent( const Agent &agent )
+{
+ if ( agent == mData->agent ) return;
+ detach();
+ mData->empty = false;
+ mData->agent = agent;
+}
+
+Agent Addressee::agent() const
+{
+ return mData->agent;
+}
+
+QString Addressee::agentLabel()
+{
+ return i18n("Agent");
+}
+
+
+
+void Addressee::setNameFromString( const QString &str )
+{
+ setFormattedName( str );
+ setName( str );
+
+ QStringList titles;
+ titles += i18n( "Dr." );
+ titles += i18n( "Miss" );
+ titles += i18n( "Mr." );
+ titles += i18n( "Mrs." );
+ titles += i18n( "Ms." );
+ titles += i18n( "Prof." );
+
+ QStringList suffixes;
+ suffixes += i18n( "I" );
+ suffixes += i18n( "II" );
+ suffixes += i18n( "III" );
+ suffixes += i18n( "Jr." );
+ suffixes += i18n( "Sr." );
+
+ QStringList prefixes;
+ prefixes += "van";
+ prefixes += "von";
+ prefixes += "de";
+
+//US KConfig config( "kabcrc" );
+ KConfig config( locateLocal( "config", "kabcrc") );
+ config.setGroup( "General" );
+ titles += config.readListEntry( "Prefixes" );
+ titles.remove( "" );
+ prefixes += config.readListEntry( "Inclusions" );
+ prefixes.remove( "" );
+ suffixes += config.readListEntry( "Suffixes" );
+ suffixes.remove( "" );
+
+ // clear all name parts
+ setPrefix( "" );
+ setGivenName( "" );
+ setAdditionalName( "" );
+ setFamilyName( "" );
+ setSuffix( "" );
+
+ if ( str.isEmpty() )
+ return;
+
+ int i = str.find(',');
+ if( i < 0 ) {
+ QStringList parts = QStringList::split( " ", str );
+ int leftOffset = 0;
+ int rightOffset = parts.count() - 1;
+
+ QString suffix;
+ while ( rightOffset >= 0 ) {
+ if ( suffixes.contains( parts[ rightOffset ] ) ) {
+ suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
+ rightOffset--;
+ } else
+ break;
+ }
+ setSuffix( suffix );
+
+ if ( rightOffset < 0 )
+ return;
+
+ if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
+ setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
+ rightOffset--;
+ } else
+ setFamilyName( parts[ rightOffset ] );
+
+ QString prefix;
+ while ( leftOffset < rightOffset ) {
+ if ( titles.contains( parts[ leftOffset ] ) ) {
+ prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
+ leftOffset++;
+ } else
+ break;
+ }
+ setPrefix( prefix );
+
+ if ( leftOffset < rightOffset ) {
+ setGivenName( parts[ leftOffset ] );
+ leftOffset++;
+ }
+
+ QString additionalName;
+ while ( leftOffset < rightOffset ) {
+ additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
+ leftOffset++;
+ }
+ setAdditionalName( additionalName );
+ } else {
+ QString part1 = str.left( i );
+ QString part2 = str.mid( i + 1 );
+
+ QStringList parts = QStringList::split( " ", part1 );
+ int leftOffset = 0;
+ int rightOffset = parts.count() - 1;
+
+ QString suffix;
+ while ( rightOffset >= 0 ) {
+ if ( suffixes.contains( parts[ rightOffset ] ) ) {
+ suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
+ rightOffset--;
+ } else
+ break;
+ }
+ setSuffix( suffix );
+
+ if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
+ setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
+ rightOffset--;
+ } else
+ setFamilyName( parts[ rightOffset ] );
+
+ QString prefix;
+ while ( leftOffset < rightOffset ) {
+ if ( titles.contains( parts[ leftOffset ] ) ) {
+ prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
+ leftOffset++;
+ } else
+ break;
+ }
+
+ parts = QStringList::split( " ", part2 );
+
+ leftOffset = 0;
+ rightOffset = parts.count();
+
+ while ( leftOffset < rightOffset ) {
+ if ( titles.contains( parts[ leftOffset ] ) ) {
+ prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
+ leftOffset++;
+ } else
+ break;
+ }
+ setPrefix( prefix );
+
+ if ( leftOffset < rightOffset ) {
+ setGivenName( parts[ leftOffset ] );
+ leftOffset++;
+ }
+
+ QString additionalName;
+ while ( leftOffset < rightOffset ) {
+ additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
+ leftOffset++;
+ }
+ setAdditionalName( additionalName );
+ }
+}
+
+QString Addressee::realName() const
+{
+ if ( !formattedName().isEmpty() )
+ return formattedName();
+
+ QString n = assembledName();
+
+ if ( n.isEmpty() )
+ n = name();
+
+ return n;
+}
+
+QString Addressee::assembledName() const
+{
+ QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
+ familyName() + " " + suffix();
+
+ return name.simplifyWhiteSpace();
+}
+
+QString Addressee::fullEmail( const QString &email ) const
+{
+ QString e;
+ if ( email.isNull() ) {
+ e = preferredEmail();
+ } else {
+ e = email;
+ }
+ if ( e.isEmpty() ) return QString::null;
+
+ QString text;
+ if ( realName().isEmpty() )
+ text = e;
+ else
+ text = assembledName() + " <" + e + ">";
+
+ return text;
+}
+
+void Addressee::insertEmail( const QString &email, bool preferred )
+{
+ detach();
+
+ QStringList::Iterator it = mData->emails.find( email );
+
+ if ( it != mData->emails.end() ) {
+ if ( !preferred || it == mData->emails.begin() ) return;
+ mData->emails.remove( it );
+ mData->emails.prepend( email );
+ } else {
+ if ( preferred ) {
+ mData->emails.prepend( email );
+ } else {
+ mData->emails.append( email );
+ }
+ }
+}
+
+void Addressee::removeEmail( const QString &email )
+{
+ detach();
+
+ QStringList::Iterator it = mData->emails.find( email );
+ if ( it == mData->emails.end() ) return;
+
+ mData->emails.remove( it );
+}
+
+QString Addressee::preferredEmail() const
+{
+ if ( mData->emails.count() == 0 ) return QString::null;
+ else return mData->emails.first();
+}
+
+QStringList Addressee::emails() const
+{
+ return mData->emails;
+}
+void Addressee::setEmails( const QStringList& emails ) {
+ detach();
+ mData->emails = emails;
+}
+void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
+{
+ detach();
+ mData->empty = false;
+
+ PhoneNumber::List::Iterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ( (*it).id() == phoneNumber.id() ) {
+ *it = phoneNumber;
+ return;
+ }
+ }
+ mData->phoneNumbers.append( phoneNumber );
+}
+
+void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
+{
+ detach();
+
+ PhoneNumber::List::Iterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ( (*it).id() == phoneNumber.id() ) {
+ mData->phoneNumbers.remove( it );
+ return;
+ }
+ }
+}
+
+PhoneNumber Addressee::phoneNumber( int type ) const
+{
+ PhoneNumber phoneNumber( "", type );
+ PhoneNumber::List::ConstIterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ( matchBinaryPattern( (*it).type(), type ) ) {
+ if ( (*it).type() & PhoneNumber::Pref )
+ return (*it);
+ else if ( phoneNumber.number().isEmpty() )
+ phoneNumber = (*it);
+ }
+ }
+
+ return phoneNumber;
+}
+
+PhoneNumber::List Addressee::phoneNumbers() const
+{
+ return mData->phoneNumbers;
+}
+
+PhoneNumber::List Addressee::phoneNumbers( int type ) const
+{
+ PhoneNumber::List list;
+
+ PhoneNumber::List::ConstIterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ( matchBinaryPattern( (*it).type(), type ) ) {
+ list.append( *it );
+ }
+ }
+ return list;
+}
+
+PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
+{
+ PhoneNumber::List::ConstIterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ( (*it).id() == id ) {
+ return *it;
+ }
+ }
+ return PhoneNumber();
+}
+
+void Addressee::insertKey( const Key &key )
+{
+ detach();
+ mData->empty = false;
+
+ Key::List::Iterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it).id() == key.id() ) {
+ *it = key;
+ return;
+ }
+ }
+ mData->keys.append( key );
+}
+
+void Addressee::removeKey( const Key &key )
+{
+ detach();
+
+ Key::List::Iterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it).id() == key.id() ) {
+ mData->keys.remove( key );
+ return;
+ }
+ }
+}
+
+Key Addressee::key( int type, QString customTypeString ) const
+{
+ Key::List::ConstIterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it).type() == type ) {
+ if ( type == Key::Custom ) {
+ if ( customTypeString.isEmpty() ) {
+ return *it;
+ } else {
+ if ( (*it).customTypeString() == customTypeString )
+ return (*it);
+ }
+ } else {
+ return *it;
+ }
+ }
+ }
+ return Key( QString(), type );
+}
+void Addressee::setKeys( const Key::List& list ) {
+ detach();
+ mData->keys = list;
+}
+
+Key::List Addressee::keys() const
+{
+ return mData->keys;
+}
+
+Key::List Addressee::keys( int type, QString customTypeString ) const
+{
+ Key::List list;
+
+ Key::List::ConstIterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it).type() == type ) {
+ if ( type == Key::Custom ) {
+ if ( customTypeString.isEmpty() ) {
+ list.append(*it);
+ } else {
+ if ( (*it).customTypeString() == customTypeString )
+ list.append(*it);
+ }
+ } else {
+ list.append(*it);
+ }
+ }
+ }
+ return list;
+}
+
+Key Addressee::findKey( const QString &id ) const
+{
+ Key::List::ConstIterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it).id() == id ) {
+ return *it;
+ }
+ }
+ return Key();
+}
+
+QString Addressee::asString() const
+{
+ return "Smith, agent Smith...";
+}
+
+void Addressee::dump() const
+{
+ return;
+ kdDebug(5700) << "Addressee {" << endl;
+
+ kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
+
+ kdDebug(5700) << " Name: '" << name() << "'" << endl;
+ kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
+ kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
+ kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
+ kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
+ kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
+ kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
+ kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
+ kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
+ kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
+ kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
+ kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
+ kdDebug(5700) << " Title: '" << title() << "'" << endl;
+ kdDebug(5700) << " Role: '" << role() << "'" << endl;
+ kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
+ kdDebug(5700) << " Note: '" << note() << "'" << endl;
+ kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
+ kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
+ kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
+ kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
+ kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
+ kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
+ kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
+ kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
+ kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
+
+ kdDebug(5700) << " Emails {" << endl;
+ QStringList e = emails();
+ QStringList::ConstIterator it;
+ for( it = e.begin(); it != e.end(); ++it ) {
+ kdDebug(5700) << " " << (*it) << endl;
+ }
+ kdDebug(5700) << " }" << endl;
+
+ kdDebug(5700) << " PhoneNumbers {" << endl;
+ PhoneNumber::List p = phoneNumbers();
+ PhoneNumber::List::ConstIterator it2;
+ for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
+ kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
+ }
+ kdDebug(5700) << " }" << endl;
+
+ Address::List a = addresses();
+ Address::List::ConstIterator it3;
+ for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
+ (*it3).dump();
+ }
+
+ kdDebug(5700) << " Keys {" << endl;
+ Key::List k = keys();
+ Key::List::ConstIterator it4;
+ for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
+ kdDebug(5700) << " Type: " << int((*it4).type()) <<
+ " Key: " << (*it4).textData() <<
+ " CustomString: " << (*it4).customTypeString() << endl;
+ }
+ kdDebug(5700) << " }" << endl;
+
+ kdDebug(5700) << "}" << endl;
+}
+
+
+void Addressee::insertAddress( const Address &address )
+{
+ detach();
+ mData->empty = false;
+
+ Address::List::Iterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( (*it).id() == address.id() ) {
+ *it = address;
+ return;
+ }
+ }
+ mData->addresses.append( address );
+}
+
+void Addressee::removeAddress( const Address &address )
+{
+ detach();
+
+ Address::List::Iterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( (*it).id() == address.id() ) {
+ mData->addresses.remove( it );
+ return;
+ }
+ }
+}
+
+Address Addressee::address( int type ) const
+{
+ Address address( type );
+ Address::List::ConstIterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( matchBinaryPattern( (*it).type(), type ) ) {
+ if ( (*it).type() & Address::Pref )
+ return (*it);
+ else if ( address.isEmpty() )
+ address = (*it);
+ }
+ }
+
+ return address;
+}
+
+Address::List Addressee::addresses() const
+{
+ return mData->addresses;
+}
+
+Address::List Addressee::addresses( int type ) const
+{
+ Address::List list;
+
+ Address::List::ConstIterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( matchBinaryPattern( (*it).type(), type ) ) {
+ list.append( *it );
+ }
+ }
+
+ return list;
+}
+
+Address Addressee::findAddress( const QString &id ) const
+{
+ Address::List::ConstIterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( (*it).id() == id ) {
+ return *it;
+ }
+ }
+ return Address();
+}
+
+void Addressee::insertCategory( const QString &c )
+{
+ detach();
+ mData->empty = false;
+
+ if ( mData->categories.contains( c ) ) return;
+
+ mData->categories.append( c );
+}
+
+void Addressee::removeCategory( const QString &c )
+{
+ detach();
+
+ QStringList::Iterator it = mData->categories.find( c );
+ if ( it == mData->categories.end() ) return;
+
+ mData->categories.remove( it );
+}
+
+bool Addressee::hasCategory( const QString &c ) const
+{
+ return ( mData->categories.contains( c ) );
+}
+
+void Addressee::setCategories( const QStringList &c )
+{
+ detach();
+ mData->empty = false;
+
+ mData->categories = c;
+}
+
+QStringList Addressee::categories() const
+{
+ return mData->categories;
+}
+
+void Addressee::insertCustom( const QString &app, const QString &name,
+ const QString &value )
+{
+ if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
+
+ detach();
+ mData->empty = false;
+
+ QString qualifiedName = app + "-" + name + ":";
+
+ QStringList::Iterator it;
+ for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
+ if ( (*it).startsWith( qualifiedName ) ) {
+ (*it) = qualifiedName + value;
+ return;
+ }
+ }
+
+ mData->custom.append( qualifiedName + value );
+}
+
+void Addressee::removeCustom( const QString &app, const QString &name)
+{
+ detach();
+
+ QString qualifiedName = app + "-" + name + ":";
+
+ QStringList::Iterator it;
+ for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
+ if ( (*it).startsWith( qualifiedName ) ) {
+ mData->custom.remove( it );
+ return;
+ }
+ }
+}
+
+QString Addressee::custom( const QString &app, const QString &name ) const
+{
+ QString qualifiedName = app + "-" + name + ":";
+ QString value;
+
+ QStringList::ConstIterator it;
+ for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
+ if ( (*it).startsWith( qualifiedName ) ) {
+ value = (*it).mid( (*it).find( ":" ) + 1 );
+ break;
+ }
+ }
+
+ return value;
+}
+
+void Addressee::setCustoms( const QStringList &l )
+{
+ detach();
+ mData->empty = false;
+
+ mData->custom = l;
+}
+
+QStringList Addressee::customs() const
+{
+ return mData->custom;
+}
+
+void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
+ QString &email)
+{
+ int startPos, endPos, len;
+ QString partA, partB, result;
+ char endCh = '>';
+
+ startPos = rawEmail.find('<');
+ if (startPos < 0)
+ {
+ startPos = rawEmail.find('(');
+ endCh = ')';
+ }
+ if (startPos < 0)
+ {
+ // We couldn't find any separators, so we assume the whole string
+ // is the email address
+ email = rawEmail;
+ fullName = "";
+ }
+ else
+ {
+ // We have a start position, try to find an end
+ endPos = rawEmail.find(endCh, startPos+1);
+
+ if (endPos < 0)
+ {
+ // We couldn't find the end of the email address. We can only
+ // assume the entire string is the email address.
+ email = rawEmail;
+ fullName = "";
+ }
+ else
+ {
+ // We have a start and end to the email address
+
+ // Grab the name part
+ fullName = rawEmail.left(startPos).stripWhiteSpace();
+
+ // grab the email part
+ email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
+
+ // Check that we do not have any extra characters on the end of the
+ // strings
+ len = fullName.length();
+ if (fullName[0]=='"' && fullName[len-1]=='"')
+ fullName = fullName.mid(1, len-2);
+ else if (fullName[0]=='<' && fullName[len-1]=='>')
+ fullName = fullName.mid(1, len-2);
+ else if (fullName[0]=='(' && fullName[len-1]==')')
+ fullName = fullName.mid(1, len-2);
+ }
+ }
+}
+
+void Addressee::setResource( Resource *resource )
+{
+ detach();
+ mData->resource = resource;
+}
+
+Resource *Addressee::resource() const
+{
+ return mData->resource;
+}
+
+void Addressee::setChanged( bool value )
+{
+ detach();
+ mData->changed = value;
+}
+
+bool Addressee::changed() const
+{
+ return mData->changed;
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
+{
+ if (!a.mData) return s;
+
+ s << a.uid();
+
+ s << a.mData->name;
+ s << a.mData->formattedName;
+ s << a.mData->familyName;
+ s << a.mData->givenName;
+ s << a.mData->additionalName;
+ s << a.mData->prefix;
+ s << a.mData->suffix;
+ s << a.mData->nickName;
+ s << a.mData->birthday;
+ s << a.mData->mailer;
+ s << a.mData->timeZone;
+ s << a.mData->geo;
+ s << a.mData->title;
+ s << a.mData->role;
+ s << a.mData->organization;
+ s << a.mData->note;
+ s << a.mData->productId;
+ s << a.mData->revision;
+ s << a.mData->sortString;
+ s << a.mData->url;
+ s << a.mData->secrecy;
+ s << a.mData->logo;
+ s << a.mData->photo;
+ s << a.mData->sound;
+ s << a.mData->agent;
+ s << a.mData->phoneNumbers;
+ s << a.mData->addresses;
+ s << a.mData->emails;
+ s << a.mData->categories;
+ s << a.mData->custom;
+ s << a.mData->keys;
+ return s;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
+{
+ if (!a.mData) return s;
+
+ s >> a.mData->uid;
+
+ s >> a.mData->name;
+ s >> a.mData->formattedName;
+ s >> a.mData->familyName;
+ s >> a.mData->givenName;
+ s >> a.mData->additionalName;
+ s >> a.mData->prefix;
+ s >> a.mData->suffix;
+ s >> a.mData->nickName;
+ s >> a.mData->birthday;
+ s >> a.mData->mailer;
+ s >> a.mData->timeZone;
+ s >> a.mData->geo;
+ s >> a.mData->title;
+ s >> a.mData->role;
+ s >> a.mData->organization;
+ s >> a.mData->note;
+ s >> a.mData->productId;
+ s >> a.mData->revision;
+ s >> a.mData->sortString;
+ s >> a.mData->url;
+ s >> a.mData->secrecy;
+ s >> a.mData->logo;
+ s >> a.mData->photo;
+ s >> a.mData->sound;
+ s >> a.mData->agent;
+ s >> a.mData->phoneNumbers;
+ s >> a.mData->addresses;
+ s >> a.mData->emails;
+ s >> a.mData->categories;
+ s >> a.mData->custom;
+ s >> a.mData->keys;
+
+ a.mData->empty = false;
+
+ return s;
+}
+
+bool matchBinaryPattern( int value, int pattern )
+{
+ /**
+ We want to match all telephonnumbers/addresses which have the bits in the
+ pattern set. More are allowed.
+ if pattern == 0 we have a special handling, then we want only those with
+ exactly no bit set.
+ */
+ if ( pattern == 0 )
+ return ( value == 0 );
+ else
+ return ( pattern == ( pattern & value ) );
+}
diff --git a/kabc/addressee.h b/kabc/addressee.h
new file mode 100644
index 0000000..ee98e03
--- a/dev/null
+++ b/kabc/addressee.h
@@ -0,0 +1,817 @@
+/*** Warning! This file has been generated by the script makeaddressee ***/
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_ADDRESSEE_H
+#define KABC_ADDRESSEE_H
+
+#include <qdatetime.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qvaluelist.h>
+
+#include <ksharedptr.h>
+#include <kurl.h>
+
+#include "address.h"
+#include "agent.h"
+#include "geo.h"
+#include "key.h"
+#include "phonenumber.h"
+#include "picture.h"
+#include "secrecy.h"
+#include "sound.h"
+#include "timezone.h"
+
+namespace KABC {
+
+class Resource;
+
+/**
+ @short address book entry
+
+ This class represents an entry in the address book.
+
+ The data of this class is implicitly shared. You can pass this class by value.
+
+ If you need the name of a field for presenting it to the user you should use
+ the functions ending in Label(). They return a translated string which can be
+ used as label for the corresponding field.
+
+ About the name fields:
+
+ givenName() is the first name and familyName() the last name. In some
+ countries the family name comes first, that's the reason for the
+ naming. formattedName() is the full name with the correct formatting.
+ It is used as an override, when the correct formatting can't be generated
+ from the other name fields automatically.
+
+ realName() returns a fully formatted name(). It uses formattedName, if set,
+ otherwise it constucts the name from the name fields. As fallback, if
+ nothing else is set it uses name().
+
+ name() is the NAME type of RFC2426. It can be used as internal name for the
+ data enty, but shouldn't be used for displaying the data to the user.
+ */
+class Addressee
+{
+ friend QDataStream &operator<<( QDataStream &, const Addressee & );
+ friend QDataStream &operator>>( QDataStream &, Addressee & );
+
+ public:
+ typedef QValueList<Addressee> List;
+
+ /**
+ Construct an empty address book entry.
+ */
+ Addressee();
+ ~Addressee();
+
+ Addressee( const Addressee & );
+ Addressee &operator=( const Addressee & );
+
+ bool operator==( const Addressee & ) const;
+ bool operator!=( const Addressee & ) const;
+
+ /**
+ Return, if the address book entry is empty.
+ */
+ bool isEmpty() const;
+
+ /**
+ Set unique identifier.
+ */
+ void setUid( const QString &uid );
+ /**
+ Return unique identifier.
+ */
+ QString uid() const;
+ /**
+ Return translated label for uid field.
+ */
+ static QString uidLabel();
+
+ /**
+ Set name.
+ */
+ void setName( const QString &name );
+ /**
+ Return name.
+ */
+ QString name() const;
+ /**
+ Return translated label for name field.
+ */
+ static QString nameLabel();
+
+ /**
+ Set formatted name.
+ */
+ void setFormattedName( const QString &formattedName );
+ /**
+ Return formatted name.
+ */
+ QString formattedName() const;
+ /**
+ Return translated label for formattedName field.
+ */
+ static QString formattedNameLabel();
+
+ /**
+ Set family name.
+ */
+ void setFamilyName( const QString &familyName );
+ /**
+ Return family name.
+ */
+ QString familyName() const;
+ /**
+ Return translated label for familyName field.
+ */
+ static QString familyNameLabel();
+
+ /**
+ Set given name.
+ */
+ void setGivenName( const QString &givenName );
+ /**
+ Return given name.
+ */
+ QString givenName() const;
+ /**
+ Return translated label for givenName field.
+ */
+ static QString givenNameLabel();
+
+ /**
+ Set additional names.
+ */
+ void setAdditionalName( const QString &additionalName );
+ /**
+ Return additional names.
+ */
+ QString additionalName() const;
+ /**
+ Return translated label for additionalName field.
+ */
+ static QString additionalNameLabel();
+
+ /**
+ Set honorific prefixes.
+ */
+ void setPrefix( const QString &prefix );
+ /**
+ Return honorific prefixes.
+ */
+ QString prefix() const;
+ /**
+ Return translated label for prefix field.
+ */
+ static QString prefixLabel();
+
+ /**
+ Set honorific suffixes.
+ */
+ void setSuffix( const QString &suffix );
+ /**
+ Return honorific suffixes.
+ */
+ QString suffix() const;
+ /**
+ Return translated label for suffix field.
+ */
+ static QString suffixLabel();
+
+ /**
+ Set nick name.
+ */
+ void setNickName( const QString &nickName );
+ /**
+ Return nick name.
+ */
+ QString nickName() const;
+ /**
+ Return translated label for nickName field.
+ */
+ static QString nickNameLabel();
+
+ /**
+ Set birthday.
+ */
+ void setBirthday( const QDateTime &birthday );
+ /**
+ Return birthday.
+ */
+ QDateTime birthday() const;
+ /**
+ Return translated label for birthday field.
+ */
+ static QString birthdayLabel();
+
+ /**
+ Return translated label for homeAddressStreet field.
+ */
+ static QString homeAddressStreetLabel();
+
+ /**
+ Return translated label for homeAddressLocality field.
+ */
+ static QString homeAddressLocalityLabel();
+
+ /**
+ Return translated label for homeAddressRegion field.
+ */
+ static QString homeAddressRegionLabel();
+
+ /**
+ Return translated label for homeAddressPostalCode field.
+ */
+ static QString homeAddressPostalCodeLabel();
+
+ /**
+ Return translated label for homeAddressCountry field.
+ */
+ static QString homeAddressCountryLabel();
+
+ /**
+ Return translated label for homeAddressLabel field.
+ */
+ static QString homeAddressLabelLabel();
+
+ /**
+ Return translated label for businessAddressStreet field.
+ */
+ static QString businessAddressStreetLabel();
+
+ /**
+ Return translated label for businessAddressLocality field.
+ */
+ static QString businessAddressLocalityLabel();
+
+ /**
+ Return translated label for businessAddressRegion field.
+ */
+ static QString businessAddressRegionLabel();
+
+ /**
+ Return translated label for businessAddressPostalCode field.
+ */
+ static QString businessAddressPostalCodeLabel();
+
+ /**
+ Return translated label for businessAddressCountry field.
+ */
+ static QString businessAddressCountryLabel();
+
+ /**
+ Return translated label for businessAddressLabel field.
+ */
+ static QString businessAddressLabelLabel();
+
+ /**
+ Return translated label for homePhone field.
+ */
+ static QString homePhoneLabel();
+
+ /**
+ Return translated label for businessPhone field.
+ */
+ static QString businessPhoneLabel();
+
+ /**
+ Return translated label for mobilePhone field.
+ */
+ static QString mobilePhoneLabel();
+
+ /**
+ Return translated label for homeFax field.
+ */
+ static QString homeFaxLabel();
+
+ /**
+ Return translated label for businessFax field.
+ */
+ static QString businessFaxLabel();
+
+ /**
+ Return translated label for carPhone field.
+ */
+ static QString carPhoneLabel();
+
+ /**
+ Return translated label for isdn field.
+ */
+ static QString isdnLabel();
+
+ /**
+ Return translated label for pager field.
+ */
+ static QString pagerLabel();
+
+ /**
+ Return translated label for email field.
+ */
+ static QString emailLabel();
+
+ /**
+ Set mail client.
+ */
+ void setMailer( const QString &mailer );
+ /**
+ Return mail client.
+ */
+ QString mailer() const;
+ /**
+ Return translated label for mailer field.
+ */
+ static QString mailerLabel();
+
+ /**
+ Set time zone.
+ */
+ void setTimeZone( const TimeZone &timeZone );
+ /**
+ Return time zone.
+ */
+ TimeZone timeZone() const;
+ /**
+ Return translated label for timeZone field.
+ */
+ static QString timeZoneLabel();
+
+ /**
+ Set geographic position.
+ */
+ void setGeo( const Geo &geo );
+ /**
+ Return geographic position.
+ */
+ Geo geo() const;
+ /**
+ Return translated label for geo field.
+ */
+ static QString geoLabel();
+
+ /**
+ Set title.
+ */
+ void setTitle( const QString &title );
+ /**
+ Return title.
+ */
+ QString title() const;
+ /**
+ Return translated label for title field.
+ */
+ static QString titleLabel();
+
+ /**
+ Set role.
+ */
+ void setRole( const QString &role );
+ /**
+ Return role.
+ */
+ QString role() const;
+ /**
+ Return translated label for role field.
+ */
+ static QString roleLabel();
+
+ /**
+ Set organization.
+ */
+ void setOrganization( const QString &organization );
+ /**
+ Return organization.
+ */
+ QString organization() const;
+ /**
+ Return translated label for organization field.
+ */
+ static QString organizationLabel();
+
+ /**
+ Set note.
+ */
+ void setNote( const QString &note );
+ /**
+ Return note.
+ */
+ QString note() const;
+ /**
+ Return translated label for note field.
+ */
+ static QString noteLabel();
+
+ /**
+ Set product identifier.
+ */
+ void setProductId( const QString &productId );
+ /**
+ Return product identifier.
+ */
+ QString productId() const;
+ /**
+ Return translated label for productId field.
+ */
+ static QString productIdLabel();
+
+ /**
+ Set revision date.
+ */
+ void setRevision( const QDateTime &revision );
+ /**
+ Return revision date.
+ */
+ QDateTime revision() const;
+ /**
+ Return translated label for revision field.
+ */
+ static QString revisionLabel();
+
+ /**
+ Set sort string.
+ */
+ void setSortString( const QString &sortString );
+ /**
+ Return sort string.
+ */
+ QString sortString() const;
+ /**
+ Return translated label for sortString field.
+ */
+ static QString sortStringLabel();
+
+ /**
+ Set URL.
+ */
+ void setUrl( const KURL &url );
+ /**
+ Return URL.
+ */
+ KURL url() const;
+ /**
+ Return translated label for url field.
+ */
+ static QString urlLabel();
+
+ /**
+ Set security class.
+ */
+ void setSecrecy( const Secrecy &secrecy );
+ /**
+ Return security class.
+ */
+ Secrecy secrecy() const;
+ /**
+ Return translated label for secrecy field.
+ */
+ static QString secrecyLabel();
+
+ /**
+ Set logo.
+ */
+ void setLogo( const Picture &logo );
+ /**
+ Return logo.
+ */
+ Picture logo() const;
+ /**
+ Return translated label for logo field.
+ */
+ static QString logoLabel();
+
+ /**
+ Set photo.
+ */
+ void setPhoto( const Picture &photo );
+ /**
+ Return photo.
+ */
+ Picture photo() const;
+ /**
+ Return translated label for photo field.
+ */
+ static QString photoLabel();
+
+ /**
+ Set sound.
+ */
+ void setSound( const Sound &sound );
+ /**
+ Return sound.
+ */
+ Sound sound() const;
+ /**
+ Return translated label for sound field.
+ */
+ static QString soundLabel();
+
+ /**
+ Set agent.
+ */
+ void setAgent( const Agent &agent );
+ /**
+ Return agent.
+ */
+ Agent agent() const;
+ /**
+ Return translated label for agent field.
+ */
+ static QString agentLabel();
+
+ /**
+ Set name fields by parsing the given string and trying to associate the
+ parts of the string with according fields. This function should probably
+ be a bit more clever.
+ */
+ void setNameFromString( const QString & );
+
+ /**
+ Return the name of the addressee. This is calculated from all the name
+ fields.
+ */
+ QString realName() const;
+
+ /**
+ Return the name that consists of all name parts.
+ */
+ QString assembledName() const;
+
+ /**
+ Return email address including real name.
+
+ @param email Email address to be used to construct the full email string.
+ If this is QString::null the preferred email address is used.
+ */
+ QString fullEmail( const QString &email=QString::null ) const;
+
+ /**
+ Insert an email address. If the email address already exists in this
+ addressee it is not duplicated.
+
+ @param email Email address
+ @param preferred Set to true, if this is the preferred email address of
+ the addressee.
+ */
+ void insertEmail( const QString &email, bool preferred=false );
+
+ /**
+ Remove email address. If the email address doesn't exist, nothing happens.
+ */
+ void removeEmail( const QString &email );
+
+ /**
+ Return preferred email address. This is the first email address or the
+ last one added with @ref insertEmail() with a set preferred parameter.
+ */
+ QString preferredEmail() const;
+
+ /**
+ Return list of all email addresses.
+ */
+ QStringList emails() const;
+
+ /**
+ Set the emails to @param.
+ The first email address gets the preferred one!
+ @param list The list of email addresses.
+ */
+ void setEmails( const QStringList& list);
+
+ /**
+ Insert a phone number. If a phone number with the same id already exists
+ in this addressee it is not duplicated.
+ */
+ void insertPhoneNumber( const PhoneNumber &phoneNumber );
+
+ /**
+ Remove phone number. If no phone number with the given id exists for this
+ addresse nothing happens.
+ */
+ void removePhoneNumber( const PhoneNumber &phoneNumber );
+
+ /**
+ Return phone number, which matches the given type.
+ */
+ PhoneNumber phoneNumber( int type ) const;
+
+ /**
+ Return list of all phone numbers.
+ */
+ PhoneNumber::List phoneNumbers() const;
+
+ /**
+ Return list of phone numbers with a special type.
+ */
+ PhoneNumber::List phoneNumbers( int type ) const;
+
+ /**
+ Return phone number with the given id.
+ */
+ PhoneNumber findPhoneNumber( const QString &id ) const;
+
+ /**
+ Insert a key. If a key with the same id already exists
+ in this addressee it is not duplicated.
+ */
+ void insertKey( const Key &key );
+
+ /**
+ Remove a key. If no key with the given id exists for this
+ addresse nothing happens.
+ */
+ void removeKey( const Key &key );
+
+ /**
+ Return key, which matches the given type.
+ If @p type == Key::Custom you can specify a string
+ that should match. If you leave the string empty, the first
+ key with a custom value is returned.
+ */
+ Key key( int type, QString customTypeString = QString::null ) const;
+
+ /**
+ Return list of all keys.
+ */
+ Key::List keys() const;
+
+ /**
+ Set the list of keys
+ @param keys The keys to be set.
+ */
+ void setKeys( const Key::List& keys);
+
+ /**
+ Return list of keys with a special type.
+ If @p type == Key::Custom you can specify a string
+ that should match. If you leave the string empty, all custom
+ keys will be returned.
+ */
+ Key::List keys( int type, QString customTypeString = QString::null ) const;
+
+ /**
+ Return key with the given id.
+ */
+ Key findKey( const QString &id ) const;
+
+ /**
+ Insert an address. If an address with the same id already exists
+ in this addressee it is not duplicated.
+ */
+ void insertAddress( const Address &address );
+
+ /**
+ Remove address. If no address with the given id exists for this
+ addresse nothing happens.
+ */
+ void removeAddress( const Address &address );
+
+ /**
+ Return address, which matches the given type.
+ */
+ Address address( int type ) const;
+
+ /**
+ Return list of all addresses.
+ */
+ Address::List addresses() const;
+
+ /**
+ Return list of addresses with a special type.
+ */
+ Address::List addresses( int type ) const;
+
+ /**
+ Return address with the given id.
+ */
+ Address findAddress( const QString &id ) const;
+
+ /**
+ Insert category. If the category already exists it is not duplicated.
+ */
+ void insertCategory( const QString & );
+
+ /**
+ Remove category.
+ */
+ void removeCategory( const QString & );
+
+ /**
+ Return, if addressee has the given category.
+ */
+ bool hasCategory( const QString & ) const;
+
+ /**
+ Set categories to given value.
+ */
+ void setCategories( const QStringList & );
+
+ /**
+ Return list of all set categories.
+ */
+ QStringList categories() const;
+
+ /**
+ Insert custom entry. The entry is identified by the name of the inserting
+ application and a unique name. If an entry with the given app and name
+ already exists its value is replaced with the new given value.
+ */
+ void insertCustom( const QString &app, const QString &name,
+ const QString &value );
+
+ /**
+ Remove custom entry.
+ */
+ void removeCustom( const QString &app, const QString &name );
+
+ /**
+ Return value of custom entry, identified by app and entry name.
+ */
+ QString custom( const QString &app, const QString &name ) const;
+
+ /**
+ Set all custom entries.
+ */
+ void setCustoms( const QStringList & );
+
+ /**
+ Return list of all custom entries.
+ */
+ QStringList customs() const;
+
+ /**
+ Parse full email address. The result is given back in fullName and email.
+ */
+ static void parseEmailAddress( const QString &rawEmail, QString &fullName,
+ QString &email );
+
+ /**
+ Debug output.
+ */
+ void dump() const;
+
+ /**
+ Returns string representation of the addressee.
+ */
+ QString asString() const;
+
+ /**
+ Set resource where the addressee is from.
+ */
+ void setResource( Resource *resource );
+
+ /**
+ Return pointer to resource.
+ */
+ Resource *resource() const;
+
+ /**
+ Mark addressee as changed.
+ */
+ void setChanged( bool value );
+
+ /**
+ Return whether the addressee is changed.
+ */
+ bool changed() const;
+
+ private:
+ Addressee copy();
+ void detach();
+
+ struct AddresseeData;
+ mutable KSharedPtr<AddresseeData> mData;
+};
+
+QDataStream &operator<<( QDataStream &, const Addressee & );
+QDataStream &operator>>( QDataStream &, Addressee & );
+
+}
+
+#endif
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp
new file mode 100644
index 0000000..033e857
--- a/dev/null
+++ b/kabc/addresseedialog.cpp
@@ -0,0 +1,264 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qgroupbox.h>
+#include <qapplication.h>
+#include <qregexp.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+#include <kglobalsettings.h>
+
+#include "stdaddressbook.h"
+
+#include "addresseedialog.h"
+//#include "addresseedialog.moc"
+
+using namespace KABC;
+
+AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) :
+ QListViewItem( parent ),
+ mAddressee( addressee )
+{
+ setText( Name, addressee.realName() );
+ setText( Email, addressee.preferredEmail() );
+}
+
+QString AddresseeItem::key( int column, bool ) const
+{
+ /* LR
+ if (column == Email) {
+ QString value = text(Email);
+ QRegExp emailRe("<\\S*>");
+ int match = emailRe.search(value);
+ if (match > -1)
+ value = value.mid(match + 1, emailRe.matchedLength() - 2);
+
+ return value.lower();
+ }
+ */
+ return text(column).lower();
+}
+
+AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
+ KDialogBase( KDialogBase::Plain, i18n("Select Addressee"),
+ Ok|Cancel, Ok, parent ), mMultiple( multiple )
+{
+ QWidget *topWidget = plainPage();
+
+ QBoxLayout *topLayout = new QHBoxLayout( topWidget );
+ QBoxLayout *listLayout = new QVBoxLayout;
+ topLayout->addLayout( listLayout );
+
+ mAddresseeList = new KListView( topWidget );
+ mAddresseeList->addColumn( i18n("Name") );
+ mAddresseeList->addColumn( i18n("Email") );
+ mAddresseeList->setAllColumnsShowFocus( true );
+ mAddresseeList->setFullWidth( true );
+ listLayout->addWidget( mAddresseeList );
+ connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ),
+ SLOT( slotOk() ) );
+ connect( mAddresseeList, SIGNAL( selectionChanged( QListViewItem * ) ),
+ SLOT( updateEdit( QListViewItem * ) ) );
+
+ mAddresseeEdit = new KLineEdit( topWidget );
+ //mAddresseeEdit->setCompletionMode( KGlobalSettings::CompletionAuto );
+ // connect( mAddresseeEdit->completionObject(), SIGNAL( match( const QString & ) ),
+ // SLOT( selectItem( const QString & ) ) );
+ mAddresseeEdit->setFocus();
+ //mAddresseeEdit->completionObject()->setIgnoreCase( true );
+ listLayout->addWidget( mAddresseeEdit );
+
+ //setInitialSize( QSize( 450, 300 ) );
+
+ if ( mMultiple ) {
+ QBoxLayout *selectedLayout = new QVBoxLayout;
+ topLayout->addLayout( selectedLayout );
+ topLayout->setSpacing( spacingHint() );
+
+ QGroupBox *selectedGroup = new QGroupBox( 1, Horizontal, i18n("Selected"),
+ topWidget );
+ selectedLayout->addWidget( selectedGroup );
+
+ mSelectedList = new KListView( selectedGroup );
+ mSelectedList->addColumn( i18n("Name") );
+ mSelectedList->addColumn( i18n("Email") );
+ mSelectedList->setAllColumnsShowFocus( true );
+ mSelectedList->setFullWidth( true );
+ connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ),
+ SLOT( removeSelected() ) );
+
+ QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup );
+ connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) );
+
+ connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ),
+ SLOT( addSelected( QListViewItem * ) ) );
+
+ // setInitialSize( QSize( 650, 350 ) );
+ }
+
+ mAddressBook = StdAddressBook::self( true );
+ connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ),
+ SLOT( addressBookChanged() ) );
+ connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ),
+ SLOT( addressBookChanged() ) );
+
+ loadAddressBook();
+}
+
+AddresseeDialog::~AddresseeDialog()
+{
+}
+
+void AddresseeDialog::loadAddressBook()
+{
+ mAddresseeList->clear();
+ mItemDict.clear();
+ //mAddresseeEdit->completionObject()->clear();
+
+ AddressBook::Iterator it;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) );
+ addCompletionItem( (*it).realName(), item );
+ addCompletionItem( (*it).preferredEmail(), item );
+ }
+}
+
+void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item )
+{
+ if ( str.isEmpty() ) return;
+
+ mItemDict.insert( str, item );
+ //mAddresseeEdit->completionObject()->addItem( str );
+}
+
+void AddresseeDialog::selectItem( const QString &str )
+{
+ if ( str.isEmpty() ) return;
+
+ QListViewItem *item = mItemDict.find( str );
+ if ( item ) {
+ mAddresseeList->blockSignals( true );
+ mAddresseeList->setSelected( item, true );
+ mAddresseeList->ensureItemVisible( item );
+ mAddresseeList->blockSignals( false );
+ }
+}
+
+void AddresseeDialog::updateEdit( QListViewItem *item )
+{
+ mAddresseeEdit->setText( item->text( 0 ) );
+ mAddresseeEdit->setSelection( 0, item->text( 0 ).length() );
+}
+
+void AddresseeDialog::addSelected( QListViewItem *item )
+{
+ AddresseeItem *addrItem = (AddresseeItem *)( item );
+ if ( !addrItem ) return;
+
+ Addressee a = addrItem->addressee();
+
+ QListViewItem *selectedItem = mSelectedDict.find( a.uid() );
+ if ( !selectedItem ) {
+ selectedItem = new AddresseeItem( mSelectedList, a );
+ mSelectedDict.insert( a.uid(), selectedItem );
+ }
+}
+
+void AddresseeDialog::removeSelected()
+{
+ QListViewItem *item = mSelectedList->selectedItem();
+ AddresseeItem *addrItem = (AddresseeItem *)( item );
+ if ( !addrItem ) return;
+
+ mSelectedDict.remove( addrItem->addressee().uid() );
+ delete addrItem;
+}
+
+Addressee AddresseeDialog::addressee()
+{
+ AddresseeItem *aItem = 0;
+
+ if ( mMultiple )
+ aItem = (AddresseeItem *)( mSelectedList->firstChild() );
+ else
+ aItem = (AddresseeItem *)( mAddresseeList->selectedItem() );
+
+ if (aItem) return aItem->addressee();
+ return Addressee();
+}
+
+Addressee::List AddresseeDialog::addressees()
+{
+ Addressee::List al;
+ AddresseeItem *aItem = 0;
+
+ if ( mMultiple ) {
+ QListViewItem *item = mSelectedList->firstChild();
+ while( item ) {
+ aItem = (AddresseeItem *)( item );
+ if ( aItem ) al.append( aItem->addressee() );
+ item = item->nextSibling();
+ }
+ }
+ else
+ {
+ aItem = (AddresseeItem *)( mAddresseeList->selectedItem() );
+ if (aItem) al.append( aItem->addressee() );
+ }
+
+ return al;
+}
+
+Addressee AddresseeDialog::getAddressee( QWidget *parent )
+{
+ AddresseeDialog *dlg = new AddresseeDialog( parent );
+ Addressee addressee;
+ int result = dlg->exec();
+
+ if ( result == QDialog::Accepted ) {
+ addressee = dlg->addressee();
+ }
+
+ delete dlg;
+ return addressee;
+}
+
+Addressee::List AddresseeDialog::getAddressees( QWidget *parent )
+{
+ AddresseeDialog *dlg = new AddresseeDialog( parent, true );
+ Addressee::List addressees;
+ if ( QApplication::desktop()->width() <= 640 )
+ dlg->showMaximized();
+ int result = dlg->exec();
+ if ( result == QDialog::Accepted ) {
+ addressees = dlg->addressees();
+ }
+
+ delete dlg;
+ return addressees;
+}
+
+void AddresseeDialog::addressBookChanged()
+{
+ loadAddressBook();
+}
diff --git a/kabc/addresseedialog.h b/kabc/addresseedialog.h
new file mode 100644
index 0000000..74e7871
--- a/dev/null
+++ b/kabc/addresseedialog.h
@@ -0,0 +1,160 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_ADDRESSEEDIALOG_H
+#define KABC_ADDRESSEEDIALOG_H
+
+#include <qdict.h>
+
+#include <kdialogbase.h>
+#include <klineedit.h>
+#include <klistview.h>
+
+#include "addressbook.h"
+
+namespace KABC {
+
+/**
+ @short Special ListViewItem, that is used by the AddresseeDialog.
+*/
+class AddresseeItem : public QListViewItem
+{
+ public:
+
+ /**
+ Type of column
+ @li @p Name - Name in Addressee
+ @li @p Email - Email in Addressee
+ */
+ enum columns { Name = 0, Email = 1 };
+
+ /**
+ Constructor.
+
+ @param parent The parent listview.
+ @param addressee The associated addressee.
+ */
+ AddresseeItem( QListView *parent, const Addressee &addressee );
+
+ /**
+ Returns the addressee.
+ */
+ Addressee addressee() const { return mAddressee; }
+
+ /**
+ Method used by QListView to sort the items.
+ */
+ virtual QString key( int column, bool ascending ) const;
+
+ private:
+ Addressee mAddressee;
+};
+
+/**
+ @short Dialog for selecting address book entries.
+
+ This class provides a dialog for selecting entries from the standard KDE
+ address book. Use the getAddressee() function to open a modal dialog,
+ returning an address book entry.
+
+ In the dialog you can select an entry from the list with the mouse or type in
+ the first letters of the name or email address you are searching for. The
+ entry matching best is automatically selected. Use double click, pressing
+ return or pressing the ok button to return the selected addressee to the
+ application.
+*/
+class AddresseeDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ /**
+ Construct addressbook entry select dialog.
+
+ @param parent parent widget
+ */
+ AddresseeDialog( QWidget *parent=0, bool multiple=false );
+
+ /**
+ Destructor.
+ */
+ virtual ~AddresseeDialog();
+
+ /**
+ Return the address chosen.
+
+ If it is a multiple select, this will return only the first address chosen
+ */
+ Addressee addressee();
+
+ /**
+ Return the list of addresses chosen
+ */
+ Addressee::List addressees();
+
+ /**
+ Select a single address book entry.
+
+ Open addressee select dialog and return the entry selected by the user.
+ If the user doesn't select an entry or presses cancel, the returned
+ addressee is empty.
+ */
+ static Addressee getAddressee( QWidget *parent );
+
+ /**
+ Select multiple address book entries.
+
+ Open addressee select dialog and return the entries selected by the user.
+ If the user doesn't select an entry or presses cancel, the returned
+ addressee list is empty.
+ */
+ static Addressee::List getAddressees( QWidget *parent );
+
+ private slots:
+ void selectItem( const QString & );
+ void updateEdit( QListViewItem *item );
+ void addSelected( QListViewItem *item );
+ void removeSelected();
+
+ protected slots:
+ void addressBookChanged();
+
+ private:
+ void loadAddressBook();
+ void addCompletionItem( const QString &str, QListViewItem *item );
+
+ bool mMultiple;
+
+ KListView *mAddresseeList;
+ KLineEdit *mAddresseeEdit;
+
+ KListView *mSelectedList;
+
+ AddressBook *mAddressBook;
+
+ QDict<QListViewItem> mItemDict;
+ QDict<QListViewItem> mSelectedDict;
+
+ class AddresseeDialogPrivate;
+ AddresseeDialogPrivate *d;
+};
+
+}
+#endif
diff --git a/kabc/addresseelist.cpp b/kabc/addresseelist.cpp
new file mode 100644
index 0000000..097e162
--- a/dev/null
+++ b/kabc/addresseelist.cpp
@@ -0,0 +1,292 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Jost Schenck <jost@schenck.de>
+ 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <kdebug.h>
+//US
+#include <qtl.h>
+
+
+#include "addresseelist.h"
+#include "field.h"
+
+using namespace KABC;
+
+//
+//
+// Traits
+//
+//
+
+bool SortingTraits::Uid::eq( const Addressee &a1, const Addressee &a2 )
+{
+ // locale awareness doesn't make sense sorting ids
+ return ( QString::compare( a1.uid(), a2.uid() ) == 0 );
+}
+
+bool SortingTraits::Uid::lt( const Addressee &a1, const Addressee &a2 )
+{
+ // locale awareness doesn't make sense sorting ids
+ return ( QString::compare( a1.uid(), a2.uid() ) < 0 );
+}
+
+bool SortingTraits::Name::eq( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ return ( QString::compare( a1.name(), a2.name() ) == 0 );
+}
+
+bool SortingTraits::Name::lt( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ return ( QString::compare( a1.name(), a2.name() ) < 0 );
+}
+
+bool SortingTraits::FormattedName::eq( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ return ( QString::compare( a1.formattedName(), a2.formattedName() ) == 0 );
+}
+
+bool SortingTraits::FormattedName::lt( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ return ( QString::compare( a1.formattedName(), a2.formattedName() ) < 0 );
+}
+
+bool SortingTraits::FamilyName::eq( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ return ( QString::compare( a1.familyName(), a2.familyName() ) == 0
+ && QString::compare( a1.givenName(), a2.givenName() ) == 0 );
+}
+
+bool SortingTraits::FamilyName::lt( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ int family = QString::compare( a1.familyName(), a2.familyName() );
+ if ( 0 == family ) {
+ return ( QString::compare( a1.givenName(), a2.givenName() ) < 0 );
+ } else {
+ return family < 0;
+ }
+}
+
+bool SortingTraits::GivenName::eq( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ return ( QString::compare( a1.givenName(), a2.givenName() ) == 0
+ && QString::compare( a1.familyName(), a2.familyName() ) == 0 );
+}
+
+bool SortingTraits::GivenName::lt( const Addressee &a1, const Addressee &a2 )
+{
+//US QString::localeAwareCompare is not available in my distribution. Redefine it to compare
+ int given = QString::compare( a1.givenName(), a2.givenName() );
+ if ( 0 == given ) {
+ return ( QString::compare( a1.familyName(), a2.familyName() ) < 0 );
+ } else {
+ return given < 0;
+ }
+}
+
+//
+//
+// AddresseeList
+//
+//
+
+AddresseeList::AddresseeList()
+ : QValueList<Addressee>()
+{
+ mReverseSorting = false;
+ mActiveSortingCriterion = FormattedName;
+ mActiveSortingField = 0;
+}
+
+AddresseeList::~AddresseeList()
+{
+}
+
+AddresseeList::AddresseeList( const AddresseeList &l )
+ : QValueList<Addressee>( l )
+{
+ mReverseSorting = l.reverseSorting();
+ mActiveSortingCriterion = l.sortingCriterion();
+}
+
+AddresseeList::AddresseeList( const QValueList<Addressee> &l )
+ : QValueList<Addressee>( l )
+{
+ mReverseSorting = false;
+}
+
+void AddresseeList::dump() const
+{
+ kdDebug(5700) << "AddresseeList {" << endl;
+ kdDebug(5700) << "reverse order: " << ( mReverseSorting ? "true" : "false" ) << endl;
+
+ QString crit;
+ if ( Uid == mActiveSortingCriterion ) {
+ crit = "Uid";
+ } else if ( Name == mActiveSortingCriterion ) {
+ crit = "Name";
+ } else if ( FormattedName == mActiveSortingCriterion ) {
+ crit = "FormattedName";
+ } else if ( FamilyName == mActiveSortingCriterion ) {
+ crit = "FamilyName";
+ } else if ( GivenName == mActiveSortingCriterion ) {
+ crit = "GivenName";
+ } else {
+ crit = "unknown -- update dump method";
+ }
+
+ kdDebug(5700) << "sorting criterion: " << crit << endl;
+
+//US
+//US for ( const_iterator it = begin(); it != end(); ++it )
+ for ( ConstIterator it = begin(); it != end(); ++it )
+ (*it).dump();
+
+ kdDebug(5700) << "}" << endl;
+}
+
+void AddresseeList::sortBy( SortingCriterion c )
+{
+ mActiveSortingCriterion = c;
+ if ( Uid == c ) {
+ sortByTrait<SortingTraits::Uid>();
+ } else if ( Name == c ) {
+ sortByTrait<SortingTraits::Name>();
+ } else if ( FormattedName == c ) {
+ sortByTrait<SortingTraits::FormattedName>();
+ } else if ( FamilyName == c ) {
+ sortByTrait<SortingTraits::FamilyName>();
+ } else if ( GivenName==c ) {
+ sortByTrait<SortingTraits::GivenName>();
+ } else {
+ kdError(5700) << "AddresseeList sorting criterion passed for which a trait is not known. No sorting done." << endl;
+ }
+}
+
+void AddresseeList::sort()
+{
+ sortBy( mActiveSortingCriterion );
+}
+
+template<class Trait>
+void AddresseeList::sortByTrait()
+{
+ // FIXME: better sorting algorithm, bubblesort is not acceptable for larger lists.
+ //
+ // for i := 1 to n - 1
+ // do for j := 1 to n - i
+ // do if A[j] > A[j+1]
+ // then temp := A[j]
+ // A[j] := A[j + 1]
+ // A[j + 1 ] := temp
+
+//US iterator i1 = begin();
+ Iterator i1 = begin();
+//US iterator endIt = end();
+ Iterator endIt = end();
+ --endIt;
+ if ( i1 == endIt ) // don't need sorting
+ return;
+
+//US iterator i2 = endIt;
+ Iterator i2 = endIt;
+ while( i1 != endIt ) {
+//US iterator j1 = begin();
+ Iterator j1 = begin();
+//US iterator j2 = j1;
+ Iterator j2 = j1;
+ ++j2;
+ while( j1 != i2 ) {
+ if ( !mReverseSorting && Trait::lt( *j2, *j1 )
+ || mReverseSorting && Trait::lt( *j1, *j2 ) ) {
+ qSwap( *j1, *j2 );
+ }
+ ++j1;
+ ++j2;
+ }
+ ++i1;
+ --i2;
+ }
+}
+
+void AddresseeList::sortByField( Field *field )
+{
+ if ( field )
+ mActiveSortingField = field;
+
+ if ( !mActiveSortingField ) {
+ kdWarning(5700) << "sortByField called with no active sort field" << endl;
+ return;
+ }
+
+ if ( count() == 0 )
+ return;
+
+ quickSortByField( 0, count() - 1 );
+}
+
+void AddresseeList::quickSortByField( int left, int right )
+{
+ int i = left;
+ int j = right;
+ int mid = ( left + right ) / 2;
+
+//US iterator x = at( mid );
+ ConstIterator x = at( mid );
+
+ do {
+ if ( !mReverseSorting ) {
+ //US QString::localeAwareCompare was not available. Used compare instead.
+ while ( QString::compare( mActiveSortingField->value( *at( i ) ).upper(), mActiveSortingField->value( *x ).upper() ) < 0 )
+ i++;
+ //US QString::localeAwareCompare was not available. Used compare instead.
+ while ( QString::compare( mActiveSortingField->value( *at( j ) ).upper(), mActiveSortingField->value( *x ).upper() ) > 0 )
+ j--;
+ } else {
+ //US QString::localeAwareCompare was not available. Used compare instead.
+ while ( QString::compare( mActiveSortingField->value( *at( i ) ).upper(), mActiveSortingField->value( *x ).upper() ) > 0 )
+ i++;
+ //US QString::localeAwareCompare was not available. Used compare instead.
+ while ( QString::compare( mActiveSortingField->value( *at( j ) ).upper(), mActiveSortingField->value( *x ).upper() ) < 0 )
+ j--;
+ }
+ if ( i <= j ) {
+ qSwap( *at( i ), *at( j ) );
+ i++;
+ j--;
+ }
+ } while ( i <= j );
+
+ if ( left < j ) quickSortByField( left, j );
+ if ( right > i ) quickSortByField( i, right );
+}
diff --git a/kabc/addresseelist.h b/kabc/addresseelist.h
new file mode 100644
index 0000000..2df252c
--- a/dev/null
+++ b/kabc/addresseelist.h
@@ -0,0 +1,218 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Jost Schenck <jost@schenck.de>
+ 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_ADDRESSEELIST_H
+#define KABC_ADDRESSEELIST_H
+
+#include <qvaluelist.h>
+
+#include "addressee.h"
+
+namespace KABC {
+
+class Field;
+
+/**
+ * Each trait must implement one static function for equality, one for "less
+ * than". Class name should be the field name. A trait does not necessarily
+ * have to stick to just one field: a trait sorting by family name can e.g.
+ * sort addressees with equal family name by given name.
+ *
+ * If you want to implement reverse sorting, you do not have to write another
+ * trait, as AddresseeList takes care of that.
+ */
+namespace SortingTraits
+{
+
+class Uid
+{
+ public:
+ static bool eq( const Addressee &, const Addressee & );
+ static bool lt( const Addressee &, const Addressee & );
+};
+
+class Name
+{
+ public:
+ static bool eq( const Addressee &, const Addressee & );
+ static bool lt( const Addressee &, const Addressee & );
+};
+
+class FormattedName
+{
+ public:
+ static bool eq( const Addressee &, const Addressee & );
+ static bool lt( const Addressee &, const Addressee & );
+};
+
+class FamilyName // fallback to given name
+{
+ public:
+ static bool eq( const Addressee &, const Addressee & );
+ static bool lt( const Addressee &, const Addressee & );
+};
+
+class GivenName // fallback to family name
+{
+ public:
+ static bool eq( const Addressee &, const Addressee & );
+ static bool lt( const Addressee &, const Addressee & );
+};
+
+}
+
+/**
+ * Addressee attribute used for sorting.
+ */
+typedef enum { Uid, Name, FormattedName, FamilyName, GivenName } SortingCriterion;
+
+/**
+ * @short a QValueList of Addressee, with sorting functionality
+ *
+ * This class extends the functionality of QValueList with
+ * sorting methods specific to the Addressee class. It can be used
+ * just like any other QValueList but is no template class.
+ *
+ * An AddresseeList does not automatically keep sorted when addressees
+ * are added or removed or the sorting order is changed, as this would
+ * slow down larger operations by sorting after every step. So after
+ * such operations you have to call {@link #sort} or {@link #sortBy} to
+ * create a defined order again.
+ *
+ * Iterator usage is inherited by QValueList and extensively documented
+ * there. Please remember that the state of an iterator is undefined
+ * after any sorting operation.
+ *
+ * For the enumeration Type SortingCriterion, which specifies the
+ * field by the collection will be sorted, the following values exist:
+ * Uid, Name, FormattedName, FamilyName, GivenName.
+ *
+ * @author Jost Schenck jost@schenck.de
+ */
+class AddresseeList : public QValueList<Addressee>
+{
+ public:
+ AddresseeList();
+ ~AddresseeList();
+ AddresseeList( const AddresseeList & );
+ AddresseeList( const QValueList<Addressee> & );
+
+ /**
+ * Debug output.
+ */
+ void dump() const;
+
+ /**
+ * Determines the direction of sorting. On change, the list
+ * will <em>not</em> automatically be resorted.
+ * @param r <tt>true</tt> if sorting should be done reverse, <tt>false</tt> otherwise
+ */
+ void setReverseSorting( bool r = true ) { mReverseSorting = r; }
+
+ /**
+ * Returns the direction of sorting.
+ * @return <tt>true</tt> if sorting is done reverse, <tt>false</tt> otherwise
+ */
+ bool reverseSorting() const { return mReverseSorting; }
+
+ /**
+ * Sorts this list by a specific criterion.
+ * @param c the criterion by which should be sorted
+ */
+ void sortBy( SortingCriterion c );
+
+ /**
+ * Sorts this list by a specific field. If no parameter is given, the
+ * last used Field object will be used.
+ * @param field pointer to the Field object to be sorted by
+ */
+ void sortByField( Field *field = 0 );
+
+ /**
+ * Sorts this list by its active sorting criterion. This normally is the
+ * criterion of the last sortBy operation or <tt>FormattedName</tt> if up
+ * to now there has been no sortBy operation.
+ *
+ * Please note that the sorting trait of the last {@link #sortByTrait}
+ * method call is not remembered and thus the action can not be repeated
+ * by this method.
+ */
+ void sort();
+
+ /**
+ * Templated sort function. You normally will not want to use this but
+ * {@link #sortBy} and {@link #sort} instead as the existing sorting
+ * criteria completely suffice for most cases.
+ *
+ * However, if you do want to use some special sorting criterion, you can
+ * write a trait class that will be provided to this templated method.
+ * This trait class has to have a class declaration like the following:
+ * <pre>
+ * class MySortingTrait {
+ * public:
+ * // eq returns true if a1 and a2 are equal
+ * static bool eq(KABC::Addressee a1, KABC::Addressee a2);
+ * // lt returns true is a1 is "less than" a2
+ * static bool lt(KABC::Addressee a1, KABC::Addressee a2);
+ * };
+ * </pre>
+ * You can then pass this class to the sortByTrait method like this:
+ * <pre>
+ * myAddresseelist.sortByTrait&lt;MySortingTrait&gt;();
+ * </pre>
+ * Please note that the {@link #sort} method can not be used to repeat the
+ * sorting of the last <tt>sortByTrait</tt> action.
+ *
+ * Right now this method uses the bubble sort algorithm. This should be
+ * replaced for a better one when I have time.
+ */
+ template<class Trait> void sortByTrait();
+
+ /**
+ * Returns the active sorting criterion, ie the sorting criterion that
+ * will be used by a {@link #sort} call.
+ */
+ SortingCriterion sortingCriterion() const { return mActiveSortingCriterion; }
+
+ /**
+ * Returns the active sorting field, ie a pointer to the Field object
+ * which was used for the last {@link #sortByField} operation.
+ */
+ Field* sortingField() const { return mActiveSortingField; }
+
+ private:
+ void quickSortByField( int, int );
+
+ bool mReverseSorting;
+ SortingCriterion mActiveSortingCriterion;
+ Field* mActiveSortingField;
+};
+
+}
+
+#endif
diff --git a/kabc/agent.cpp b/kabc/agent.cpp
new file mode 100644
index 0000000..ef26cbf
--- a/dev/null
+++ b/kabc/agent.cpp
@@ -0,0 +1,155 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include "addressee.h"
+
+#include "agent.h"
+
+using namespace KABC;
+
+Agent::Agent()
+ : mAddressee( 0 ), mIntern( false )
+{
+}
+
+Agent::Agent( const QString &url )
+ : mAddressee( 0 ),mUrl( url ), mIntern( false )
+{
+}
+
+Agent::Agent( Addressee *addressee )
+ : mAddressee( addressee ), mIntern( true )
+{
+}
+
+Agent::~Agent()
+{
+ delete mAddressee;
+ mAddressee = 0;
+}
+
+bool Agent::operator==( const Agent &a ) const
+{
+ if ( mIntern != a.mIntern )
+ return false;
+
+ if ( !mIntern ) {
+ if ( mUrl != a.mUrl )
+ return false;
+ } else {
+ if ( mAddressee && !a.mAddressee ) return false;
+ if ( !mAddressee && a.mAddressee ) return false;
+ if ( !mAddressee && !a.mAddressee ) return false;
+ if ( (*mAddressee) != (*a.mAddressee) ) return false;
+ }
+
+ return true;
+}
+
+bool Agent::operator!=( const Agent &a ) const
+{
+ return !( a == *this );
+}
+
+Agent &Agent::operator=( const Agent &addr )
+{
+ if ( this == &addr )
+ return *this;
+
+ if ( addr.mIntern && addr.mAddressee ) {
+ if ( mAddressee )
+ delete mAddressee;
+
+ mAddressee = new Addressee;
+ *mAddressee = *(addr.mAddressee);
+ }
+
+ mUrl = addr.mUrl;
+ mIntern = addr.mIntern;
+
+ return *this;
+}
+
+void Agent::setUrl( const QString &url )
+{
+ mUrl = url;
+ mIntern = false;
+}
+
+void Agent::setAddressee( Addressee *addressee )
+{
+ mAddressee = addressee;
+ mIntern = true;
+}
+
+bool Agent::isIntern() const
+{
+ return mIntern;
+}
+
+QString Agent::url() const
+{
+ return mUrl;
+}
+
+Addressee *Agent::addressee() const
+{
+ return mAddressee;
+}
+
+QString Agent::asString() const
+{
+ if ( mIntern )
+ return "intern agent";
+ else
+ return mUrl;
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Agent &agent )
+{
+ Q_UINT32 hasAddressee = ( agent.mAddressee != 0 );
+
+ s << agent.mIntern << agent.mUrl << hasAddressee;
+ if ( hasAddressee )
+ s << (*agent.mAddressee);
+
+ return s;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Agent &agent )
+{
+ Q_UINT32 hasAddressee;
+
+ s >> agent.mIntern >> agent.mUrl >> hasAddressee;
+
+ if ( hasAddressee ) {
+ agent.mAddressee = new Addressee;
+ s >> (*agent.mAddressee);
+ }
+
+ return s;
+}
diff --git a/kabc/agent.h b/kabc/agent.h
new file mode 100644
index 0000000..fa459d5
--- a/dev/null
+++ b/kabc/agent.h
@@ -0,0 +1,129 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_AGENT_H
+#define KABC_AGENT_H
+
+namespace KABC {
+
+class Addressee;
+
+/**
+ * Important!!!
+ *
+ * At the moment the vcard format does not support saving and loading
+ * this entity.
+ */
+class Agent
+{
+ friend QDataStream &operator<<( QDataStream &, const Agent & );
+ friend QDataStream &operator>>( QDataStream &, Agent & );
+
+public:
+
+ /**
+ * Consturctor. Creates an empty object.
+ */
+ Agent();
+
+ /**
+ * Consturctor.
+ *
+ * @param url A URL that describes the position of the agent file.
+ */
+ Agent( const QString &url );
+
+ /**
+ * Consturctor.
+ *
+ * @param addressee The addressee object of the agent.
+ */
+ Agent( Addressee *addressee );
+
+ /**
+ * Destructor.
+ */
+ ~Agent();
+
+
+ bool operator==( const Agent & ) const;
+ bool operator!=( const Agent & ) const;
+ Agent &operator=( const Agent & );
+
+ /**
+ * Sets a URL for the location of the agent file. When using this
+ * function, @ref isIntern() will return 'false' until you use
+ * @ref setAddressee().
+ *
+ * @param url The location URL of the agent file.
+ */
+ void setUrl( const QString &url );
+
+ /**
+ * Sets the addressee of the agent. When using this function,
+ * @ref isIntern() will return 'true' until you use @ref setUrl().
+ *
+ * @param addressee The addressee object of the agent.
+ */
+ void setAddressee( Addressee *addressee );
+
+ /**
+ * Returns whether the agent is described by a URL (extern) or
+ * by a addressee (intern).
+ * When this method returns 'true' you can use @ref addressee() to
+ * get a @ref Addressee object. Otherwise you can request the URL
+ * of this agent by @ref url() and load the data from that location.
+ */
+ bool isIntern() const;
+
+ /**
+ * Returns the location URL of this agent.
+ */
+ QString url() const;
+
+ /**
+ * Returns the addressee object of this agent.
+ */
+ Addressee* addressee() const;
+
+ /**
+ * Returns string representation of the agent.
+ */
+ QString asString() const;
+
+private:
+ Addressee *mAddressee;
+ QString mUrl;
+
+ int mIntern;
+};
+
+QDataStream &operator<<( QDataStream &, const Agent & );
+QDataStream &operator>>( QDataStream &, Agent & );
+
+}
+#endif
diff --git a/kabc/distributionlist.cpp b/kabc/distributionlist.cpp
new file mode 100644
index 0000000..aa2725d
--- a/dev/null
+++ b/kabc/distributionlist.cpp
@@ -0,0 +1,293 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <ksimpleconfig.h>
+#include <kstandarddirs.h>
+#include <kdebug.h>
+
+#include "distributionlist.h"
+
+using namespace KABC;
+
+DistributionList::DistributionList( DistributionListManager *manager,
+ const QString &name ) :
+ mManager( manager ), mName( name )
+{
+ mManager->insert( this );
+}
+
+DistributionList::~DistributionList()
+{
+ mManager->remove( this );
+}
+
+void DistributionList::setName( const QString &name )
+{
+ mName = name;
+}
+
+QString DistributionList::name() const
+{
+ return mName;
+}
+
+void DistributionList::insertEntry( const Addressee &a, const QString &email )
+{
+ Entry e( a, email );
+
+ QValueList<Entry>::Iterator it;
+ for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
+ if ( (*it).addressee.uid() == a.uid() ) {
+ /**
+ We have to check if both email addresses contains no data,
+ a simple 'email1 == email2' wont work here
+ */
+ if ( ( (*it).email.isNull() && email.isEmpty() ) ||
+ ( (*it).email.isEmpty() && email.isNull() ) ||
+ ( (*it).email == email ) ) {
+ *it = e;
+ return;
+ }
+ }
+ }
+ mEntries.append( e );
+}
+
+void DistributionList::removeEntry( const Addressee &a, const QString &email )
+{
+ QValueList<Entry>::Iterator it;
+ for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
+ if ( (*it).addressee.uid() == a.uid() && (*it).email == email ) {
+ mEntries.remove( it );
+ return;
+ }
+ }
+}
+
+QStringList DistributionList::emails() const
+{
+ QStringList emails;
+
+ Entry::List::ConstIterator it;
+ for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
+ Addressee a = (*it).addressee;
+ QString email = (*it).email.isEmpty() ? a.fullEmail() :
+ a.fullEmail( (*it).email );
+
+ if ( !email.isEmpty() ) {
+ emails.append( email );
+ }
+ }
+
+ return emails;
+}
+
+DistributionList::Entry::List DistributionList::entries() const
+{
+ return mEntries;
+}
+
+
+DistributionListManager::DistributionListManager( AddressBook *ab ) :
+ mAddressBook( ab )
+{
+}
+
+DistributionListManager::~DistributionListManager()
+{
+}
+
+DistributionList *DistributionListManager::list( const QString &name )
+{
+ DistributionList *list;
+ for( list = mLists.first(); list; list = mLists.next() ) {
+ if ( list->name() == name ) return list;
+ }
+
+ return 0;
+}
+
+void DistributionListManager::insert( DistributionList *l )
+{
+ DistributionList *list;
+ for( list = mLists.first(); list; list = mLists.next() ) {
+ if ( list->name() == l->name() ) {
+ mLists.remove( list );
+ break;
+ }
+ }
+ mLists.append( l );
+}
+
+void DistributionListManager::remove( DistributionList *l )
+{
+ DistributionList *list;
+ for( list = mLists.first(); list; list = mLists.next() ) {
+ if ( list->name() == l->name() ) {
+ mLists.remove( list );
+ return;
+ }
+ }
+}
+
+QStringList DistributionListManager::listNames()
+{
+ QStringList names;
+
+ DistributionList *list;
+ for( list = mLists.first(); list; list = mLists.next() ) {
+ names.append( list->name() );
+ }
+
+ return names;
+}
+
+bool DistributionListManager::load()
+{
+ KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );
+
+#ifndef KAB_EMBEDDED
+
+ QMap<QString,QString> entryMap = cfg.entryMap( mAddressBook->identifier() );
+ if ( entryMap.isEmpty() ) {
+ kdDebug(5700) << "No distlists for '" << mAddressBook->identifier() << "'" << endl;
+ return false;
+ }
+
+ cfg.setGroup( mAddressBook->identifier() );
+
+ QMap<QString,QString>::ConstIterator it;
+ for( it = entryMap.begin(); it != entryMap.end(); ++it ) {
+ QString name = it.key();
+
+#else //KAB_EMBEDDED
+ cfg.setGroup( mAddressBook->identifier() );
+ //US we work in microkde with a list of distributionlists
+ QStringList distlists = cfg.readListEntry( "Lists" );
+ if ( distlists.isEmpty() ) {
+ kdDebug(5700) << "No distlists for '" << mAddressBook->identifier() << "'" << endl;
+ return false;
+ }
+
+ QStringList::ConstIterator it;
+ for( it = distlists.begin(); it != distlists.end(); ++it ) {
+ QString name = *it;
+
+#endif //KAB_EMBEDDED
+
+ QStringList value = cfg.readListEntry( name );
+
+ kdDebug(5700) << "DLM::load(): " << name << ": " << value.join(",") << endl;
+
+ DistributionList *list = new DistributionList( this, name );
+
+ QStringList::ConstIterator it2 = value.begin();
+ while( it2 != value.end() ) {
+ QString id = *it2++;
+ QString email = *it2;
+
+ kdDebug(5700) << "----- Entry " << id << endl;
+
+ Addressee a = mAddressBook->findByUid( id );
+ if ( !a.isEmpty() ) {
+ list->insertEntry( a, email );
+ }
+
+ if ( it2 == value.end() ) break;
+ ++it2;
+ }
+ }
+
+ return true;
+}
+
+bool DistributionListManager::save()
+{
+ kdDebug(5700) << "DistListManager::save()" << endl;
+
+ KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );
+
+ cfg.deleteGroup( mAddressBook->identifier() );
+ cfg.setGroup( mAddressBook->identifier() );
+
+ DistributionList *list;
+ for( list = mLists.first(); list; list = mLists.next() ) {
+ kdDebug(5700) << " Saving '" << list->name() << "'" << endl;
+ QStringList value;
+ DistributionList::Entry::List entries = list->entries();
+ DistributionList::Entry::List::ConstIterator it;
+ for( it = entries.begin(); it != entries.end(); ++it ) {
+ value.append( (*it).addressee.uid() );
+ value.append( (*it).email );
+ }
+ cfg.writeEntry( list->name(), value );
+ }
+
+#ifdef KAB_EMBEDDED
+//US for microKDE we have not yet sophisticated methods to load maps.
+// Because of that we store also a list of all distributionlists.
+ QStringList namelist;
+ for( list = mLists.first(); list; list = mLists.next() ) {
+ namelist.append( list->name() );
+ }
+ cfg.writeEntry( "Lists", namelist );
+
+#endif //KAB_EMBEDDED
+
+ cfg.sync();
+
+ return true;
+}
+
+DistributionListWatcher* DistributionListWatcher::mSelf = 0;
+
+DistributionListWatcher::DistributionListWatcher()
+ : QObject( 0, "DistributionListWatcher" )
+{
+#ifndef KAB_EMBEDDED
+ mDirWatch = new KDirWatch;
+ mDirWatch->addFile( locateLocal( "data", "kabc/distlists" ) );
+
+ connect( mDirWatch, SIGNAL( dirty( const QString& ) ), SIGNAL( changed() ) );
+ mDirWatch->startScan();
+#endif //KAB_EMBEDDED
+}
+
+DistributionListWatcher::~DistributionListWatcher()
+{
+#ifndef KAB_EMBEDDED
+ delete mDirWatch;
+ mDirWatch = 0;
+#endif //KAB_EMBEDDED
+}
+
+DistributionListWatcher *DistributionListWatcher::self()
+{
+ if ( !mSelf )
+ mSelf = new DistributionListWatcher();
+
+ return mSelf;
+}
+
+
+#ifndef KAB_EMBEDDED
+#include "distributionlist.moc"
+#endif //KAB_EMBEDDED
+
diff --git a/kabc/distributionlist.h b/kabc/distributionlist.h
new file mode 100644
index 0000000..ccff487
--- a/dev/null
+++ b/kabc/distributionlist.h
@@ -0,0 +1,219 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_DISTRIBUTIONLIST_H
+#define KABC_DISTRIBUTIONLIST_H
+
+#include <kdirwatch.h>
+
+#include "addressbook.h"
+
+namespace KABC {
+
+class DistributionListManager;
+
+/**
+ @short Distribution list of email addresses
+
+ This class represents a list of email addresses. Each email address is
+ associated with an address book entry. If the address book entry changes, the
+ entry in the distribution list is automatically updated.
+*/
+class DistributionList
+{
+ public:
+ /**
+ @short Distribution List Entry
+
+ This class represents an entry of a distribution list. It consists of an
+ addressee and an email address. If the email address is null, the
+ preferred email address of the addressee is used.
+ */
+ struct Entry
+ {
+ typedef QValueList<Entry> List;
+
+ Entry() {}
+ Entry( const Addressee &_addressee, const QString &_email ) :
+ addressee( _addressee ), email( _email ) {}
+
+ Addressee addressee;
+ QString email;
+ };
+
+ /**
+ Create distribution list object.
+
+ @param manager Managing object of this list.
+ @param name Name of this list.
+ */
+ DistributionList( DistributionListManager *manager, const QString &name );
+
+ /**
+ Destructor.
+ */
+ ~DistributionList();
+
+ /**
+ Set name of this list. The name is used as key by the
+ DistributinListManager.
+ */
+ void setName( const QString & );
+
+ /**
+ Get name of this list.
+ */
+ QString name() const;
+
+ /**
+ Insert an entry into this distribution list. If the entry already exists
+ nothing happens.
+ */
+ void insertEntry( const Addressee &, const QString &email=QString::null );
+
+ /**
+ Remove an entry from this distribution list. If the entry doesn't exist
+ nothing happens.
+ */
+ void removeEntry( const Addressee &, const QString &email=QString::null );
+
+ /**
+ Return list of email addresses, which belong to this distributon list.
+ These addresses can be directly used by e.g. a mail client.
+ */
+ QStringList emails() const;
+
+ /**
+ Return list of entries belonging to this distribution list. This function
+ is mainly useful for a distribution list editor.
+ */
+ Entry::List entries() const;
+
+ private:
+ DistributionListManager *mManager;
+ QString mName;
+
+ Entry::List mEntries;
+};
+
+/**
+ @short Manager of distribution lists
+
+ This class represents a collection of distribution lists, which are associated
+ with a given address book.
+*/
+class DistributionListManager
+{
+ public:
+ /**
+ Create manager for given address book.
+ */
+ DistributionListManager( AddressBook * );
+
+ /**
+ Destructor.
+ */
+ ~DistributionListManager();
+
+ /**
+ Return distribution list with given name.
+ */
+ DistributionList *list( const QString &name );
+
+ /**
+ Insert distribution list. If a list with this name already exists, nothing
+ happens.
+ */
+ void insert( DistributionList * );
+
+ /**
+ Remove distribution list. If a list with this name doesn't exist, nothing
+ happens.
+ */
+ void remove( DistributionList * );
+
+ /**
+ Return names of all distribution lists managed by this manager.
+ */
+ QStringList listNames();
+
+ /**
+ Load distribution lists form disk.
+ */
+ bool load();
+
+ /**
+ Save distribution lists to disk.
+ */
+ bool save();
+
+ private:
+ AddressBook *mAddressBook;
+
+ QPtrList<DistributionList> mLists;
+};
+
+/**
+ @short Watchdog for distribution lists
+
+ This class provides a @ref changed() signal that i emitted when the
+ distribution lists has changed in some way.
+
+ Exapmle:
+
+ <pre>
+ KABC::DistributionListWatcher *watchdog = KABC::DistributionListWatcher::self()
+
+ connect( watchdog, SIGNAL( changed() ), SLOT( doSomething() ) );
+ </pre>
+*/
+
+class DistributionListWatcher : public QObject
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Returns the watcher object.
+ */
+ static DistributionListWatcher *self();
+
+
+ signals:
+ /**
+ * This signal is emmitted whenever the distribution lists has
+ * changed (if a list was added or removed, when a list was
+ * renamed or the entries of the list changed).
+ */
+ void changed();
+
+ protected:
+ DistributionListWatcher();
+ ~DistributionListWatcher();
+
+ private:
+ static DistributionListWatcher* mSelf;
+#ifndef KAB_EMBEDDED
+ KDirWatch *mDirWatch;
+#endif //KAB_EMBEDDED
+};
+
+}
+#endif
diff --git a/kabc/distributionlistdialog.cpp b/kabc/distributionlistdialog.cpp
new file mode 100644
index 0000000..31d5944
--- a/dev/null
+++ b/kabc/distributionlistdialog.cpp
@@ -0,0 +1,396 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <qlistview.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <klineeditdlg.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+
+#include "addressbook.h"
+#include "addresseedialog.h"
+#include "distributionlist.h"
+
+#include "distributionlistdialog.h"
+
+#ifndef KAB_EMBEDDED
+#include "distributionlistdialog.moc"
+#endif //KAB_EMBEDDED
+
+using namespace KABC;
+
+DistributionListDialog::DistributionListDialog( AddressBook *addressBook, QWidget *parent)
+ : KDialogBase( parent, "", true, i18n("Configure Distribution Lists"), Ok, Ok, true)
+{
+ mEditor = new DistributionListEditorWidget( addressBook, this );
+ setMainWidget( mEditor );
+
+ connect( this, SIGNAL( okClicked() ), mEditor, SLOT( save() ) );
+}
+
+DistributionListDialog::~DistributionListDialog()
+{
+}
+
+
+EmailSelector::EmailSelector( const QStringList &emails, const QString &current,
+ QWidget *parent ) :
+ KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok,
+ parent )
+{
+ QFrame *topFrame = plainPage();
+ QBoxLayout *topLayout = new QVBoxLayout( topFrame );
+
+ mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"),
+ topFrame );
+ topLayout->addWidget( mButtonGroup );
+
+ QStringList::ConstIterator it;
+ for( it = emails.begin(); it != emails.end(); ++it ) {
+ QRadioButton *button = new QRadioButton( *it, mButtonGroup );
+ if ( (*it) == current ) {
+ button->setDown( true );
+ }
+ }
+}
+
+QString EmailSelector::selected()
+{
+ QButton *button = mButtonGroup->selected();
+ if ( button ) return button->text();
+ return QString::null;
+}
+
+QString EmailSelector::getEmail( const QStringList &emails, const QString &current,
+ QWidget *parent )
+{
+ EmailSelector *dlg = new EmailSelector( emails, current, parent );
+ dlg->exec();
+
+ QString result = dlg->selected();
+
+ delete dlg;
+
+ return result;
+}
+
+class EntryItem : public QListViewItem
+{
+ public:
+ EntryItem( QListView *parent, const Addressee &addressee,
+ const QString &email=QString::null ) :
+ QListViewItem( parent ),
+ mAddressee( addressee ),
+ mEmail( email )
+ {
+ setText( 0, addressee.realName() );
+ if( email.isEmpty() ) {
+ setText( 1, addressee.preferredEmail() );
+ setText( 2, i18n("Yes") );
+ } else {
+ setText( 1, email );
+ setText( 2, i18n("No") );
+ }
+ }
+
+ Addressee addressee() const
+ {
+ return mAddressee;
+ }
+
+ QString email() const
+ {
+ return mEmail;
+ }
+
+ private:
+ Addressee mAddressee;
+ QString mEmail;
+};
+
+DistributionListEditorWidget::DistributionListEditorWidget( AddressBook *addressBook, QWidget *parent) :
+ QWidget( parent ),
+ mAddressBook( addressBook )
+{
+ kdDebug(5700) << "DistributionListEditor()" << endl;
+
+ QBoxLayout *topLayout = new QVBoxLayout( this );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ QBoxLayout *nameLayout = new QHBoxLayout( topLayout) ;
+
+ mNameCombo = new QComboBox( this );
+ nameLayout->addWidget( mNameCombo );
+ connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) );
+
+ mNewButton = new QPushButton( i18n("New List..."), this );
+ nameLayout->addWidget( mNewButton );
+ connect( mNewButton, SIGNAL( clicked() ), SLOT( newList() ) );
+
+ mEditButton = new QPushButton( i18n("Rename List..."), this );
+ nameLayout->addWidget( mEditButton );
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( editList() ) );
+
+ mRemoveButton = new QPushButton( i18n("Remove List"), this );
+ nameLayout->addWidget( mRemoveButton );
+ connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeList() ) );
+
+ QGridLayout *gridLayout = new QGridLayout( topLayout, 3, 3 );
+ gridLayout->setColStretch(1, 1);
+
+ QLabel *listLabel = new QLabel( i18n("Available addresses:"), this );
+ gridLayout->addWidget( listLabel, 0, 0 );
+
+ mListLabel = new QLabel( this );
+ gridLayout->addMultiCellWidget( mListLabel, 0, 0, 1, 2 );
+
+ mAddresseeView = new QListView( this );
+ mAddresseeView->addColumn( i18n("Name") );
+ mAddresseeView->addColumn( i18n("Preferred Email") );
+ mAddresseeView->setAllColumnsShowFocus( true );
+ gridLayout->addWidget( mAddresseeView, 1, 0 );
+ connect( mAddresseeView, SIGNAL( selectionChanged() ),
+ SLOT( slotSelectionAddresseeViewChanged() ) );
+ connect( mAddresseeView, SIGNAL( doubleClicked( QListViewItem * ) ),
+ SLOT( addEntry() ) );
+
+ mAddEntryButton = new QPushButton( i18n("Add Entry"), this );
+ mAddEntryButton->setEnabled(false);
+ gridLayout->addWidget( mAddEntryButton, 2, 0 );
+ connect( mAddEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) );
+
+ mEntryView = new QListView( this );
+ mEntryView->addColumn( i18n("Name") );
+ mEntryView->addColumn( i18n("Email") );
+ mEntryView->addColumn( i18n("Use Preferred") );
+ mEntryView->setEnabled(false);
+ mEntryView->setAllColumnsShowFocus( true );
+ gridLayout->addMultiCellWidget( mEntryView, 1, 1, 1, 2 );
+ connect( mEntryView, SIGNAL( selectionChanged() ),
+ SLOT( slotSelectionEntryViewChanged() ) );
+
+ mChangeEmailButton = new QPushButton( i18n("Change Email..."), this );
+ gridLayout->addWidget( mChangeEmailButton, 2, 1 );
+ connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) );
+
+ mRemoveEntryButton = new QPushButton( i18n("Remove Entry"), this );
+ gridLayout->addWidget( mRemoveEntryButton, 2, 2 );
+ connect( mRemoveEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) );
+
+ mManager = new DistributionListManager( mAddressBook );
+ mManager->load();
+
+ updateAddresseeView();
+ updateNameCombo();
+}
+
+DistributionListEditorWidget::~DistributionListEditorWidget()
+{
+ kdDebug(5700) << "~DistributionListEditor()" << endl;
+
+ delete mManager;
+}
+
+void DistributionListEditorWidget::save()
+{
+ mManager->save();
+}
+
+void DistributionListEditorWidget::slotSelectionEntryViewChanged()
+{
+ EntryItem *entryItem = static_cast<EntryItem *>( mEntryView->selectedItem() );
+ bool state=entryItem;
+
+ mChangeEmailButton->setEnabled(state);
+ mRemoveEntryButton->setEnabled(state);
+}
+
+void DistributionListEditorWidget::newList()
+{
+ KLineEditDlg dlg(i18n("Please enter name:"), QString::null, this);
+ dlg.setCaption(i18n("New Distribution List"));
+ if (!dlg.exec()) return;
+
+ new DistributionList( mManager, dlg.text() );
+
+ mNameCombo->clear();
+ mNameCombo->insertStringList( mManager->listNames() );
+ mNameCombo->setCurrentItem( mNameCombo->count() - 1 );
+
+ updateEntryView();
+ slotSelectionAddresseeViewChanged();
+}
+
+void DistributionListEditorWidget::editList()
+{
+ QString oldName = mNameCombo->currentText();
+
+ KLineEditDlg dlg(i18n("Please change name:"), oldName, this);
+ dlg.setCaption(i18n("Distribution List"));
+ if (!dlg.exec()) return;
+
+ DistributionList *list = mManager->list( oldName );
+ list->setName( dlg.text() );
+
+ mNameCombo->clear();
+ mNameCombo->insertStringList( mManager->listNames() );
+ mNameCombo->setCurrentItem( mNameCombo->count() - 1 );
+
+ updateEntryView();
+ slotSelectionAddresseeViewChanged();
+}
+
+void DistributionListEditorWidget::removeList()
+{
+ int result = KMessageBox::warningContinueCancel( this,
+ i18n("Delete distribution list '%1'?") .arg( mNameCombo->currentText() ),
+ QString::null, i18n("Delete") );
+
+ if ( result != KMessageBox::Continue ) return;
+
+ delete mManager->list( mNameCombo->currentText() );
+ mNameCombo->removeItem( mNameCombo->currentItem() );
+
+ updateEntryView();
+ slotSelectionAddresseeViewChanged();
+}
+
+void DistributionListEditorWidget::addEntry()
+{
+ AddresseeItem *addresseeItem =
+ static_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
+
+ if( !addresseeItem ) {
+ kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl;
+ return;
+ }
+
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) {
+ kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl;
+ return;
+ }
+
+ list->insertEntry( addresseeItem->addressee() );
+ updateEntryView();
+ slotSelectionAddresseeViewChanged();
+}
+
+void DistributionListEditorWidget::removeEntry()
+{
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) return;
+
+ EntryItem *entryItem =
+ static_cast<EntryItem *>( mEntryView->selectedItem() );
+ if ( !entryItem ) return;
+
+ list->removeEntry( entryItem->addressee(), entryItem->email() );
+ delete entryItem;
+}
+
+void DistributionListEditorWidget::changeEmail()
+{
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) return;
+
+ EntryItem *entryItem =
+ static_cast<EntryItem *>( mEntryView->selectedItem() );
+ if ( !entryItem ) return;
+
+ QString email = EmailSelector::getEmail( entryItem->addressee().emails(),
+ entryItem->email(), this );
+ list->removeEntry( entryItem->addressee(), entryItem->email() );
+ list->insertEntry( entryItem->addressee(), email );
+
+ updateEntryView();
+}
+
+void DistributionListEditorWidget::updateEntryView()
+{
+ if ( mNameCombo->currentText().isEmpty() ) {
+ mListLabel->setText( i18n("Selected addressees:") );
+ } else {
+ mListLabel->setText( i18n("Selected addresses in '%1':")
+ .arg( mNameCombo->currentText() ) );
+ }
+
+ mEntryView->clear();
+
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) {
+ mEditButton->setEnabled(false);
+ mRemoveButton->setEnabled(false);
+ mChangeEmailButton->setEnabled(false);
+ mRemoveEntryButton->setEnabled(false);
+ mAddresseeView->setEnabled(false);
+ mEntryView->setEnabled(false);
+ return;
+ } else {
+ mEditButton->setEnabled(true);
+ mRemoveButton->setEnabled(true);
+ mAddresseeView->setEnabled(true);
+ mEntryView->setEnabled(true);
+ }
+
+ DistributionList::Entry::List entries = list->entries();
+ DistributionList::Entry::List::ConstIterator it;
+ for( it = entries.begin(); it != entries.end(); ++it ) {
+ new EntryItem( mEntryView, (*it).addressee, (*it).email );
+ }
+
+ EntryItem *entryItem = static_cast<EntryItem *>( mEntryView->selectedItem() );
+ bool state=entryItem;
+
+ mChangeEmailButton->setEnabled(state);
+ mRemoveEntryButton->setEnabled(state);
+}
+
+void DistributionListEditorWidget::updateAddresseeView()
+{
+ mAddresseeView->clear();
+
+ AddressBook::Iterator it;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ new AddresseeItem( mAddresseeView, *it );
+ }
+}
+
+void DistributionListEditorWidget::updateNameCombo()
+{
+ mNameCombo->insertStringList( mManager->listNames() );
+
+ updateEntryView();
+}
+
+void DistributionListEditorWidget::slotSelectionAddresseeViewChanged()
+{
+ AddresseeItem *addresseeItem =
+ static_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
+ bool state=addresseeItem;
+ mAddEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty());
+}
diff --git a/kabc/distributionlistdialog.h b/kabc/distributionlistdialog.h
new file mode 100644
index 0000000..b6d3c80
--- a/dev/null
+++ b/kabc/distributionlistdialog.h
@@ -0,0 +1,140 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_DISTRIBUTIONLISTDIALOG_H
+#define KABC_DISTRIBUTIONLISTDIALOG_H
+
+#include <qwidget.h>
+
+#include <kdialogbase.h>
+
+class QListView;
+class QLabel;
+class QComboBox;
+class QButtonGroup;
+
+namespace KABC {
+
+class AddressBook;
+class DistributionListEditorWidget;
+class DistributionListManager;
+
+/**
+ @short Frontend to create distribution lists
+
+ Creating a new DistributionListDialog does automatically
+ load all addressees and distribution lists from the config
+ files. The changes will be saved when clicking the 'OK'
+ button.
+
+ Example:
+
+ <pre>
+ KABC::DistributionListDialog *dlg = new
+ KABC::DistributionListDialog( KABC::StdAddressBook::self(), this );
+
+ dlg->exec();
+ </pre>
+*/
+class DistributionListDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ /**
+ Constructor.
+
+ @param ab The addressbook, the addressees should be used from
+ @param parent The parent widget
+ */
+ DistributionListDialog( AddressBook *ab, QWidget *parent );
+
+ /**
+ Destructor.
+ */
+ virtual ~DistributionListDialog();
+
+ private:
+ DistributionListEditorWidget *mEditor;
+
+ struct Data;
+ Data *d;
+};
+
+/**
+ @short Helper class
+*/
+class EmailSelector : public KDialogBase
+{
+ public:
+ EmailSelector( const QStringList &emails, const QString &current,
+ QWidget *parent );
+
+ QString selected();
+
+ static QString getEmail( const QStringList &emails, const QString &current,
+ QWidget *parent );
+
+ private:
+ QButtonGroup *mButtonGroup;
+};
+
+/**
+ @short Helper class
+*/
+class DistributionListEditorWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ DistributionListEditorWidget( AddressBook *, QWidget *parent );
+ virtual ~DistributionListEditorWidget();
+
+ private slots:
+ void newList();
+ void editList();
+ void removeList();
+ void addEntry();
+ void removeEntry();
+ void changeEmail();
+ void updateEntryView();
+ void updateAddresseeView();
+ void updateNameCombo();
+ void slotSelectionEntryViewChanged();
+ void slotSelectionAddresseeViewChanged();
+ void save();
+
+ private:
+ QComboBox *mNameCombo;
+ QLabel *mListLabel;
+ QListView *mEntryView;
+ QListView *mAddresseeView;
+
+ AddressBook *mAddressBook;
+ DistributionListManager *mManager;
+ QPushButton *mNewButton, *mEditButton, *mRemoveButton;
+ QPushButton *mChangeEmailButton, *mRemoveEntryButton, *mAddEntryButton;
+
+ struct Data;
+ Data *d;
+};
+
+}
+#endif
diff --git a/kabc/distributionlisteditor.cpp b/kabc/distributionlisteditor.cpp
new file mode 100644
index 0000000..569dc96
--- a/dev/null
+++ b/kabc/distributionlisteditor.cpp
@@ -0,0 +1,335 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <qlistview.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qinputdialog.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "addressbook.h"
+#include "addresseedialog.h"
+#include "distributionlist.h"
+
+#include "distributionlisteditor.h"
+
+#ifndef KAB_EMBEDDED
+#include "distributionlisteditor.moc"
+#endif //KAB_EMBEDDED
+
+using namespace KABC;
+
+EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString &current,
+ QWidget *parent ) :
+ KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok,
+ parent )
+{
+ QFrame *topFrame = plainPage();
+ QBoxLayout *topLayout = new QVBoxLayout( topFrame );
+
+ mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"),
+ topFrame );
+ topLayout->addWidget( mButtonGroup );
+
+ QStringList::ConstIterator it;
+ for( it = emails.begin(); it != emails.end(); ++it ) {
+ QRadioButton *button = new QRadioButton( *it, mButtonGroup );
+ if ( (*it) == current ) {
+ button->setDown( true );
+ }
+ }
+}
+
+QString EmailSelectDialog::selected()
+{
+ QButton *button = mButtonGroup->selected();
+ if ( button ) return button->text();
+ return QString::null;
+}
+
+QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
+ QWidget *parent )
+{
+ EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent );
+ dlg->exec();
+
+ QString result = dlg->selected();
+
+ delete dlg;
+
+ return result;
+}
+
+class EditEntryItem : public QListViewItem
+{
+ public:
+ EditEntryItem( QListView *parent, const Addressee &addressee,
+ const QString &email=QString::null ) :
+ QListViewItem( parent ),
+ mAddressee( addressee ),
+ mEmail( email )
+ {
+ setText( 0, addressee.realName() );
+ if( email.isEmpty() ) {
+ setText( 1, addressee.preferredEmail() );
+ setText( 2, i18n("Yes") );
+ } else {
+ setText( 1, email );
+ setText( 2, i18n("No") );
+ }
+ }
+
+ Addressee addressee() const
+ {
+ return mAddressee;
+ }
+
+ QString email() const
+ {
+ return mEmail;
+ }
+
+ private:
+ Addressee mAddressee;
+ QString mEmail;
+};
+
+DistributionListEditor::DistributionListEditor( AddressBook *addressBook, QWidget *parent) :
+ QWidget( parent ),
+ mAddressBook( addressBook )
+{
+ kdDebug(5700) << "DistributionListEditor()" << endl;
+
+ QBoxLayout *topLayout = new QVBoxLayout( this );
+ topLayout->setMargin( KDialog::marginHint() );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ QBoxLayout *nameLayout = new QHBoxLayout( topLayout) ;
+
+ mNameCombo = new QComboBox( this );
+ nameLayout->addWidget( mNameCombo );
+ connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) );
+
+ newButton = new QPushButton( i18n("New List"), this );
+ nameLayout->addWidget( newButton );
+ connect( newButton, SIGNAL( clicked() ), SLOT( newList() ) );
+
+ removeButton = new QPushButton( i18n("Remove List"), this );
+ nameLayout->addWidget( removeButton );
+ connect( removeButton, SIGNAL( clicked() ), SLOT( removeList() ) );
+
+ mEntryView = new QListView( this );
+ mEntryView->addColumn( i18n("Name") );
+ mEntryView->addColumn( i18n("Email") );
+ mEntryView->addColumn( i18n("Use Preferred") );
+ topLayout->addWidget( mEntryView );
+ connect(mEntryView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionEntryViewChanged()));
+
+ changeEmailButton = new QPushButton( i18n("Change Email"), this );
+ topLayout->addWidget( changeEmailButton );
+ connect( changeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) );
+
+ removeEntryButton = new QPushButton( i18n("Remove Entry"), this );
+ topLayout->addWidget( removeEntryButton );
+ connect( removeEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) );
+
+ addEntryButton = new QPushButton( i18n("Add Entry"), this );
+ topLayout->addWidget( addEntryButton );
+ connect( addEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) );
+
+ mAddresseeView = new QListView( this );
+ mAddresseeView->addColumn( i18n("Name") );
+ mAddresseeView->addColumn( i18n("Preferred Email") );
+ topLayout->addWidget( mAddresseeView );
+
+
+ connect(mAddresseeView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionAddresseeViewChanged()));
+
+ mManager = new DistributionListManager( mAddressBook );
+ mManager->load();
+
+ updateAddresseeView();
+ updateNameCombo();
+ removeButton->setEnabled(!mManager->listNames().isEmpty());
+}
+
+DistributionListEditor::~DistributionListEditor()
+{
+ kdDebug(5700) << "~DistributionListEditor()" << endl;
+
+ mManager->save();
+ delete mManager;
+}
+
+void DistributionListEditor::slotSelectionEntryViewChanged()
+{
+#ifndef KAB_EMBEDDED
+ EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
+#else //KAB_EMBEDDED
+ EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
+#endif //KAB_EMBEDDED
+ bool state = (entryItem != 0L);
+
+ changeEmailButton->setEnabled(state);
+ removeEntryButton->setEnabled(state);
+}
+
+void DistributionListEditor::newList()
+{
+ bool ok = false;
+ QString name = QInputDialog::getText( i18n("New Distribution List"),
+ i18n("Please enter name:"),
+ QLineEdit::Normal, QString::null, &ok,
+ this );
+ if ( !ok || name.isEmpty() ) return;
+
+ new DistributionList( mManager, name );
+
+ mNameCombo->insertItem( name );
+ removeButton->setEnabled(true);
+ updateEntryView();
+}
+
+void DistributionListEditor::removeList()
+{
+ delete mManager->list( mNameCombo->currentText() );
+ mNameCombo->removeItem( mNameCombo->currentItem() );
+ removeButton->setEnabled(!mManager->listNames().isEmpty());
+ addEntryButton->setEnabled( !mNameCombo->currentText().isEmpty());
+ updateEntryView();
+}
+
+void DistributionListEditor::addEntry()
+{
+#ifndef KAB_EMBEDDED
+ AddresseeItem *addresseeItem =
+ dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
+#else //KAB_EMBEDDED
+ AddresseeItem *addresseeItem =
+ (AddresseeItem *)( mAddresseeView->selectedItem() );
+#endif //KAB_EMBEDDED
+
+
+ if( !addresseeItem ) {
+ kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl;
+ return;
+ }
+
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) {
+ kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl;
+ return;
+ }
+
+ list->insertEntry( addresseeItem->addressee() );
+ updateEntryView();
+ slotSelectionAddresseeViewChanged();
+}
+
+void DistributionListEditor::removeEntry()
+{
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) return;
+
+#ifndef KAB_EMBEDDED
+ EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
+#else //KAB_EMBEDDED
+ EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
+#endif //KAB_EMBEDDED
+ if ( !entryItem ) return;
+
+ list->removeEntry( entryItem->addressee(), entryItem->email() );
+ delete entryItem;
+}
+
+void DistributionListEditor::changeEmail()
+{
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) return;
+
+#ifndef KAB_EMBEDDED
+ EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
+#else //KAB_EMBEDDED
+ EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
+#endif //KAB_EMBEDDED
+ if ( !entryItem ) return;
+
+ QString email = EmailSelectDialog::getEmail( entryItem->addressee().emails(),
+ entryItem->email(), this );
+ list->removeEntry( entryItem->addressee(), entryItem->email() );
+ list->insertEntry( entryItem->addressee(), email );
+
+ updateEntryView();
+}
+
+void DistributionListEditor::updateEntryView()
+{
+ DistributionList *list = mManager->list( mNameCombo->currentText() );
+ if ( !list ) return;
+
+ mEntryView->clear();
+ DistributionList::Entry::List entries = list->entries();
+ DistributionList::Entry::List::ConstIterator it;
+ for( it = entries.begin(); it != entries.end(); ++it ) {
+ new EditEntryItem( mEntryView, (*it).addressee, (*it).email );
+ }
+#ifndef KAB_EMBEDDED
+ EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
+#else //KAB_EMBEDDED
+ EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
+#endif //KAB_EMBEDDED
+ bool state = (entryItem != 0L);
+
+ changeEmailButton->setEnabled(state);
+ removeEntryButton->setEnabled(state);
+}
+
+void DistributionListEditor::updateAddresseeView()
+{
+ mAddresseeView->clear();
+
+ AddressBook::Iterator it;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ new AddresseeItem( mAddresseeView, *it );
+ }
+}
+
+void DistributionListEditor::updateNameCombo()
+{
+ mNameCombo->insertStringList( mManager->listNames() );
+
+ updateEntryView();
+}
+
+void DistributionListEditor::slotSelectionAddresseeViewChanged()
+{
+#ifndef KAB_EMBEDDED
+ AddresseeItem *addresseeItem = dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
+#else //KAB_EMBEDDED
+ AddresseeItem *addresseeItem = (AddresseeItem *)( mAddresseeView->selectedItem() );
+#endif //KAB_EMBEDDED
+ bool state = (addresseeItem != 0L);
+ addEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty());
+}
diff --git a/kabc/distributionlisteditor.h b/kabc/distributionlisteditor.h
new file mode 100644
index 0000000..e0b4221
--- a/dev/null
+++ b/kabc/distributionlisteditor.h
@@ -0,0 +1,86 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+#ifndef KABC_DISTRIBUTIONLISTEDITOR_H
+#define KABC_DISTRIBUTIONLISTEDITOR_H
+
+#include <qwidget.h>
+
+#include <kdialogbase.h>
+
+class QListView;
+class QComboBox;
+class QButtonGroup;
+
+namespace KABC {
+
+class AddressBook;
+class DistributionListManager;
+
+class EmailSelectDialog : public KDialogBase
+{
+ public:
+ EmailSelectDialog( const QStringList &emails, const QString &current,
+ QWidget *parent );
+
+ QString selected();
+
+ static QString getEmail( const QStringList &emails, const QString &current,
+ QWidget *parent );
+
+ private:
+ QButtonGroup *mButtonGroup;
+};
+
+/**
+ @obsolete
+*/
+class DistributionListEditor : public QWidget
+{
+ Q_OBJECT
+ public:
+ DistributionListEditor( AddressBook *, QWidget *parent );
+ virtual ~DistributionListEditor();
+
+ private slots:
+ void newList();
+ void removeList();
+ void addEntry();
+ void removeEntry();
+ void changeEmail();
+ void updateEntryView();
+ void updateAddresseeView();
+ void updateNameCombo();
+ void slotSelectionEntryViewChanged();
+ void slotSelectionAddresseeViewChanged();
+
+ private:
+ QComboBox *mNameCombo;
+ QListView *mEntryView;
+ QListView *mAddresseeView;
+
+ AddressBook *mAddressBook;
+ DistributionListManager *mManager;
+ QPushButton *newButton, *removeButton;
+ QPushButton *changeEmailButton,*removeEntryButton,*addEntryButton;
+};
+
+}
+
+#endif
diff --git a/kabc/field.cpp b/kabc/field.cpp
new file mode 100644
index 0000000..41bbfde
--- a/dev/null
+++ b/kabc/field.cpp
@@ -0,0 +1,550 @@
+/*** Warning! This file has been generated by the script makeaddressee ***/
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <klocale.h>
+#include <kconfig.h>
+#include <kconfigbase.h>
+#include <kglobal.h>
+
+#include "field.h"
+
+using namespace KABC;
+
+class Field::FieldImpl
+{
+ public:
+ FieldImpl( int fieldId, int category = 0,
+ const QString &label = QString::null,
+ const QString &key = QString::null,
+ const QString &app = QString::null )
+ : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
+ mKey( key ), mApp( app ) {}
+
+ enum FieldId
+ {
+ CustomField,
+ FormattedName,
+ FamilyName,
+ GivenName,
+ AdditionalName,
+ Prefix,
+ Suffix,
+ NickName,
+ Birthday,
+ HomeAddressStreet,
+ HomeAddressLocality,
+ HomeAddressRegion,
+ HomeAddressPostalCode,
+ HomeAddressCountry,
+ HomeAddressLabel,
+ BusinessAddressStreet,
+ BusinessAddressLocality,
+ BusinessAddressRegion,
+ BusinessAddressPostalCode,
+ BusinessAddressCountry,
+ BusinessAddressLabel,
+ HomePhone,
+ BusinessPhone,
+ MobilePhone,
+ HomeFax,
+ BusinessFax,
+ CarPhone,
+ Isdn,
+ Pager,
+ Email,
+ Mailer,
+ Title,
+ Role,
+ Organization,
+ Note,
+ Url
+ };
+
+ int fieldId() { return mFieldId; }
+ int category() { return mCategory; }
+
+ QString label() { return mLabel; }
+ QString key() { return mKey; }
+ QString app() { return mApp; }
+
+ private:
+ int mFieldId;
+ int mCategory;
+
+ QString mLabel;
+ QString mKey;
+ QString mApp;
+};
+
+
+Field::List Field::mAllFields;
+Field::List Field::mDefaultFields;
+Field::List Field::mCustomFields;
+
+
+Field::Field( FieldImpl *impl )
+{
+ mImpl = impl;
+}
+
+Field::~Field()
+{
+ delete mImpl;
+}
+
+QString Field::label()
+{
+ switch ( mImpl->fieldId() ) {
+ case FieldImpl::FormattedName:
+ return Addressee::formattedNameLabel();
+ case FieldImpl::FamilyName:
+ return Addressee::familyNameLabel();
+ case FieldImpl::GivenName:
+ return Addressee::givenNameLabel();
+ case FieldImpl::AdditionalName:
+ return Addressee::additionalNameLabel();
+ case FieldImpl::Prefix:
+ return Addressee::prefixLabel();
+ case FieldImpl::Suffix:
+ return Addressee::suffixLabel();
+ case FieldImpl::NickName:
+ return Addressee::nickNameLabel();
+ case FieldImpl::Birthday:
+ return Addressee::birthdayLabel();
+ case FieldImpl::HomeAddressStreet:
+ return Addressee::homeAddressStreetLabel();
+ case FieldImpl::HomeAddressLocality:
+ return Addressee::homeAddressLocalityLabel();
+ case FieldImpl::HomeAddressRegion:
+ return Addressee::homeAddressRegionLabel();
+ case FieldImpl::HomeAddressPostalCode:
+ return Addressee::homeAddressPostalCodeLabel();
+ case FieldImpl::HomeAddressCountry:
+ return Addressee::homeAddressCountryLabel();
+ case FieldImpl::HomeAddressLabel:
+ return Addressee::homeAddressLabelLabel();
+ case FieldImpl::BusinessAddressStreet:
+ return Addressee::businessAddressStreetLabel();
+ case FieldImpl::BusinessAddressLocality:
+ return Addressee::businessAddressLocalityLabel();
+ case FieldImpl::BusinessAddressRegion:
+ return Addressee::businessAddressRegionLabel();
+ case FieldImpl::BusinessAddressPostalCode:
+ return Addressee::businessAddressPostalCodeLabel();
+ case FieldImpl::BusinessAddressCountry:
+ return Addressee::businessAddressCountryLabel();
+ case FieldImpl::BusinessAddressLabel:
+ return Addressee::businessAddressLabelLabel();
+ case FieldImpl::HomePhone:
+ return Addressee::homePhoneLabel();
+ case FieldImpl::BusinessPhone:
+ return Addressee::businessPhoneLabel();
+ case FieldImpl::MobilePhone:
+ return Addressee::mobilePhoneLabel();
+ case FieldImpl::HomeFax:
+ return Addressee::homeFaxLabel();
+ case FieldImpl::BusinessFax:
+ return Addressee::businessFaxLabel();
+ case FieldImpl::CarPhone:
+ return Addressee::carPhoneLabel();
+ case FieldImpl::Isdn:
+ return Addressee::isdnLabel();
+ case FieldImpl::Pager:
+ return Addressee::pagerLabel();
+ case FieldImpl::Email:
+ return Addressee::emailLabel();
+ case FieldImpl::Mailer:
+ return Addressee::mailerLabel();
+ case FieldImpl::Title:
+ return Addressee::titleLabel();
+ case FieldImpl::Role:
+ return Addressee::roleLabel();
+ case FieldImpl::Organization:
+ return Addressee::organizationLabel();
+ case FieldImpl::Note:
+ return Addressee::noteLabel();
+ case FieldImpl::Url:
+ return Addressee::urlLabel();
+ case FieldImpl::CustomField:
+ return mImpl->label();
+ default:
+ return i18n("Unknown Field");
+ }
+}
+
+int Field::category()
+{
+ return mImpl->category();
+}
+
+QString Field::categoryLabel( int category )
+{
+ switch ( category ) {
+ case All:
+ return i18n("All");
+ case Frequent:
+ return i18n("Frequent");
+ case Address:
+ return i18n("Address");
+ case Email:
+ return i18n("Email");
+ case Personal:
+ return i18n("Personal");
+ case Organization:
+ return i18n("Organization");
+ case CustomCategory:
+ return i18n("Custom");
+ default:
+ return i18n("Undefined");
+ }
+}
+
+QString Field::value( const KABC::Addressee &a )
+{
+ switch ( mImpl->fieldId() ) {
+ case FieldImpl::FormattedName:
+ return a.formattedName();
+ case FieldImpl::FamilyName:
+ return a.familyName();
+ case FieldImpl::GivenName:
+ return a.givenName();
+ case FieldImpl::AdditionalName:
+ return a.additionalName();
+ case FieldImpl::Prefix:
+ return a.prefix();
+ case FieldImpl::Suffix:
+ return a.suffix();
+ case FieldImpl::NickName:
+ return a.nickName();
+ case FieldImpl::Mailer:
+ return a.mailer();
+ case FieldImpl::Title:
+ return a.title();
+ case FieldImpl::Role:
+ return a.role();
+ case FieldImpl::Organization:
+ return a.organization();
+ case FieldImpl::Note:
+ return a.note();
+ case FieldImpl::Email:
+ return a.preferredEmail();
+ case FieldImpl::Birthday:
+ if ( a.birthday().isValid() ) {
+//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
+// But Qt::IsoDate was not specified.
+ QString _oldFormat = KGlobal::locale()->dateFormat();
+ KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
+ QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false);
+ KGlobal::locale()->setDateFormat(_oldFormat);
+ return dt;
+ }
+ else
+ return QString::null;
+ case FieldImpl::Url:
+ return a.url().prettyURL();
+ case FieldImpl::HomePhone:
+ return a.phoneNumber( PhoneNumber::Home ).number();
+ case FieldImpl::BusinessPhone:
+ return a.phoneNumber( PhoneNumber::Work ).number();
+ case FieldImpl::MobilePhone:
+ return a.phoneNumber( PhoneNumber::Cell ).number();
+ case FieldImpl::HomeFax:
+ return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
+ case FieldImpl::BusinessFax:
+ return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
+ case FieldImpl::CarPhone:
+ return a.phoneNumber( PhoneNumber::Car ).number();
+ case FieldImpl::Isdn:
+ return a.phoneNumber( PhoneNumber::Isdn ).number();
+ case FieldImpl::Pager:
+ return a.phoneNumber( PhoneNumber::Pager ).number();
+ case FieldImpl::HomeAddressStreet:
+ return a.address( Address::Home ).street();
+ case FieldImpl::HomeAddressLocality:
+ return a.address( Address::Home ).locality();
+ case FieldImpl::HomeAddressRegion:
+ return a.address( Address::Home ).region();
+ case FieldImpl::HomeAddressPostalCode:
+ return a.address( Address::Home ).postalCode();
+ case FieldImpl::HomeAddressCountry:
+ return a.address( Address::Home ).country();
+ case FieldImpl::BusinessAddressStreet:
+ return a.address( Address::Work ).street();
+ case FieldImpl::BusinessAddressLocality:
+ return a.address( Address::Work ).locality();
+ case FieldImpl::BusinessAddressRegion:
+ return a.address( Address::Work ).region();
+ case FieldImpl::BusinessAddressPostalCode:
+ return a.address( Address::Work ).postalCode();
+ case FieldImpl::BusinessAddressCountry:
+ return a.address( Address::Work ).country();
+ case FieldImpl::CustomField:
+ return a.custom( mImpl->app(), mImpl->key() );
+ default:
+ return QString::null;
+ }
+}
+
+bool Field::setValue( KABC::Addressee &a, const QString &value )
+{
+ switch ( mImpl->fieldId() ) {
+ case FieldImpl::FormattedName:
+ a.setFormattedName( value );
+ return true;
+ case FieldImpl::FamilyName:
+ a.setFamilyName( value );
+ return true;
+ case FieldImpl::GivenName:
+ a.setGivenName( value );
+ return true;
+ case FieldImpl::AdditionalName:
+ a.setAdditionalName( value );
+ return true;
+ case FieldImpl::Prefix:
+ a.setPrefix( value );
+ return true;
+ case FieldImpl::Suffix:
+ a.setSuffix( value );
+ return true;
+ case FieldImpl::NickName:
+ a.setNickName( value );
+ return true;
+ case FieldImpl::Mailer:
+ a.setMailer( value );
+ return true;
+ case FieldImpl::Title:
+ a.setTitle( value );
+ return true;
+ case FieldImpl::Role:
+ a.setRole( value );
+ return true;
+ case FieldImpl::Organization:
+ a.setOrganization( value );
+ return true;
+ case FieldImpl::Note:
+ a.setNote( value );
+ return true;
+ case FieldImpl::Birthday:
+//US
+//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
+// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
+ {
+ QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
+ a.setBirthday(dt);
+ }
+ return true;
+ case FieldImpl::CustomField:
+ a.insertCustom( mImpl->app(), mImpl->key(), value );
+ default:
+ return false;
+ }
+}
+
+bool Field::isCustom()
+{
+ return mImpl->fieldId() == FieldImpl::CustomField;
+}
+
+Field::List Field::allFields()
+{
+ if ( mAllFields.isEmpty() ) {
+ createField( FieldImpl::FormattedName, Frequent );
+ createField( FieldImpl::FamilyName, Frequent );
+ createField( FieldImpl::GivenName, Frequent );
+ createField( FieldImpl::AdditionalName );
+ createField( FieldImpl::Prefix );
+ createField( FieldImpl::Suffix );
+ createField( FieldImpl::NickName, Personal );
+ createField( FieldImpl::Birthday, Personal );
+ createField( FieldImpl::HomeAddressStreet, Address|Personal );
+ createField( FieldImpl::HomeAddressLocality, Address|Personal );
+ createField( FieldImpl::HomeAddressRegion, Address|Personal );
+ createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
+ createField( FieldImpl::HomeAddressCountry, Address|Personal );
+ createField( FieldImpl::HomeAddressLabel, Address|Personal );
+ createField( FieldImpl::BusinessAddressStreet, Address|Organization );
+ createField( FieldImpl::BusinessAddressLocality, Address|Organization );
+ createField( FieldImpl::BusinessAddressRegion, Address|Organization );
+ createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
+ createField( FieldImpl::BusinessAddressCountry, Address|Organization );
+ createField( FieldImpl::BusinessAddressLabel, Address|Organization );
+ createField( FieldImpl::HomePhone, Personal|Frequent );
+ createField( FieldImpl::BusinessPhone, Organization|Frequent );
+ createField( FieldImpl::MobilePhone, Frequent );
+ createField( FieldImpl::HomeFax );
+ createField( FieldImpl::BusinessFax );
+ createField( FieldImpl::CarPhone );
+ createField( FieldImpl::Isdn );
+ createField( FieldImpl::Pager );
+ createField( FieldImpl::Email, Email|Frequent );
+ createField( FieldImpl::Mailer, Email );
+ createField( FieldImpl::Title, Organization );
+ createField( FieldImpl::Role, Organization );
+ createField( FieldImpl::Organization, Organization );
+ createField( FieldImpl::Note );
+ createField( FieldImpl::Url );
+ }
+
+ return mAllFields;
+}
+
+Field::List Field::defaultFields()
+{
+ if ( mDefaultFields.isEmpty() ) {
+ createDefaultField( FieldImpl::GivenName );
+ createDefaultField( FieldImpl::FamilyName );
+ createDefaultField( FieldImpl::Email );
+ }
+
+ return mDefaultFields;
+}
+
+void Field::createField( int id, int category )
+{
+ mAllFields.append( new Field( new FieldImpl( id, category ) ) );
+}
+
+void Field::createDefaultField( int id, int category )
+{
+ mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
+}
+
+void Field::deleteFields()
+{
+ Field::List::ConstIterator it;
+
+ for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
+ delete (*it);
+ }
+ mAllFields.clear();
+
+ for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
+ delete (*it);
+ }
+ mDefaultFields.clear();
+
+ for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
+ delete (*it);
+ }
+ mCustomFields.clear();
+}
+
+void Field::saveFields( const QString &identifier,
+ const Field::List &fields )
+{
+ KConfig *cfg = KGlobal::config();
+ KConfigGroupSaver( cfg, "KABCFields" );
+ saveFields( cfg, identifier, fields );
+}
+
+void Field::saveFields( KConfig *cfg, const QString &identifier,
+ const Field::List &fields )
+{
+ QValueList<int> fieldIds;
+
+//US
+//US qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1());
+
+ int custom = 0;
+ Field::List::ConstIterator it;
+ for( it = fields.begin(); it != fields.end(); ++it ) {
+//US
+//US qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId());
+
+ fieldIds.append( (*it)->mImpl->fieldId() );
+ if( (*it)->isCustom() ) {
+ QStringList customEntry;
+ customEntry << (*it)->mImpl->label();
+ customEntry << (*it)->mImpl->key();
+ customEntry << (*it)->mImpl->app();
+ cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" +
+ QString::number( custom++ ), customEntry );
+ }
+ }
+ cfg->writeEntry( identifier, fieldIds );
+}
+
+Field::List Field::restoreFields( const QString &identifier )
+{
+ KConfig *cfg = KGlobal::config();
+ KConfigGroupSaver( cfg, "KABCFields" );
+ cfg->setGroup( "KABCFields" );
+
+ Field::List l = restoreFields( cfg, identifier );
+
+ return l;
+}
+
+Field::List Field::restoreFields( KConfig *cfg, const QString &identifier )
+{
+ QValueList<int> fieldIds = cfg->readIntListEntry( identifier);
+//US
+ qDebug("Field::restoreFields from %s", cfg->getFileName().latin1());
+
+ Field::List fields;
+
+ int custom = 0;
+ QValueList<int>::ConstIterator it;
+ for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
+ FieldImpl *f = 0;
+ if ( (*it) == FieldImpl::CustomField ) {
+ QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" +
+ identifier + "_" +
+ QString::number( custom++ ) );
+ f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ],
+ customEntry[ 1 ], customEntry[ 2 ] );
+ } else {
+ f = new FieldImpl( *it );
+ }
+ fields.append( new Field( f ) );
+ }
+
+ return fields;
+}
+
+bool Field::equals( Field *field )
+{
+ bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() );
+
+ if ( !sameId ) return false;
+
+ if ( mImpl->fieldId() != FieldImpl::CustomField ) return true;
+
+ return mImpl->key() == field->mImpl->key();
+}
+
+Field *Field::createCustomField( const QString &label, int category,
+ const QString &key, const QString &app )
+{
+ Field *field = new Field( new FieldImpl( FieldImpl::CustomField,
+ category | CustomCategory,
+ label, key, app ) );
+ mCustomFields.append( field );
+
+ return field;
+}
diff --git a/kabc/field.h b/kabc/field.h
new file mode 100644
index 0000000..9e06597
--- a/dev/null
+++ b/kabc/field.h
@@ -0,0 +1,178 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_FIELD_H
+#define KABC_FIELD_H
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+#include "addressee.h"
+
+class KConfig;
+
+namespace KABC {
+
+class Field
+{
+ class FieldImpl;
+ friend class FieldImpl;
+
+public:
+ typedef QValueList<Field *> List;
+
+ /**
+ * @li @p All -
+ * @li @p Frequent -
+ * @li @p Address -
+ * @li @p Email -
+ * @li @p Personal -
+ * @li @p Organization -
+ * @li @p CustomCategory -
+ */
+ enum FieldCategory
+ {
+ All = 0x0,
+ Frequent = 0x01,
+ Address = 0x02,
+ Email = 0x04,
+ Personal = 0x08,
+ Organization = 0x10,
+ CustomCategory = 0x20
+ };
+
+ /**
+ * Returns the translated label for this field.
+ */
+ virtual QString label();
+
+ /**
+ * Returns the ored categories the field belongs to.
+ */
+ virtual int category();
+
+ /**
+ * Returns the translated label for field category.
+ */
+ static QString categoryLabel( int category );
+
+ /**
+ * Returns a string representation of the value the field has in the given
+ * Addressee. Returns QString::null, if it is not possible to convert the
+ * value to a string.
+ */
+ virtual QString value( const KABC::Addressee & );
+
+ /**
+ * Sets the value of the field in the given Addressee. Returns true on success
+ * or false, if the given string couldn't be converted to a valid value.
+ */
+ virtual bool setValue( KABC::Addressee &, const QString & );
+
+ /**
+ * Returns, if the field is a user-defined field.
+ */
+ virtual bool isCustom();
+
+ /**
+ * Returns, if the field is equal with @param field.
+ */
+ virtual bool equals( Field *field );
+
+ /**
+ * Returns a list of all fields.
+ */
+ static Field::List allFields();
+
+ /**
+ * Returns a list of the default fields.
+ */
+ static Field::List defaultFields();
+
+ /**
+ * Creates a custom field.
+ *
+ * @param label The label for this field
+ * @param category The category of this field
+ * @param key Unique key for this field
+ * @param app Unique app name for this field
+ */
+ static Field *createCustomField( const QString &label, int category,
+ const QString &key, const QString &app );
+
+ /**
+ * Delete all fields from list.
+ */
+ static void deleteFields();
+
+ /**
+ * Save the field settings to a config file.
+ *
+ * @param cfg The config file object
+ * @param identifier The unique identifier
+ * @param fields The list of the fields
+ */
+ static void saveFields( KConfig *cfg, const QString &identifier,
+ const Field::List &fields );
+ /**
+ * This is the same as above, with the difference, that
+ * the list is stored in KGlobal::config() in group "KABCFields".
+ */
+ static void saveFields( const QString &identifier,
+ const Field::List &fields );
+
+ /**
+ * Load the field settings from a config file.
+ *
+ * @param cfg The config file object
+ * @param identifier The unique identifier
+ */
+ static Field::List restoreFields( KConfig *cfg, const QString &identifier );
+
+ /**
+ * This is the same as above, with the difference, that
+ * the list is loaded from KGlobal::config() from group "KABCFields".
+ */
+ static Field::List restoreFields( const QString &identifier );
+
+protected:
+ static void createField( int id, int category = 0 );
+ static void createDefaultField( int id, int category = 0 );
+
+private:
+ Field( FieldImpl * );
+ virtual ~Field();
+
+ FieldImpl *mImpl;
+
+ static Field::List mAllFields;
+ static Field::List mDefaultFields;
+ static Field::List mCustomFields;
+};
+
+}
+#endif
diff --git a/kabc/formatfactory.cpp b/kabc/formatfactory.cpp
new file mode 100644
index 0000000..2b073d7
--- a/dev/null
+++ b/kabc/formatfactory.cpp
@@ -0,0 +1,181 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <ksimpleconfig.h>
+#include <kstandarddirs.h>
+#include <kstaticdeleter.h>
+
+#include <qfile.h>
+#include <qstringlist.h>
+
+#include "vcardformatplugin.h"
+
+#include "formatfactory.h"
+
+using namespace KABC;
+
+FormatFactory *FormatFactory::mSelf = 0;
+static KStaticDeleter<FormatFactory> factoryDeleter;
+
+FormatFactory *FormatFactory::self()
+{
+ kdDebug(5700) << "FormatFactory::self()" << endl;
+
+ if ( !mSelf ) {
+#ifdef KAB_EMBEDDED
+ mSelf = factoryDeleter.setObject( new FormatFactory );
+#else //KAB_EMBEDDED
+ factoryDeleter.setObject( mSelf, new FormatFactory );
+#endif //KAB_EMBEDDED
+
+ }
+ return mSelf;
+}
+
+FormatFactory::FormatFactory()
+{
+ mFormatList.setAutoDelete( true );
+
+ // dummy entry for default format
+ FormatInfo *info = new FormatInfo;
+ info->library = "<NoLibrary>";
+ info->nameLabel = i18n( "vCard" );
+ info->descriptionLabel = i18n( "vCard Format" );
+ mFormatList.insert( "vcard", info );
+
+ QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true );
+ for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it )
+ {
+//US KSimpleConfig config( *it, true );
+ KConfig config( *it );
+
+ if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) )
+ continue;
+
+ info = new FormatInfo;
+
+ config.setGroup( "Plugin" );
+ QString type = config.readEntry( "Type" );
+ info->library = config.readEntry( "X-KDE-Library" );
+
+ config.setGroup( "Misc" );
+ info->nameLabel = config.readEntry( "Name" );
+ info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) );
+
+ mFormatList.insert( type, info );
+ }
+}
+
+FormatFactory::~FormatFactory()
+{
+ mFormatList.clear();
+}
+
+QStringList FormatFactory::formats()
+{
+ QStringList retval;
+
+ // make sure 'vcard' is the first entry
+ retval << "vcard";
+
+ QDictIterator<FormatInfo> it( mFormatList );
+ for ( ; it.current(); ++it )
+ if ( it.currentKey() != "vcard" )
+ retval << it.currentKey();
+
+ return retval;
+}
+
+FormatInfo *FormatFactory::info( const QString &type )
+{
+ if ( type.isEmpty() )
+ return 0;
+ else
+ return mFormatList[ type ];
+}
+
+FormatPlugin *FormatFactory::format( const QString& type )
+{
+ FormatPlugin *format = 0;
+
+ if ( type.isEmpty() )
+ return 0;
+
+ if ( type == "vcard" ) {
+ format = new VCardFormatPlugin;
+ /* // LR
+ format->setType( type );
+ format->setNameLabel( i18n( "vCard" ) );
+ format->setDescriptionLabel( i18n( "vCard Format" ) );
+ */
+ return format;
+ }
+
+ FormatInfo *fi = mFormatList[ type ];
+ if (!fi)
+ return 0;
+ QString libName = fi->library;
+#ifndef DESKTOP_VERSION
+ KLibrary *library = openLibrary( libName );
+ if ( !library )
+ return 0;
+
+ void *format_func = library->symbol( "format" );
+
+ if ( format_func ) {
+ format = ((FormatPlugin* (*)())format_func)();
+ // LR
+ /*
+ format->setType( type );
+ format->setNameLabel( fi->nameLabel );
+ format->setDescriptionLabel( fi->descriptionLabel );
+ */
+ } else {
+ kdDebug( 5700 ) << "'" << libName << "' is not a format plugin." << endl;
+ return 0;
+ }
+#endif
+ return format;
+}
+
+#ifndef DESKTOP_VERSION
+KLibrary *FormatFactory::openLibrary( const QString& libName )
+{
+ KLibrary *library = 0;
+
+ QString path = KLibLoader::findLibrary( QFile::encodeName( libName ) );
+
+ if ( path.isEmpty() ) {
+ kdDebug( 5700 ) << "No format plugin library was found!" << endl;
+ return 0;
+ }
+
+ library = KLibLoader::self()->library( QFile::encodeName( path ) );
+
+ if ( !library ) {
+ kdDebug( 5700 ) << "Could not load library '" << libName << "'" << endl;
+ return 0;
+ }
+
+ return library;
+}
+#endif
diff --git a/kabc/formatfactory.h b/kabc/formatfactory.h
new file mode 100644
index 0000000..9612374
--- a/dev/null
+++ b/kabc/formatfactory.h
@@ -0,0 +1,104 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_FORMATFACTORY_H
+#define KABC_FORMATFACTORY_H
+
+#include <qdict.h>
+#include <qstring.h>
+
+#include <kconfig.h>
+#ifndef DESKTOP_VERSION
+#include <klibloader.h>
+#endif
+
+#include "formatplugin.h"
+
+namespace KABC {
+
+struct FormatInfo
+{
+ QString library;
+ QString nameLabel;
+ QString descriptionLabel;
+};
+
+/**
+ * Class for loading format plugins.
+ *
+ * Example:
+ *
+ * <pre>
+ * KABC::FormatFactory *factory = KABC::FormatFactory::self();
+ *
+ * QStringList list = factory->formats();
+ * QStringList::Iterator it;
+ * for ( it = list.begin(); it != list.end(); ++it ) {
+ * KABC::FormatPlugin *format = factory->format( (*it) );
+ * // do something with format
+ * }
+ * </pre>
+ */
+class FormatFactory
+{
+ public:
+
+ /**
+ Destructor.
+ */
+ ~FormatFactory();
+
+ /**
+ * Returns the global format factory.
+ */
+ static FormatFactory *self();
+
+ /**
+ * Returns a pointer to a format object or a null pointer
+ * if format type doesn't exist.
+ *
+ * @param type The type of the format, returned by @ref formats()
+ */
+ FormatPlugin *format( const QString &type );
+
+ /**
+ * Returns a list of all available format types.
+ */
+ QStringList formats();
+
+ /**
+ * Returns the info structure for a special type.
+ */
+ FormatInfo *info( const QString &type );
+
+ protected:
+ FormatFactory();
+
+ private:
+#ifndef DESKTOP_VERSION
+ KLibrary *openLibrary( const QString& libName );
+#endif
+ static FormatFactory *mSelf;
+
+ QDict<FormatInfo> mFormatList;
+};
+
+}
+#endif
diff --git a/kabc/formatplugin.h b/kabc/formatplugin.h
new file mode 100644
index 0000000..d784daf
--- a/dev/null
+++ b/kabc/formatplugin.h
@@ -0,0 +1,81 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_FORMATPLUGIN_H
+#define KABC_FORMATPLUGIN_H
+
+#include <qfile.h>
+
+//US #include "plugin.h"
+#include "resource.h"
+
+namespace KABC {
+
+class AddressBook;
+class Addressee;
+
+/**
+ * @short Base class for address book formats.
+ *
+ * This class provides an abstract interface for ResourceFile and
+ * ResourceDir formats.
+ *
+ * @internal
+ */
+//US class FormatPlugin : public Plugin
+class FormatPlugin
+{
+public:
+
+ /**
+ * Load single addressee from file.
+ */
+ virtual bool load( Addressee &, QFile *file ) = 0;
+
+ /**
+ * Load whole addressbook from file.
+ */
+ virtual bool loadAll( AddressBook *, Resource *, QFile *file ) = 0;
+
+ /**
+ * Save a single Addressee to file.
+ */
+ virtual void save( const Addressee &, QFile *file ) = 0;
+
+ /**
+ * Save whole addressbook to file.
+ */
+ virtual void saveAll( AddressBook *, Resource *, QFile *file ) = 0;
+
+ /**
+ * Checks if given file contains the right format
+ */
+ virtual bool checkFormat( QFile *file ) const = 0;
+};
+
+}
+#endif
diff --git a/kabc/formats/binaryformat.cpp b/kabc/formats/binaryformat.cpp
new file mode 100644
index 0000000..e2f28b8
--- a/dev/null
+++ b/kabc/formats/binaryformat.cpp
@@ -0,0 +1,236 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+
+#include <qdatastream.h>
+#include <qimage.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+#include "addressbook.h"
+#include "addressee.h"
+#include "picture.h"
+#include "sound.h"
+
+#include "binaryformat.h"
+
+#define BINARY_FORMAT_VERSION 2
+
+using namespace KABC;
+
+/*US
+extern "C"
+{
+ FormatPlugin *format()
+ {
+ qDebug(" BinaryFormat::format = new BinaryFormat");
+ return new BinaryFormat;
+ }
+}
+*/
+bool BinaryFormat::load( Addressee &addressee, QFile *file )
+{
+ kdDebug(5700) << "BinaryFormat::load()" << endl;
+ QDataStream stream( file );
+
+ if ( !checkHeader( stream ) )
+ return false;
+
+ loadAddressee( addressee, stream );
+
+ return true;
+}
+
+bool BinaryFormat::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
+{
+ kdDebug(5700) << "BinaryFormat::loadAll()" << endl;
+
+ QDataStream stream( file );
+
+ if ( !checkHeader( stream ) )
+ return false;
+
+ Q_UINT32 entries;
+
+ stream >> entries;
+
+ for ( uint i = 0; i < entries; ++i ) {
+ Addressee addressee;
+ loadAddressee( addressee, stream );
+ addressee.setResource( resource );
+ addressBook->insertAddressee( addressee );
+ }
+
+ return true;
+}
+
+void BinaryFormat::save( const Addressee &addressee, QFile *file )
+{
+ kdDebug(5700) << "BinaryFormat::save()" << endl;
+
+ QDataStream stream( file );
+
+ writeHeader( stream );
+
+ Q_UINT32 entries = 1;
+ stream << entries;
+ saveAddressee( addressee, stream );
+}
+
+void BinaryFormat::saveAll( AddressBook *ab, Resource *resource, QFile *file )
+{
+ kdDebug(5700) << "BinaryFormat::saveAll()" << endl;
+
+ Q_UINT32 counter = 0;
+ QDataStream stream( file );
+
+ writeHeader( stream );
+ // set dummy number of entries
+ stream << counter;
+
+ AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it ) {
+ if ( (*it).resource() == resource ) {
+ saveAddressee( (*it), stream );
+ counter++;
+ (*it).setChanged( false );
+ }
+ }
+
+ // set real number of entries
+ stream.device()->at( 2 * sizeof( Q_UINT32 ) );
+ stream << counter;
+}
+
+bool BinaryFormat::checkFormat( QFile *file ) const
+{
+ kdDebug(5700) << "BinaryFormat::checkFormat()" << endl;
+
+ QDataStream stream( file );
+
+ return checkHeader( stream );
+}
+
+bool BinaryFormat::checkHeader( QDataStream &stream ) const
+{
+ Q_UINT32 magic, version;
+
+ stream >> magic >> version;
+
+//US QFile *file = dynamic_cast<QFile*>( stream.device() );
+ QFile *file = (QFile*)( stream.device() );
+
+ if ( !file ) {
+ qDebug("BinaryFormat::checkHeader : Not a file?");
+ kdError() << i18n("Not a file?") << endl;
+ return false;
+ }
+
+ if ( magic != 0x2e93e ) {
+ qDebug("BinaryFormat::checkHeader : File '%s' is not binary format.", file->name().latin1());
+ kdError() << i18n("File '%1' is not binary format.").arg( file->name() ) << endl;
+ return false;
+ }
+
+ if ( version != BINARY_FORMAT_VERSION ) {
+ qDebug("BinaryFormat::checkHeader : File '%s' is the wrong version.", file->name().latin1());
+ kdError() << i18n("File '%1' is the wrong version.").arg( file->name() ) << endl;
+ return false;
+ }
+
+ return true;
+}
+
+void BinaryFormat::writeHeader( QDataStream &stream )
+{
+ Q_UINT32 magic, version;
+
+ magic = 0x2e93e;
+ version = BINARY_FORMAT_VERSION;
+
+ stream << magic << version;
+}
+
+void BinaryFormat::loadAddressee( Addressee &addressee, QDataStream &stream )
+{
+ stream >> addressee;
+/*
+ // load pictures
+ Picture photo = addressee.photo();
+ Picture logo = addressee.logo();
+
+ if ( photo.isIntern() ) {
+ QImage img;
+ if ( !img.load( locateLocal( "data", "kabc/photos/" ) + addressee.uid() ) )
+ kdDebug(5700) << "No photo available for '" << addressee.uid() << "'." << endl;
+
+ addressee.setPhoto( img );
+ }
+
+ if ( logo.isIntern() ) {
+ QImage img;
+ if ( !img.load( locateLocal( "data", "kabc/logos/" ) + addressee.uid() ) )
+ kdDebug(5700) << "No logo available for '" << addressee.uid() << "'." << endl;
+
+ addressee.setLogo( img );
+ }
+
+ // load sound
+ // TODO: load sound data from file
+*/
+}
+
+void BinaryFormat::saveAddressee( const Addressee &addressee, QDataStream &stream )
+{
+ stream << addressee;
+/*
+ // load pictures
+ Picture photo = addressee.photo();
+ Picture logo = addressee.logo();
+
+ if ( photo.isIntern() ) {
+ QImage img = photo.data();
+ QString fileName = locateLocal( "data", "kabc/photos/" ) + addressee.uid();
+
+ if ( !img.save( fileName, "PNG" ) )
+ kdDebug(5700) << "Unable to save photo for '" << addressee.uid() << "'." << endl;
+ }
+
+ if ( logo.isIntern() ) {
+ QImage img = logo.data();
+ QString fileName = locateLocal( "data", "kabc/logos/" ) + addressee.uid();
+
+ if ( !img.save( fileName, "PNG" ) )
+ kdDebug(5700) << "Unable to save logo for '" << addressee.uid() << "'." << endl;
+ }
+
+ // save sound
+ // TODO: save the sound data to file
+*/
+}
diff --git a/kabc/formats/binaryformat.h b/kabc/formats/binaryformat.h
new file mode 100644
index 0000000..415fd3b
--- a/dev/null
+++ b/kabc/formats/binaryformat.h
@@ -0,0 +1,76 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_BINARYFORMAT_H
+#define KABC_BINARYFORMAT_H
+
+#include "formatplugin.h"
+
+namespace KABC {
+
+class AddressBook;
+class Addressee;
+
+/**
+ @short binary file format for addressbook entries.
+*/
+class BinaryFormat : public FormatPlugin
+{
+public:
+ /**
+ * Load single addressee from file.
+ */
+ bool load( Addressee &, QFile *file );
+
+ /**
+ * Load whole addressee from file.
+ */
+ bool loadAll( AddressBook *, Resource *, QFile *file );
+
+ /**
+ * Save single addressee to file.
+ */
+ void save( const Addressee &, QFile *file );
+
+ /**
+ * Save all addressees to file.
+ */
+ void saveAll( AddressBook *, Resource *, QFile *file );
+
+ /**
+ * Check for valid format of a file.
+ */
+ bool checkFormat( QFile *file ) const;
+
+private:
+ void loadAddressee( Addressee &, QDataStream & );
+ void saveAddressee( const Addressee &, QDataStream & );
+ bool checkHeader( QDataStream & ) const;
+ void writeHeader( QDataStream & );
+};
+
+}
+#endif
diff --git a/kabc/formats/vcardformatplugin2.cpp b/kabc/formats/vcardformatplugin2.cpp
new file mode 100644
index 0000000..2a772b4
--- a/dev/null
+++ b/kabc/formats/vcardformatplugin2.cpp
@@ -0,0 +1,123 @@
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include "vcardformatplugin2.h"
+
+#include "address.h"
+#include "addressee.h"
+#include "vcardparser/vcardtool.h"
+
+#include <qtextstream.h>
+#include <qfile.h>
+
+using namespace KABC;
+
+/*US
+extern "C"
+{
+ FormatPlugin *format()
+ {
+ qDebug(" VCardFormatPlugin2::format = new VCardFormatPlugin2");
+ return new VCardFormatPlugin2();
+ }
+}
+*/
+
+VCardFormatPlugin2::VCardFormatPlugin2()
+{
+}
+
+VCardFormatPlugin2::~VCardFormatPlugin2()
+{
+}
+
+bool VCardFormatPlugin2::load( Addressee &addressee, QFile *file )
+{
+ QString data;
+
+ QTextStream t( file );
+ t.setEncoding( QTextStream::UnicodeUTF8 );
+ data = t.read();
+
+ VCardTool tool;
+
+ Addressee::List l = tool.parseVCards( data );
+
+ if ( ! l.first().isEmpty() ) {
+ addressee = l.first();
+ return true;
+ }
+
+ return false;
+}
+
+bool VCardFormatPlugin2::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
+{
+ QString data;
+
+ QTextStream t( file );
+ t.setEncoding( QTextStream::UnicodeUTF8 );
+ data = t.read();
+
+ VCardTool tool;
+
+ Addressee::List l = tool.parseVCards( data );
+
+ Addressee::List::Iterator itr;
+
+ for ( itr = l.begin(); itr != l.end(); ++itr) {
+ Addressee addressee = *itr;
+ addressee.setResource( resource );
+ addressBook->insertAddressee( addressee );
+ }
+
+ return true;
+}
+
+void VCardFormatPlugin2::save( const Addressee &addressee, QFile *file )
+{
+ VCardTool tool;
+ Addressee::List vcardlist;
+
+
+ vcardlist.append( addressee );
+
+ QTextStream t( file );
+ t.setEncoding( QTextStream::UnicodeUTF8 );
+ t << tool.createVCards( vcardlist );
+}
+
+void VCardFormatPlugin2::saveAll( AddressBook *ab, Resource *resource, QFile *file )
+{
+ VCardTool tool;
+ Addressee::List vcardlist;
+
+ AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it ) {
+ if ( (*it).resource() == resource ) {
+ (*it).setChanged( false );
+ vcardlist.append( *it );
+ }
+ }
+
+ QTextStream t( file );
+ t.setEncoding( QTextStream::UnicodeUTF8 );
+ t << tool.createVCards( vcardlist );
+}
+
+bool VCardFormatPlugin2::checkFormat( QFile *file ) const
+{
+ QString line;
+
+ file->readLine( line, 1024 );
+ line = line.stripWhiteSpace();
+ if ( line == "BEGIN:VCARD" )
+ return true;
+ else
+ return false;
+}
+
diff --git a/kabc/formats/vcardformatplugin2.h b/kabc/formats/vcardformatplugin2.h
new file mode 100644
index 0000000..585ab6b
--- a/dev/null
+++ b/kabc/formats/vcardformatplugin2.h
@@ -0,0 +1,68 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Zack Rusin <zack@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef VCARDFORMATPLUGIN2_H
+#define VCARDFORMATPLUGIN2_H
+
+#include "formatplugin.h"
+#include "addressee.h"
+
+class QFile;
+
+namespace KABC {
+
+ class Resource;
+ class AddressBook;
+ /**
+ @short Interface of vCard backend for address book.
+
+ This class implements the file format interface of address book entries for
+ the vCard format.
+ */
+ class VCardFormatPlugin2 : public FormatPlugin
+ {
+ public:
+ VCardFormatPlugin2();
+ virtual ~VCardFormatPlugin2();
+
+ bool load( Addressee &, QFile *file );
+ bool loadAll( AddressBook *, Resource *, QFile *file );
+ void save( const Addressee &, QFile *file );
+ void saveAll( AddressBook *, Resource *, QFile *file );
+
+ bool checkFormat( QFile *file ) const;
+
+ private:
+ struct VCardFormatPrivate;
+ VCardFormatPrivate *d;
+ };
+
+
+}
+
+
+#endif
diff --git a/kabc/geo.cpp b/kabc/geo.cpp
new file mode 100644
index 0000000..33597b7
--- a/dev/null
+++ b/kabc/geo.cpp
@@ -0,0 +1,116 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qdatastream.h>
+
+#include "geo.h"
+
+using namespace KABC;
+
+Geo::Geo()
+ : mLatitude( 91 ), mLongitude( 181 ), mValidLat( false ), mValidLong( false )
+{
+}
+
+Geo::Geo( float latitude, float longitude )
+{
+ setLatitude( latitude );
+ setLongitude( longitude );
+}
+
+void Geo::setLatitude( float latitude )
+{
+ if ( latitude >= -90 && latitude <= 90 ) {
+ mLatitude = latitude;
+ mValidLat = true;
+ } else {
+ mLatitude = 91;
+ mValidLat = false;
+ }
+}
+
+float Geo::latitude() const
+{
+ return mLatitude;
+}
+
+void Geo::setLongitude( float longitude)
+{
+ if ( longitude >= -180 && longitude <= 180 ) {
+ mLongitude = longitude;
+ mValidLong = true;
+ } else {
+ mLongitude = 181;
+ mValidLong = false;
+ }
+}
+
+float Geo::longitude() const
+{
+ return mLongitude;
+}
+
+bool Geo::isValid() const
+{
+ return mValidLat && mValidLong;
+}
+
+bool Geo::operator==( const Geo &g ) const
+{
+ if ( !g.isValid() && !isValid() ) return true;
+ if ( !g.isValid() || !isValid() ) return false;
+ if ( g.mLatitude == mLatitude && g.mLongitude == mLongitude ) return true;
+ return false;
+}
+
+bool Geo::operator!=( const Geo &g ) const
+{
+ if ( !g.isValid() && !isValid() ) return false;
+ if ( !g.isValid() || !isValid() ) return true;
+ if ( g.mLatitude == mLatitude && g.mLongitude == mLongitude ) return false;
+ return true;
+}
+
+QString Geo::asString() const
+{
+ return "(" + QString::number(mLatitude) + "," + QString::number(mLongitude) + ")";
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Geo &geo )
+{
+ return s << (float)geo.mLatitude << (float)geo.mLongitude;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Geo &geo )
+{
+ s >> geo.mLatitude >> geo.mLongitude;
+
+ geo.mValidLat = true;
+ geo.mValidLong = true;
+
+ return s;
+}
diff --git a/kabc/geo.h b/kabc/geo.h
new file mode 100644
index 0000000..4c7f90f
--- a/dev/null
+++ b/kabc/geo.h
@@ -0,0 +1,106 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_GEO_H
+#define KABC_GEO_H
+
+#include <qstring.h>
+
+namespace KABC {
+
+/**
+ @short Geographic position
+
+ This class represents a geographic position.
+*/
+class Geo
+{
+ friend QDataStream &operator<<( QDataStream &, const Geo & );
+ friend QDataStream &operator>>( QDataStream &, Geo & );
+
+ public:
+ /**
+ Construct invalid geographics position object.
+ */
+ Geo();
+
+ /**
+ Construct geographics position object.
+
+ @param latitude Geographical latitude
+ @param longitude Geographical longitude
+ */
+ Geo( float latitude, float longitude );
+
+ /**
+ Sets the latitude.
+ */
+ void setLatitude( float );
+
+ /**
+ Returns the latitude.
+ */
+ float latitude() const;
+
+ /**
+ Sets the longitude.
+ */
+ void setLongitude( float );
+
+ /**
+ Returns the longitude.
+ */
+ float longitude() const;
+
+ /**
+ Returns, if this object contains a valid geographical position.
+ */
+ bool isValid() const;
+
+ bool operator==( const Geo & ) const;
+ bool operator!=( const Geo & ) const;
+
+ /**
+ Returns string representation of geographical position.
+ */
+ QString asString() const;
+
+ private:
+ float mLatitude;
+ float mLongitude;
+
+ bool mValid;
+ bool mValidLat;
+ bool mValidLong;
+};
+
+QDataStream &operator<<( QDataStream &, const Geo & );
+QDataStream &operator>>( QDataStream &, Geo & );
+
+}
+
+#endif
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
new file mode 100644
index 0000000..ea4bbb7
--- a/dev/null
+++ b/kabc/kabc.pro
@@ -0,0 +1,214 @@
+TEMPLATE = lib
+CONFIG += qt warn_on
+#release debug
+DESTDIR=../bin
+
+TARGET = microkabc
+
+include( ../variables.pri )
+
+INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../qtcompat ../microkde/kdeui
+
+#LIBS += -lmicrokde -lldap
+LIBS += -L$(QPEDIR)/lib
+DEFINES += KAB_EMBEDDED DESKTOP_VERSION
+unix : {
+
+OBJECTS_DIR = obj/unix
+MOC_DIR = moc/unix
+}
+win32: {
+DEFINES += _WIN32_
+OBJECTS_DIR = obj/win
+MOC_DIR = moc/win
+}
+INTERFACES = \
+
+
+HEADERS = \
+ resource.h \
+ stdaddressbook.h \
+ agent.h \
+ geo.h \
+ key.h \
+ field.h \
+ plugin.h \
+ address.h \
+ addresseelist.h \
+formatfactory.h \
+ formatplugin.h \
+ phonenumber.h \
+distributionlist.h \
+distributionlistdialog.h \
+distributionlisteditor.h \
+vcardformatplugin.h \
+formats/binaryformat.h \
+formats/vcardformatplugin2.h \
+ picture.h \
+ secrecy.h \
+ sound.h \
+ addressbook.h \
+ timezone.h \
+ addressee.h \
+ addresseedialog.h \
+ vcardconverter.h \
+ vcard21parser.h \
+ vcardformatimpl.h \
+ plugins/file/resourcefile.h \
+ plugins/file/resourcefileconfig.h \
+ plugins/dir/resourcedir.h \
+ plugins/dir/resourcedirconfig.h \
+ vcardparser/vcardline.h \
+ vcardparser/vcard.h \
+ vcardparser/vcardtool.h \
+ vcardparser/vcardparser.h \
+vcard/include/VCardAdrParam.h \
+vcard/include/VCardAdrValue.h \
+vcard/include/VCardAgentParam.h \
+vcard/include/VCardContentLine.h \
+vcard/include/VCardDateParam.h \
+vcard/include/VCardDateValue.h \
+vcard/include/VCardEmailParam.h \
+vcard/include/VCardGeoValue.h \
+vcard/include/VCardGroup.h \
+vcard/include/VCardImageParam.h \
+vcard/include/VCardImageValue.h \
+vcard/include/VCardLangValue.h \
+vcard/include/VCardNValue.h \
+vcard/include/VCardParam.h \
+vcard/include/VCardPhoneNumberValue.h \
+vcard/include/VCardSourceParam.h \
+vcard/include/VCardTelParam.h \
+vcard/include/VCardTextParam.h \
+vcard/include/VCardTextNSParam.h \
+vcard/include/VCardTextValue.h \
+vcard/include/VCardTextBinParam.h \
+vcard/include/VCardURIValue.h \
+vcard/include/VCardVCard.h \
+vcard/include/VCardEntity.h \
+vcard/include/VCardValue.h \
+vcard/include/VCardSoundValue.h \
+vcard/include/VCardAgentValue.h \
+vcard/include/VCardTelValue.h \
+vcard/include/VCardTextBinValue.h \
+vcard/include/VCardOrgValue.h \
+vcard/include/VCardUTCValue.h \
+vcard/include/VCardClassValue.h \
+vcard/include/VCardFloatValue.h \
+vcard/include/VCardTextListValue.h \
+vcard/include/generated/AdrParam-generated.h \
+vcard/include/generated/AdrValue-generated.h \
+vcard/include/generated/AgentParam-generated.h \
+vcard/include/generated/ContentLine-generated.h \
+vcard/include/generated/DateParam-generated.h \
+vcard/include/generated/DateValue-generated.h \
+vcard/include/generated/EmailParam-generated.h \
+vcard/include/generated/GeoValue-generated.h \
+vcard/include/generated/Group-generated.h \
+vcard/include/generated/ImageParam-generated.h \
+vcard/include/generated/ImageValue-generated.h \
+vcard/include/generated/LangValue-generated.h \
+vcard/include/generated/NValue-generated.h \
+vcard/include/generated/Param-generated.h \
+vcard/include/generated/PhoneNumberValue-generated.h \
+vcard/include/generated/SourceParam-generated.h \
+vcard/include/generated/TelParam-generated.h \
+vcard/include/generated/TextParam-generated.h \
+vcard/include/generated/TextNSParam-generated.h \
+vcard/include/generated/TextValue-generated.h \
+vcard/include/generated/TextBinParam-generated.h \
+vcard/include/generated/URIValue-generated.h \
+vcard/include/generated/VCard-generated.h \
+vcard/include/generated/VCardEntity-generated.h \
+vcard/include/generated/Value-generated.h \
+vcard/include/generated/SoundValue-generated.h \
+vcard/include/generated/AgentValue-generated.h \
+vcard/include/generated/TelValue-generated.h \
+vcard/include/generated/TextBinValue-generated.h \
+vcard/include/generated/OrgValue-generated.h \
+vcard/include/generated/UTCValue-generated.h \
+vcard/include/generated/ClassValue-generated.h \
+vcard/include/generated/FloatValue-generated.h \
+vcard/include/generated/TextListValue-generated.h
+
+
+# plugins/ldap/resourceldap.h \
+# plugins/ldap/resourceldapconfig.h \
+
+
+SOURCES = \
+distributionlist.cpp \
+distributionlistdialog.cpp \
+distributionlisteditor.cpp \
+vcardformatplugin.cpp \
+formats/binaryformat.cpp \
+formats/vcardformatplugin2.cpp \
+formatfactory.cpp \
+ resource.cpp \
+ stdaddressbook.cpp \
+ plugin.cpp \
+ agent.cpp \
+ geo.cpp \
+ key.cpp \
+ field.cpp \
+ address.cpp \
+ phonenumber.cpp \
+ picture.cpp \
+ secrecy.cpp \
+ sound.cpp \
+ addressbook.cpp \
+ timezone.cpp \
+ addressee.cpp \
+ addresseelist.cpp \
+ addresseedialog.cpp \
+ vcardconverter.cpp \
+ vcard21parser.cpp \
+ vcardformatimpl.cpp \
+ plugins/file/resourcefile.cpp \
+ plugins/file/resourcefileconfig.cpp \
+ plugins/dir/resourcedir.cpp \
+ plugins/dir/resourcedirconfig.cpp \
+ vcardparser/vcardline.cpp \
+ vcardparser/vcard.cpp \
+ vcardparser/vcardtool.cpp \
+ vcardparser/vcardparser.cpp \
+vcard/AdrParam.cpp \
+vcard/AdrValue.cpp \
+vcard/AgentParam.cpp \
+vcard/ContentLine.cpp \
+vcard/DateParam.cpp \
+vcard/DateValue.cpp \
+vcard/EmailParam.cpp \
+vcard/Entity.cpp \
+vcard/Enum.cpp \
+vcard/GeoValue.cpp \
+vcard/ImageParam.cpp \
+vcard/ImageValue.cpp \
+vcard/LangValue.cpp \
+vcard/NValue.cpp \
+vcard/Param.cpp \
+vcard/PhoneNumberValue.cpp \
+vcard/RToken.cpp \
+vcard/SourceParam.cpp \
+vcard/TelParam.cpp \
+vcard/TextParam.cpp \
+vcard/TextValue.cpp \
+vcard/TextBinParam.cpp \
+vcard/URIValue.cpp \
+vcard/VCardv.cpp \
+vcard/VCardEntity.cpp \
+vcard/Value.cpp \
+vcard/SoundValue.cpp \
+vcard/AgentValue.cpp \
+vcard/TelValue.cpp \
+vcard/TextBinValue.cpp \
+vcard/OrgValue.cpp \
+vcard/UTCValue.cpp \
+vcard/ClassValue.cpp \
+vcard/FloatValue.cpp \
+vcard/TextListValue.cpp
+
+
+# plugins/ldap/resourceldap.cpp \
+# plugins/ldap/resourceldapconfig.cpp \
+
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro
new file mode 100644
index 0000000..6c37beb
--- a/dev/null
+++ b/kabc/kabcE.pro
@@ -0,0 +1,202 @@
+TEMPLATE = lib
+CONFIG += qt warn_on
+TARGET = microkabc
+
+
+INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../qtcompat
+OBJECTS_DIR = obj/$(PLATFORM)
+MOC_DIR = moc/$(PLATFORM)
+DESTDIR = $(QPEDIR)/lib
+LIBS += -lmicrokde
+#LIBS += -lldap
+LIBS += -L$(QPEDIR)/lib
+DEFINES += KAB_EMBEDDED
+
+INTERFACES = \
+
+HEADERS = \
+ resource.h \
+ stdaddressbook.h \
+ agent.h \
+ geo.h \
+ key.h \
+ field.h \
+ plugin.h \
+ address.h \
+ addresseelist.h \
+formatfactory.h \
+ formatplugin.h \
+ phonenumber.h \
+distributionlist.h \
+distributionlistdialog.h \
+distributionlisteditor.h \
+vcardformatplugin.h \
+formats/binaryformat.h \
+formats/vcardformatplugin2.h \
+ picture.h \
+ secrecy.h \
+ sound.h \
+ addressbook.h \
+ timezone.h \
+ addressee.h \
+ addresseedialog.h \
+ vcardconverter.h \
+ vcard21parser.h \
+ vcardformatimpl.h \
+ plugins/file/resourcefile.h \
+ plugins/file/resourcefileconfig.h \
+ plugins/dir/resourcedir.h \
+ plugins/dir/resourcedirconfig.h \
+ vcardparser/vcardline.h \
+ vcardparser/vcard.h \
+ vcardparser/vcardtool.h \
+ vcardparser/vcardparser.h \
+vcard/include/VCardAdrParam.h \
+vcard/include/VCardAdrValue.h \
+vcard/include/VCardAgentParam.h \
+vcard/include/VCardContentLine.h \
+vcard/include/VCardDateParam.h \
+vcard/include/VCardDateValue.h \
+vcard/include/VCardEmailParam.h \
+vcard/include/VCardGeoValue.h \
+vcard/include/VCardGroup.h \
+vcard/include/VCardImageParam.h \
+vcard/include/VCardImageValue.h \
+vcard/include/VCardLangValue.h \
+vcard/include/VCardNValue.h \
+vcard/include/VCardParam.h \
+vcard/include/VCardPhoneNumberValue.h \
+vcard/include/VCardSourceParam.h \
+vcard/include/VCardTelParam.h \
+vcard/include/VCardTextParam.h \
+vcard/include/VCardTextNSParam.h \
+vcard/include/VCardTextValue.h \
+vcard/include/VCardTextBinParam.h \
+vcard/include/VCardURIValue.h \
+vcard/include/VCardVCard.h \
+vcard/include/VCardEntity.h \
+vcard/include/VCardValue.h \
+vcard/include/VCardSoundValue.h \
+vcard/include/VCardAgentValue.h \
+vcard/include/VCardTelValue.h \
+vcard/include/VCardTextBinValue.h \
+vcard/include/VCardOrgValue.h \
+vcard/include/VCardUTCValue.h \
+vcard/include/VCardClassValue.h \
+vcard/include/VCardFloatValue.h \
+vcard/include/VCardTextListValue.h \
+vcard/include/generated/AdrParam-generated.h \
+vcard/include/generated/AdrValue-generated.h \
+vcard/include/generated/AgentParam-generated.h \
+vcard/include/generated/ContentLine-generated.h \
+vcard/include/generated/DateParam-generated.h \
+vcard/include/generated/DateValue-generated.h \
+vcard/include/generated/EmailParam-generated.h \
+vcard/include/generated/GeoValue-generated.h \
+vcard/include/generated/Group-generated.h \
+vcard/include/generated/ImageParam-generated.h \
+vcard/include/generated/ImageValue-generated.h \
+vcard/include/generated/LangValue-generated.h \
+vcard/include/generated/NValue-generated.h \
+vcard/include/generated/Param-generated.h \
+vcard/include/generated/PhoneNumberValue-generated.h \
+vcard/include/generated/SourceParam-generated.h \
+vcard/include/generated/TelParam-generated.h \
+vcard/include/generated/TextParam-generated.h \
+vcard/include/generated/TextNSParam-generated.h \
+vcard/include/generated/TextValue-generated.h \
+vcard/include/generated/TextBinParam-generated.h \
+vcard/include/generated/URIValue-generated.h \
+vcard/include/generated/VCard-generated.h \
+vcard/include/generated/VCardEntity-generated.h \
+vcard/include/generated/Value-generated.h \
+vcard/include/generated/SoundValue-generated.h \
+vcard/include/generated/AgentValue-generated.h \
+vcard/include/generated/TelValue-generated.h \
+vcard/include/generated/TextBinValue-generated.h \
+vcard/include/generated/OrgValue-generated.h \
+vcard/include/generated/UTCValue-generated.h \
+vcard/include/generated/ClassValue-generated.h \
+vcard/include/generated/FloatValue-generated.h \
+vcard/include/generated/TextListValue-generated.h
+
+
+# plugins/ldap/resourceldap.h \
+# plugins/ldap/resourceldapconfig.h \
+
+
+SOURCES = \
+distributionlist.cpp \
+distributionlistdialog.cpp \
+distributionlisteditor.cpp \
+vcardformatplugin.cpp \
+formats/binaryformat.cpp \
+formats/vcardformatplugin2.cpp \
+formatfactory.cpp \
+ resource.cpp \
+ stdaddressbook.cpp \
+ plugin.cpp \
+ agent.cpp \
+ geo.cpp \
+ key.cpp \
+ field.cpp \
+ address.cpp \
+ phonenumber.cpp \
+ picture.cpp \
+ secrecy.cpp \
+ sound.cpp \
+ addressbook.cpp \
+ timezone.cpp \
+ addressee.cpp \
+ addresseelist.cpp \
+ addresseedialog.cpp \
+ vcardconverter.cpp \
+ vcard21parser.cpp \
+ vcardformatimpl.cpp \
+ plugins/file/resourcefile.cpp \
+ plugins/file/resourcefileconfig.cpp \
+ plugins/dir/resourcedir.cpp \
+ plugins/dir/resourcedirconfig.cpp \
+ vcardparser/vcardline.cpp \
+ vcardparser/vcard.cpp \
+ vcardparser/vcardtool.cpp \
+ vcardparser/vcardparser.cpp \
+vcard/AdrParam.cpp \
+vcard/AdrValue.cpp \
+vcard/AgentParam.cpp \
+vcard/ContentLine.cpp \
+vcard/DateParam.cpp \
+vcard/DateValue.cpp \
+vcard/EmailParam.cpp \
+vcard/Entity.cpp \
+vcard/Enum.cpp \
+vcard/GeoValue.cpp \
+vcard/ImageParam.cpp \
+vcard/ImageValue.cpp \
+vcard/LangValue.cpp \
+vcard/NValue.cpp \
+vcard/Param.cpp \
+vcard/PhoneNumberValue.cpp \
+vcard/RToken.cpp \
+vcard/SourceParam.cpp \
+vcard/TelParam.cpp \
+vcard/TextParam.cpp \
+vcard/TextValue.cpp \
+vcard/TextBinParam.cpp \
+vcard/URIValue.cpp \
+vcard/VCardv.cpp \
+vcard/VCardEntity.cpp \
+vcard/Value.cpp \
+vcard/SoundValue.cpp \
+vcard/AgentValue.cpp \
+vcard/TelValue.cpp \
+vcard/TextBinValue.cpp \
+vcard/OrgValue.cpp \
+vcard/UTCValue.cpp \
+vcard/ClassValue.cpp \
+vcard/FloatValue.cpp \
+vcard/TextListValue.cpp
+
+
+# plugins/ldap/resourceldap.cpp \
+# plugins/ldap/resourceldapconfig.cpp \
diff --git a/kabc/key.cpp b/kabc/key.cpp
new file mode 100644
index 0000000..802424b
--- a/dev/null
+++ b/kabc/key.cpp
@@ -0,0 +1,160 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <kapplication.h>
+#include <klocale.h>
+
+#include "key.h"
+
+using namespace KABC;
+
+Key::Key( const QString &text, int type )
+ : mTextData( text ), mIsBinary( false ), mType( type )
+{
+ mId = KApplication::randomString(8);
+}
+
+Key::~Key()
+{
+}
+
+bool Key::operator==( const Key &k ) const
+{
+ if ( mIsBinary != k.mIsBinary ) return false;
+ if ( mIsBinary )
+ if ( mBinaryData != k.mBinaryData ) return false;
+ else
+ if ( mTextData != k.mTextData ) return false;
+ if ( mType != k.mType ) return false;
+ if ( mCustomTypeString != k.mCustomTypeString ) return false;
+
+ return true;
+}
+
+bool Key::operator!=( const Key &k ) const
+{
+ return !( k == *this );
+}
+
+void Key::setId( const QString &id )
+{
+ mId = id;
+}
+
+QString Key::id() const
+{
+ return mId;
+}
+
+void Key::setBinaryData( const QByteArray &binary )
+{
+ mBinaryData = binary;
+ mIsBinary = true;
+}
+
+QByteArray Key::binaryData() const
+{
+ return mBinaryData;
+}
+
+void Key::setTextData( const QString &text )
+{
+ mTextData = text;
+ mIsBinary = false;
+}
+
+QString Key::textData() const
+{
+ return mTextData;
+}
+
+bool Key::isBinary() const
+{
+ return mIsBinary;
+}
+
+void Key::setType( int type )
+{
+ mType = type;
+}
+
+void Key::setCustomTypeString( const QString &custom )
+{
+ mCustomTypeString = custom;
+}
+
+int Key::type() const
+{
+ return mType;
+}
+
+QString Key::customTypeString() const
+{
+ return mCustomTypeString;
+}
+
+Key::TypeList Key::typeList()
+{
+ TypeList list;
+ list << X509;
+ list << PGP;
+ list << Custom;
+
+ return list;
+}
+
+QString Key::typeLabel( int type )
+{
+ switch ( type ) {
+ case X509:
+ return i18n( "X509" );
+ break;
+ case PGP:
+ return i18n( "PGP" );
+ break;
+ case Custom:
+ return i18n( "Custom" );
+ break;
+ default:
+ return i18n( "Unknown type" );
+ break;
+ }
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Key &key )
+{
+ return s << key.mId << key.mIsBinary << key.mTextData << key.mBinaryData <<
+ key.mCustomTypeString << key.mType;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Key &key )
+{
+ s >> key.mId >> key.mIsBinary >> key.mTextData >> key.mBinaryData >>
+ key.mCustomTypeString >> key.mType;
+
+ return s;
+}
diff --git a/kabc/key.h b/kabc/key.h
new file mode 100644
index 0000000..6ea5b47
--- a/dev/null
+++ b/kabc/key.h
@@ -0,0 +1,155 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_KEY_H
+#define KABC_KEY_H
+
+#include <qvaluelist.h>
+
+namespace KABC {
+
+/**
+ * @short A class to store an encryption key.
+ */
+class Key
+{
+ friend QDataStream &operator<<( QDataStream &, const Key & );
+ friend QDataStream &operator>>( QDataStream &, Key & );
+
+public:
+ typedef QValueList<Key> List;
+ typedef QValueList<int> TypeList;
+
+ /**
+ * Key types
+ *
+ * @li X509 - X509 key
+ * @li PGP - Pretty Good Privacy key
+ * @li Custom - Custom or IANA conform key
+ */
+ enum Types {
+ X509,
+ PGP,
+ Custom
+ };
+
+ /**
+ * Constructor.
+ *
+ * @param text The text data.
+ * @param type The key type, @see Types.
+ */
+ Key( const QString &text = QString::null, int type = PGP );
+
+ /**
+ * Destructor.
+ */
+ ~Key();
+
+ bool operator==( const Key & ) const;
+ bool operator!=( const Key & ) const;
+
+ /**
+ * Sets the unique identifier.
+ */
+ void setId( const QString &id );
+
+ /**
+ * Returns the unique identifier.
+ */
+ QString id() const;
+
+ /**
+ * Sets binary data.
+ */
+ void setBinaryData( const QByteArray &binary );
+
+ /**
+ * Returns the binary data.
+ */
+ QByteArray binaryData() const;
+
+ /**
+ * Sets text data.
+ */
+ void setTextData( const QString &text );
+
+ /**
+ * Returns the text data.
+ */
+ QString textData() const;
+
+ /**
+ * Returns whether the key contains binary or text data.
+ */
+ bool isBinary() const;
+
+ /**
+ * Sets the type, @see Type.
+ */
+ void setType( int type );
+
+ /**
+ * Sets custom type string.
+ */
+ void setCustomTypeString( const QString &custom );
+
+ /**
+ * Returns the type, @see Type.
+ */
+ int type() const;
+
+ /**
+ * Returns the custom type string.
+ */
+ QString customTypeString() const;
+
+ /**
+ * Returns a list of all available key types.
+ */
+ static TypeList typeList();
+
+ /**
+ * Returns a translated label for a given key type.
+ */
+ static QString typeLabel( int type );
+
+private:
+ QByteArray mBinaryData;
+ QString mId;
+ QString mTextData;
+ QString mCustomTypeString;
+
+ int mIsBinary;
+ int mType;
+};
+
+QDataStream &operator<<( QDataStream &, const Key & );
+QDataStream &operator>>( QDataStream &, Key & );
+
+}
+#endif
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
new file mode 100644
index 0000000..ad3e65b
--- a/dev/null
+++ b/kabc/phonenumber.cpp
@@ -0,0 +1,204 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <kapplication.h>
+#include <klocale.h>
+
+#include "phonenumber.h"
+
+using namespace KABC;
+
+PhoneNumber::PhoneNumber() :
+ mType( Home )
+{
+ init();
+}
+
+PhoneNumber::PhoneNumber( const QString &number, int type ) :
+ mType( type ), mNumber( number )
+{
+ init();
+}
+
+PhoneNumber::~PhoneNumber()
+{
+}
+
+void PhoneNumber::init()
+{
+ mId = KApplication::randomString( 8 );
+}
+
+bool PhoneNumber::operator==( const PhoneNumber &p ) const
+{
+ if ( mNumber != p.mNumber ) return false;
+ if ( mType != p.mType ) return false;
+
+ return true;
+}
+
+bool PhoneNumber::operator!=( const PhoneNumber &p ) const
+{
+ return !( p == *this );
+}
+
+void PhoneNumber::setId( const QString &id )
+{
+ mId = id;
+}
+
+QString PhoneNumber::id() const
+{
+ return mId;
+}
+
+void PhoneNumber::setNumber( const QString &number )
+{
+ mNumber = number;
+}
+
+QString PhoneNumber::number() const
+{
+ return mNumber;
+}
+
+void PhoneNumber::setType( int type )
+{
+ mType = type;
+}
+
+int PhoneNumber::type() const
+{
+ return mType;
+}
+
+QString PhoneNumber::typeLabel() const
+{
+ QString label;
+ bool first = true;
+
+ TypeList list = typeList();
+
+ TypeList::Iterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
+ label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
+ if ( first )
+ first = false;
+ }
+ }
+
+ return label;
+}
+
+QString PhoneNumber::label() const
+{
+ return typeLabel( type() );
+}
+
+PhoneNumber::TypeList PhoneNumber::typeList()
+{
+ TypeList list;
+
+ list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
+ << Bbs << Modem << Car << Isdn << Pcs << Pager;
+
+ return list;
+}
+
+QString PhoneNumber::label( int type )
+{
+ return typeLabel( type );
+}
+
+QString PhoneNumber::typeLabel( int type )
+{
+ switch ( type ) {
+ case Home:
+ return i18n("Home phone", "Home");
+ break;
+ case Work:
+ return i18n("Work phone", "Work");
+ break;
+ case Msg:
+ return i18n("Messenger");
+ break;
+ case Pref:
+ return i18n("Preferred Number");
+ break;
+ case Voice:
+ return i18n("Voice");
+ break;
+ case Fax:
+ return i18n("Fax");
+ break;
+ case Cell:
+ return i18n("Mobile Phone", "Mobile" );
+ break;
+ case Video:
+ return i18n("Video");
+ break;
+ case Bbs:
+ return i18n("Mailbox");
+ break;
+ case Modem:
+ return i18n("Modem");
+ break;
+ case Car:
+ return i18n("Car Phone", "Car" );
+ break;
+ case Isdn:
+ return i18n("ISDN");
+ break;
+ case Pcs:
+ return i18n("PCS");
+ break;
+ case Pager:
+ return i18n("Pager");
+ break;
+ case Home | Fax:
+ return i18n("Home Fax");
+ break;
+ case Work | Fax:
+ return i18n("Work Fax");
+ break;
+ default:
+ return i18n("Other");
+ }
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
+{
+ return s << phone.mId << phone.mType << phone.mNumber;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
+{
+ s >> phone.mId >> phone.mType >> phone.mNumber;
+
+ return s;
+}
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h
new file mode 100644
index 0000000..6a9c8cb
--- a/dev/null
+++ b/kabc/phonenumber.h
@@ -0,0 +1,165 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_PHONENUMBER_H
+#define KABC_PHONENUMBER_H
+
+#include <qvaluelist.h>
+#include <qstring.h>
+
+namespace KABC {
+
+/**
+ @short Phonenumber information.
+
+ This class provides phone number information. A phone number is classified by
+ a type. The following types are available, it's possible to use multiple types
+ @ref Types for a number by combining them through a logical or.
+*/
+class PhoneNumber
+{
+ friend QDataStream &operator<<( QDataStream &, const PhoneNumber & );
+ friend QDataStream &operator>>( QDataStream &, PhoneNumber & );
+
+ public:
+ typedef QValueList<PhoneNumber> List;
+ typedef QValueList<int> TypeList;
+
+ /**
+ @li @p Home - Home number
+ @li @p Work - Office number
+ @li @p Msg - Messaging
+ @li @p Pref - Preferred number
+ @li @p Voice - Voice
+ @li @p Fax - Fax machine
+ @li @p Cell - Cell phone
+ @li @p Video - Video phone
+ @li @p Bbs - Mailbox
+ @li @p Modem - Modem
+ @li @p Car - Car phone
+ @li @p Isdn - ISDN connection
+ @li @p Pcs - Personal Communication Service
+ @li @p Pager - Pager
+ */
+ enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32,
+ Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024,
+ Isdn = 2048, Pcs = 4096, Pager = 8192 };
+
+ /**
+ Create an empty phone number object.
+ */
+ PhoneNumber();
+
+ /**
+ Create a phonenumber object.
+
+ @param number Number
+ @param type Type as defined in enum. Multiple types can be
+ specified by combining them by a logical or.
+ */
+ PhoneNumber( const QString &number, int type = Home );
+
+ /**
+ Destructor.
+ */
+ ~PhoneNumber();
+
+ bool operator==( const PhoneNumber & ) const;
+ bool operator!=( const PhoneNumber & ) const;
+
+ /**
+ Sets the unique identifier.
+ */
+ void setId( const QString &id );
+
+ /**
+ Returns the unique identifier.
+ */
+ QString id() const;
+
+ /**
+ Sets the number.
+ */
+ void setNumber( const QString & );
+
+ /**
+ Returns the number.
+ */
+ QString number() const;
+
+ /**
+ Sets the type. Multiple types can be specified by combining them by
+ a logical or.
+ */
+ void setType( int );
+
+ /**
+ Returns the type. Can be a multiple types combined by a logical or.
+ */
+ int type() const;
+
+ /**
+ Returns a translated string of all types the address has.
+ */
+ QString typeLabel() const;
+
+ /**
+ Returns the translated label for phone number depending on its type.
+ */
+ QString label() const;
+
+ /**
+ Returns a list of all available types
+ */
+ static TypeList typeList();
+
+ /**
+ Returns the translated label for phone number type.
+ */
+ static QString typeLabel( int type );
+
+ /**
+ Returns the translated label for phone number type.
+ @obsolete
+ */
+ static QString label( int type );
+
+ private:
+ void init();
+
+ QString mId;
+
+ int mType;
+ QString mNumber;
+};
+
+QDataStream &operator<<( QDataStream &, const PhoneNumber & );
+QDataStream &operator>>( QDataStream &, PhoneNumber & );
+
+}
+
+#endif
diff --git a/kabc/picture.cpp b/kabc/picture.cpp
new file mode 100644
index 0000000..6a34b98
--- a/dev/null
+++ b/kabc/picture.cpp
@@ -0,0 +1,141 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include "picture.h"
+
+using namespace KABC;
+
+Picture::Picture()
+ : mIntern( false )
+{
+ mUndefined = true;
+}
+
+Picture::Picture( const QString &url )
+ : mUrl( url ), mIntern( false )
+{
+ mUndefined = false;
+}
+
+Picture::Picture( const QImage &data )
+ : mData( data ), mIntern( true )
+{
+ mUndefined = false;
+}
+
+Picture::~Picture()
+{
+}
+
+bool Picture::operator==( const Picture &p ) const
+{
+ if ( mIntern != p.mIntern ) return false;
+
+ if ( mIntern ) {
+ if ( mData != p.mData )
+ return false;
+ } else {
+ if ( mUrl != p.mUrl )
+ return false;
+ }
+
+ return true;
+}
+
+bool Picture::operator!=( const Picture &p ) const
+{
+ return !( p == *this );
+}
+
+void Picture::setUrl( const QString &url )
+{
+ mUrl = url;
+ mIntern = false;
+ mUndefined = false;
+}
+
+void Picture::setData( const QImage &data )
+{
+ mData = data;
+ mIntern = true;
+ mUndefined = false;
+}
+
+void Picture::setType( const QString &type )
+{
+ mType = type;
+}
+
+bool Picture::isIntern() const
+{
+ return mIntern;
+}
+
+QString Picture::url() const
+{
+ return mUrl;
+}
+
+QImage Picture::data() const
+{
+ return mData;
+}
+QPixmap Picture::pixmap() const
+{
+ QPixmap p;
+ p.convertFromImage ( mData );
+ return p;
+}
+
+QString Picture::type() const
+{
+ return mType;
+}
+bool Picture::undefined() const
+{
+ return mUndefined;
+}
+
+
+QString Picture::asString() const
+{
+ if ( mIntern )
+ return "intern picture";
+ else
+ return mUrl;
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture )
+{
+ return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Picture &picture )
+{
+ s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData;
+ return s;
+}
diff --git a/kabc/picture.h b/kabc/picture.h
new file mode 100644
index 0000000..714d1e2
--- a/dev/null
+++ b/kabc/picture.h
@@ -0,0 +1,134 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_PICTURE_H
+#define KABC_PICTURE_H
+
+#include <qimage.h>
+
+namespace KABC {
+
+class Picture
+{
+ friend QDataStream &operator<<( QDataStream &, const Picture & );
+ friend QDataStream &operator>>( QDataStream &, Picture & );
+
+public:
+
+ /**
+ * Consturctor. Creates an empty object.
+ */
+ Picture();
+
+ /**
+ * Consturctor.
+ *
+ * @param url A URL that describes the position of the picture file.
+ */
+ Picture( const QString &url );
+
+ /**
+ * Consturctor.
+ *
+ * @param data The raw data of the picture.
+ */
+ Picture( const QImage &data );
+
+ /**
+ * Destructor.
+ */
+ ~Picture();
+
+ bool undefined() const;
+ bool operator==( const Picture & ) const;
+ bool operator!=( const Picture & ) const;
+
+ /**
+ * Sets a URL for the location of the picture file. When using this
+ * function, @ref isIntern() will return 'false' until you use
+ * @ref setData().
+ *
+ * @param url The location URL of the picture file.
+ */
+ void setUrl( const QString &url );
+
+ /**
+ * Sets the raw data of the picture. When using this function,
+ * @ref isIntern() will return 'true' until you use @ref setUrl().
+ *
+ * @param data The raw data of the picture.
+ */
+ void setData( const QImage &data );
+
+ /**
+ * Sets the type of the picture.
+ */
+ void setType( const QString &type );
+
+ /**
+ * Returns whether the picture is described by a URL (extern) or
+ * by the raw data (intern).
+ * When this method returns 'true' you can use @ref data() to
+ * get the raw data. Otherwise you can request the URL of this
+ * picture by @ref url() and load the raw data from that location.
+ */
+ bool isIntern() const;
+
+ /**
+ * Returns the location URL of this picture.
+ */
+ QString url() const;
+
+ /**
+ * Returns the raw data of this picture.
+ */
+ QImage data() const;
+ QPixmap pixmap() const;
+ /**
+ * Returns the type of this picture.
+ */
+ QString type() const;
+
+ /**
+ * Returns string representation of the picture.
+ */
+ QString asString() const;
+
+private:
+ QString mUrl;
+ QString mType;
+ QImage mData;
+ bool mUndefined;
+
+ int mIntern;
+};
+
+QDataStream &operator<<( QDataStream &, const Picture & );
+QDataStream &operator>>( QDataStream &, Picture & );
+
+}
+#endif
diff --git a/kabc/plugin.cpp b/kabc/plugin.cpp
new file mode 100644
index 0000000..16c7e86
--- a/dev/null
+++ b/kabc/plugin.cpp
@@ -0,0 +1,61 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "plugin.h"
+
+using namespace KABC;
+
+Plugin::Plugin()
+{
+}
+
+Plugin::~Plugin()
+{
+}
+
+void Plugin::setType( const QString& type )
+{
+ mType = type;
+}
+
+QString Plugin::type() const
+{
+ return mType;
+}
+
+void Plugin::setNameLabel( const QString& label )
+{
+ mNameLabel = label;
+}
+
+QString Plugin::nameLabel() const
+{
+ return mNameLabel;
+}
+
+void Plugin::setDescriptionLabel( const QString& label )
+{
+ mDescriptionLabel = label;
+}
+
+QString Plugin::descriptionLabel() const
+{
+ return mDescriptionLabel;
+}
diff --git a/kabc/plugin.h b/kabc/plugin.h
new file mode 100644
index 0000000..122a995
--- a/dev/null
+++ b/kabc/plugin.h
@@ -0,0 +1,50 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_PLUGIN_H
+#define KABC_PLUGIN_H
+
+#include <qstring.h>
+
+namespace KABC {
+
+class Plugin
+{
+public:
+ Plugin();
+ virtual ~Plugin();
+
+ virtual void setType( const QString& type );
+ virtual QString type() const;
+
+ virtual void setNameLabel( const QString& label );
+ virtual QString nameLabel() const;
+
+ virtual void setDescriptionLabel( const QString& label );
+ virtual QString descriptionLabel() const;
+
+private:
+ QString mType;
+ QString mNameLabel;
+ QString mDescriptionLabel;
+};
+
+}
+#endif
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
new file mode 100644
index 0000000..f354a9e
--- a/dev/null
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -0,0 +1,363 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifndef _WIN32_
+#include <unistd.h>
+#endif
+
+#include <qregexp.h>
+#include <qtimer.h>
+#include <qwidget.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+//US #include <kgenericfactory.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kurlrequester.h>
+
+#include "addressbook.h"
+
+//US #include "formatfactory.h"
+
+#include "resourcedirconfig.h"
+#include "stdaddressbook.h"
+
+//US
+#include <qdir.h>
+#include <formats/vcardformatplugin2.h>
+#include <formats/binaryformat.h>
+
+#include "resourcedir.h"
+
+using namespace KABC;
+
+extern "C"
+{
+ void *init_kabc_dir()
+ {
+ qDebug("resourcedir.cpp : init_kabc_dir has to be changed");
+//US return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
+ return 0;
+ }
+}
+
+
+ResourceDir::ResourceDir( const KConfig *config )
+ : Resource( config )
+{
+ QString path;
+
+ KConfig *cfg = (KConfig *)config;
+ if ( cfg ) {
+//US path = config->readEntry( "FilePath" );
+ path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() );
+//US mFormatName = config->readEntry( "FileFormat" );
+ mFormatName = cfg->readEntry( "FileFormat", "vcard" );
+ } else {
+ path = StdAddressBook::directoryName();
+ mFormatName = "vcard";
+ }
+
+
+/*US FormatFactory *factory = FormatFactory::self();
+ mFormat = factory->format( mFormatName );
+
+ if ( !mFormat ) {
+ mFormatName = "vcard";
+ mFormat = factory->format( mFormatName );
+ }
+*/
+
+//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
+ if (mFormatName == "vcard")
+ mFormat = new VCardFormatPlugin2();
+ else if (mFormatName == "binary")
+ mFormat = new BinaryFormat();
+ else
+ qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
+
+
+/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
+ connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
+ connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) );
+ connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) );
+*/
+
+ setPath( path );
+}
+
+ResourceDir::~ResourceDir()
+{
+ delete mFormat;
+ mFormat = 0;
+}
+
+void ResourceDir::writeConfig( KConfig *config )
+{
+ Resource::writeConfig( config );
+
+ config->writeEntry( "FilePath", mPath );
+ config->writeEntry( "FileFormat", mFormatName );
+}
+
+Ticket *ResourceDir::requestSaveTicket()
+{
+ kdDebug(5700) << "ResourceDir::requestSaveTicket()" << endl;
+
+ if ( !addressBook() ) return 0;
+
+ if ( !lock( mPath ) ) {
+ kdDebug(5700) << "ResourceDir::requestSaveTicket(): Unable to lock path '"
+ << mPath << "'" << endl;
+ return 0;
+ }
+ return createTicket( this );
+}
+
+
+bool ResourceDir::doOpen()
+{
+ QDir dir( mPath );
+ if ( !dir.exists() ) { // no directory available
+ return dir.mkdir( dir.path() );
+ } else {
+ QString testName = dir.entryList( QDir::Files )[0];
+ if ( testName.isNull() || testName.isEmpty() ) // no file in directory
+ return true;
+
+ QFile file( mPath + "/" + testName );
+ if ( file.open( IO_ReadOnly ) )
+ return true;
+
+ if ( file.size() == 0 )
+ return true;
+
+ bool ok = mFormat->checkFormat( &file );
+ file.close();
+ return ok;
+ }
+}
+
+void ResourceDir::doClose()
+{
+}
+
+bool ResourceDir::load()
+{
+ kdDebug(5700) << "ResourceDir::load(): '" << mPath << "'" << endl;
+
+ QDir dir( mPath );
+ QStringList files = dir.entryList( QDir::Files );
+
+ QStringList::Iterator it;
+ bool ok = true;
+ for ( it = files.begin(); it != files.end(); ++it ) {
+ QFile file( mPath + "/" + (*it) );
+
+ if ( !file.open( IO_ReadOnly ) ) {
+ addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) );
+ ok = false;
+ continue;
+ }
+
+ if ( !mFormat->loadAll( addressBook(), this, &file ) )
+ ok = false;
+
+ file.close();
+ }
+
+ return ok;
+}
+
+bool ResourceDir::save( Ticket *ticket )
+{
+ kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl;
+
+ AddressBook::Iterator it;
+ bool ok = true;
+
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ if ( (*it).resource() != this || !(*it).changed() )
+ continue;
+
+ QFile file( mPath + "/" + (*it).uid() );
+ if ( !file.open( IO_WriteOnly ) ) {
+ addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) );
+ continue;
+ }
+
+ mFormat->save( *it, &file );
+
+ // mark as unchanged
+ (*it).setChanged( false );
+
+ file.close();
+ }
+
+ delete ticket;
+ unlock( mPath );
+
+ return ok;
+}
+
+bool ResourceDir::lock( const QString &path )
+{
+ kdDebug(5700) << "ResourceDir::lock()" << endl;
+
+ QString p = path;
+//US change the implementation how the lockfilename is getting created
+//US p.replace( QRegExp("/"), "_" );
+//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" );
+ KURL url(p);
+ QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
+
+
+ kdDebug(5700) << "-- lock name: " << lockName << endl;
+
+ if ( QFile::exists( lockName ) ) return false;
+
+ QString lockUniqueName;
+ lockUniqueName = p + KApplication::randomString( 8 );
+
+ url = lockUniqueName;
+//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
+ mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
+
+ kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
+
+ // Create unique file
+ QFile file( mLockUniqueName );
+ file.open( IO_WriteOnly );
+ file.close();
+
+ // Create lock file
+#ifdef _WIN32_
+ int result = 0;
+ qDebug("WARNING: ResourceDir::lock cannot link ");
+#else
+ int result = ::link( QFile::encodeName( mLockUniqueName ),
+ QFile::encodeName( lockName ) );
+#endif
+ if ( result == 0 ) {
+ addressBook()->emitAddressBookLocked();
+ return true;
+ }
+
+ // TODO: check stat
+
+ return false;
+}
+
+void ResourceDir::unlock( const QString &path )
+{
+ QString p = path;
+//US change the implementation how the lockfilename is getting created
+//US p.replace( QRegExp( "/" ), "_" );
+//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
+ KURL url(p);
+ QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
+
+ ::unlink( QFile::encodeName( lockName ) );
+ QFile::remove( mLockUniqueName );
+ addressBook()->emitAddressBookUnlocked();
+}
+
+void ResourceDir::setPath( const QString &path )
+{
+/*US ToDo: no synchronization so far. Has to be changed in the future
+ mDirWatch.stopScan();
+ mDirWatch.removeDir( mPath );
+*/
+ mPath = path;
+
+/*US ToDo: no synchronization so far. Has to be changed in the future
+ mDirWatch.addDir( mPath, true );
+ mDirWatch.startScan();
+*/
+
+//US simulate KDirWatch event
+ pathChanged();
+
+}
+
+QString ResourceDir::path() const
+{
+ return mPath;
+}
+
+void ResourceDir::setFormat( const QString &format )
+{
+ mFormatName = format;
+
+ if ( mFormat )
+ delete mFormat;
+
+//US FormatFactory *factory = FormatFactory::self();
+//US mFormat = factory->format( mFormatName );
+
+qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
+ if (mFormatName == "vcard")
+ mFormat = new VCardFormatPlugin2();
+ else if (mFormatName == "binary")
+ mFormat = new BinaryFormat();
+ else
+ qDebug("ResourceDir::setFormat format unknown !!! %s ", format.latin1());
+
+
+}
+
+QString ResourceDir::format() const
+{
+ return mFormatName;
+}
+
+void ResourceDir::pathChanged()
+{
+ if ( !addressBook() )
+ return;
+
+ load();
+ addressBook()->emitAddressBookChanged();
+}
+
+void ResourceDir::removeAddressee( const Addressee& addr )
+{
+ QFile::remove( mPath + "/" + addr.uid() );
+}
+
+void ResourceDir::cleanUp()
+{
+ unlock( mPath );
+}
+
+//US #include "resourcedir.moc"
diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h
new file mode 100644
index 0000000..6e35695
--- a/dev/null
+++ b/kabc/plugins/dir/resourcedir.h
@@ -0,0 +1,115 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_RESOURCEDIR_H
+#define KABC_RESOURCEDIR_H
+
+#include <kconfig.h>
+#include <kdirwatch.h>
+
+#include <sys/types.h>
+
+#include "resource.h"
+
+class QTimer;
+
+namespace KABC {
+
+class FormatPlugin;
+
+/**
+ @internal
+*/
+class ResourceDir : public Resource
+{
+ Q_OBJECT
+
+public:
+ ResourceDir( const KConfig* );
+ ~ResourceDir();
+
+ virtual void writeConfig( KConfig* );
+
+ virtual bool doOpen();
+ virtual void doClose();
+
+ virtual Ticket *requestSaveTicket();
+
+ virtual bool load();
+ virtual bool save( Ticket * );
+
+ /**
+ * Set path to be used for saving.
+ */
+ void setPath( const QString & );
+
+ /**
+ * Return path used for loading and saving the address book.
+ */
+ QString path() const;
+
+ /**
+ * Set the format by name.
+ */
+ void setFormat( const QString &format );
+
+ /**
+ * Returns the format name.
+ */
+ QString format() const;
+
+ /**
+ * Remove a addressee from its source.
+ * This method is mainly called by KABC::AddressBook.
+ */
+ virtual void removeAddressee( const Addressee& addr );
+
+ /**
+ * This method is called by an error handler if the application
+ * crashed
+ */
+ virtual void cleanUp();
+
+protected slots:
+ void pathChanged();
+
+protected:
+ bool lock( const QString &path );
+ void unlock( const QString &path );
+
+private:
+ FormatPlugin *mFormat;
+
+ KDirWatch mDirWatch;
+
+ QString mPath;
+ QString mFormatName;
+ QString mLockUniqueName;
+};
+
+}
+#endif
diff --git a/kabc/plugins/dir/resourcedirconfig.cpp b/kabc/plugins/dir/resourcedirconfig.cpp
new file mode 100644
index 0000000..98d18fe
--- a/dev/null
+++ b/kabc/plugins/dir/resourcedirconfig.cpp
@@ -0,0 +1,123 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kdialog.h>
+
+//US #include "formatfactory.h"
+#include "resourcedir.h"
+#include "stdaddressbook.h"
+
+#include "resourcedirconfig.h"
+
+using namespace KABC;
+
+ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name )
+ : KRES::ConfigWidget( parent, name )
+{
+ QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0,
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Format:" ), this );
+ mFormatBox = new KComboBox( this );
+
+ mainLayout->addWidget( label, 0, 0 );
+ mainLayout->addWidget( mFormatBox, 0, 1 );
+
+ label = new QLabel( i18n( "Location:" ), this );
+ mFileNameEdit = new KURLRequester( this );
+//US mFileNameEdit->setMode( KFile::Directory );
+
+ mainLayout->addWidget( label, 1, 0 );
+ mainLayout->addWidget( mFileNameEdit, 1, 1 );
+
+/*US lets hardcode the formats instead of using a factory
+ FormatFactory *factory = FormatFactory::self();
+ QStringList formats = factory->formats();
+ QStringList::Iterator it;
+ for ( it = formats.begin(); it != formats.end(); ++it ) {
+ FormatInfo *info = factory->info( *it );
+ if ( info ) {
+ mFormatTypes << (*it);
+ mFormatBox->insertItem( info->nameLabel );
+ }
+ }
+*/
+ mFormatTypes << "vcard";
+ mFormatTypes << "binary";
+ mFormatBox->insertItem( "vcard" );
+ mFormatBox->insertItem( "binary" );
+
+
+ mInEditMode = false;
+}
+
+void ResourceDirConfig::setEditMode( bool value )
+{
+ mFormatBox->setEnabled( !value );
+ mInEditMode = value;
+}
+
+void ResourceDirConfig::loadSettings( KRES::Resource *res )
+{
+//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
+ ResourceDir *resource = (ResourceDir*)( res );
+
+ if ( !resource ) {
+ kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
+ return;
+ }
+
+ mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
+
+ mFileNameEdit->setURL( resource->path() );
+ if ( mFileNameEdit->url().isEmpty() )
+ mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() );
+}
+
+void ResourceDirConfig::saveSettings( KRES::Resource *res )
+{
+//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
+ ResourceDir *resource = (ResourceDir*)( res );
+
+ if ( !resource ) {
+ kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
+ return;
+ }
+
+ if ( mInEditMode )
+ resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
+
+ resource->setPath( mFileNameEdit->url() );
+}
+
+//US #include "resourcedirconfig.moc"
diff --git a/kabc/plugins/dir/resourcedirconfig.h b/kabc/plugins/dir/resourcedirconfig.h
new file mode 100644
index 0000000..5af38a5
--- a/dev/null
+++ b/kabc/plugins/dir/resourcedirconfig.h
@@ -0,0 +1,61 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef RESOURCEDIRCONFIG_H
+#define RESOURCEDIRCONFIG_H
+
+#include <kcombobox.h>
+#include <kurlrequester.h>
+
+#include <kresources/configwidget.h>
+
+namespace KABC {
+
+class ResourceDirConfig : public KRES::ConfigWidget
+{
+ Q_OBJECT
+
+public:
+ ResourceDirConfig( QWidget* parent = 0, const char* name = 0 );
+
+ void setEditMode( bool value );
+
+public slots:
+ void loadSettings( KRES::Resource* );
+ void saveSettings( KRES::Resource* );
+
+private:
+ KComboBox* mFormatBox;
+ KURLRequester* mFileNameEdit;
+
+ QStringList mFormatTypes;
+
+ bool mInEditMode;
+};
+
+}
+#endif
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
new file mode 100644
index 0000000..d30ed2f
--- a/dev/null
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -0,0 +1,389 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifndef _WIN32_
+#include <unistd.h>
+#endif
+
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qregexp.h>
+#include <qtimer.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+//US #include <ksavefile.h>
+#include <kstandarddirs.h>
+
+//US #include "formatfactory.h"
+
+#include "resource.h"
+#include "resourcefileconfig.h"
+#include "stdaddressbook.h"
+
+#include <formats/vcardformatplugin2.h>
+#include <formats/binaryformat.h>
+
+
+#include "resourcefile.h"
+
+using namespace KABC;
+
+extern "C"
+{
+ void *init_kabc_file()
+ {
+ qDebug("!!!resourcefile.cpp : init_kabc_file has to be changed");
+//US return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
+ return 0;
+ }
+}
+
+
+ResourceFile::ResourceFile( const KConfig *config )
+ : Resource( config ) , mFormat( 0 )
+{
+ QString fileName, formatName;
+
+ KConfig *cfg = (KConfig *)config;
+ if ( cfg ) {
+ fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() );
+ formatName = cfg->readEntry( "FileFormat", "vcard" );
+// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
+ } else {
+ fileName = StdAddressBook::fileName();
+ formatName = "vcard";
+// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
+ }
+
+ init( fileName, formatName );
+}
+
+ResourceFile::ResourceFile( const QString &fileName,
+ const QString &formatName )
+ : Resource( 0 )
+{
+// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
+ init( fileName, formatName );
+}
+
+void ResourceFile::init( const QString &fileName, const QString &formatName )
+{
+ mFormatName = formatName;
+
+/*US FormatFactory *factory = FormatFactory::self();
+ mFormat = factory->format( mFormatName );
+
+ if ( !mFormat ) {
+ mFormatName = "vcard";
+ mFormat = factory->format( mFormatName );
+ }
+*/
+
+//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1());
+ if (mFormatName == "vcard") {
+ mFormat = new VCardFormatPlugin2();
+// qDebug("ResourceFile::init format VCardFormatPlugin2");
+ }
+ else if (mFormatName == "binary") {
+ mFormat = new BinaryFormat();
+// qDebug("ResourceFile::init format BinaryFormat");
+ }
+ else
+ qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1());
+
+/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
+ connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
+ connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
+ connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
+*/
+
+ setFileName( fileName );
+}
+
+ResourceFile::~ResourceFile()
+{
+ delete mFormat;
+ mFormat = 0;
+}
+
+void ResourceFile::writeConfig( KConfig *config )
+{
+ Resource::writeConfig( config );
+
+ config->writeEntry( "FileName", mFileName );
+ config->writeEntry( "FileFormat", mFormatName );
+
+// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
+
+}
+
+Ticket *ResourceFile::requestSaveTicket()
+{
+ kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl;
+
+ if ( !addressBook() ) return 0;
+
+ if ( !lock( mFileName ) ) {
+ kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '"
+ << mFileName << "'" << endl;
+ return 0;
+ }
+ return createTicket( this );
+}
+
+
+bool ResourceFile::doOpen()
+{
+ QFile file( mFileName );
+
+ if ( !file.exists() ) {
+ // try to create the file
+ bool ok = file.open( IO_WriteOnly );
+ if ( ok )
+ file.close();
+
+ return ok;
+ } else {
+ if ( !file.open( IO_ReadWrite ) )
+ return false;
+
+ if ( file.size() == 0 ) {
+ file.close();
+ return true;
+ }
+
+ bool ok = mFormat->checkFormat( &file );
+ file.close();
+
+ return ok;
+ }
+}
+
+void ResourceFile::doClose()
+{
+}
+
+bool ResourceFile::load()
+{
+ kdDebug(5700) << "ResourceFile::load(): '" << mFileName << "'" << endl;
+
+ QFile file( mFileName );
+ if ( !file.open( IO_ReadOnly ) ) {
+ addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) );
+ return false;
+ }
+
+// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
+
+ return mFormat->loadAll( addressBook(), this, &file );
+}
+
+bool ResourceFile::save( Ticket *ticket )
+{
+// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
+ kdDebug(5700) << "ResourceFile::save()" << endl;
+
+ // create backup file
+ QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
+
+/*US we use a simpler method to create a backupfile
+
+ (void) KSaveFile::backupFile( mFileName, QString::null /*directory*/
+/*US ,extension );
+
+ KSaveFile saveFile( mFileName );
+ bool ok = false;
+ if ( saveFile.status() == 0 && saveFile.file() )
+ {
+ mFormat->saveAll( addressBook(), this, saveFile.file() );
+ ok = saveFile.close();
+ }
+*/
+
+//US ToDo: write backupfile
+ QFile info;
+ info.setName( mFileName );
+ bool ok = info.open( IO_WriteOnly );
+ if ( ok ) {
+ mFormat->saveAll( addressBook(), this, &info );
+
+ info.close();
+ ok = true;
+ }
+ else {
+
+ }
+
+ if ( !ok )
+ addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
+
+ delete ticket;
+ unlock( mFileName );
+
+ return ok;
+
+ qDebug("ResourceFile::save has to be changed");
+ return true;
+}
+
+bool ResourceFile::lock( const QString &fileName )
+{
+ kdDebug(5700) << "ResourceFile::lock()" << endl;
+
+ QString fn = fileName;
+
+//US change the implementation how the lockfilename is getting created
+//US fn.replace( QRegExp("/"), "_" );
+//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
+
+ KURL url(fn);
+ QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
+
+ kdDebug(5700) << "-- lock name: " << lockName << endl;
+
+ if (QFile::exists( lockName )) return false;
+
+ QString lockUniqueName;
+ lockUniqueName = fn + KApplication::randomString( 8 );
+
+ url = lockUniqueName;
+//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
+ mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
+ kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
+
+ // Create unique file
+ QFile file( mLockUniqueName );
+ file.open( IO_WriteOnly );
+ file.close();
+
+ // Create lock file
+ int result = 0;//::link( QFile::encodeName( mLockUniqueName ),
+ // QFile::encodeName( lockName ) );
+ qDebug("lock files %s, %s needs to be fixed", mLockUniqueName.latin1(), lockName.latin1() );
+
+ if ( result == 0 ) {
+ addressBook()->emitAddressBookLocked();
+ return true;
+ }
+
+ // TODO: check stat
+
+ return false;
+}
+
+void ResourceFile::unlock( const QString &fileName )
+{
+ QString fn = fileName;
+//US change the implementation how the lockfilename is getting created
+//US fn.replace( QRegExp( "/" ), "_" );
+//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
+//US QString lockName = fn + ".lock";
+ KURL url(fn);
+ QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
+
+ QFile::remove( lockName );
+ QFile::remove( mLockUniqueName );
+ addressBook()->emitAddressBookUnlocked();
+}
+
+void ResourceFile::setFileName( const QString &fileName )
+{
+/*US ToDo: no synchronization so far. Has to be changed in the future
+ mDirWatch.stopScan();
+ mDirWatch.removeFile( mFileName );
+*/
+ mFileName = fileName;
+
+
+/*US ToDo: no synchronization so far. Has to be changed in the future
+ mDirWatch.addFile( mFileName );
+ mDirWatch.startScan();
+*/
+//US simulate KDirWatch event
+ fileChanged();
+}
+
+QString ResourceFile::fileName() const
+{
+ return mFileName;
+}
+
+void ResourceFile::setFormat( const QString &format )
+{
+ mFormatName = format;
+ delete mFormat;
+
+//US FormatFactory *factory = FormatFactory::self();
+//US mFormat = factory->format( mFormatName );
+
+//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1());
+ if (mFormatName == "vcard") {
+ mFormat = new VCardFormatPlugin2();
+// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
+ }
+ else if (mFormatName == "binary") {
+ mFormat = new BinaryFormat();
+// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
+ }
+ else
+ qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1());
+
+}
+
+QString ResourceFile::format() const
+{
+ return mFormatName;
+}
+
+void ResourceFile::fileChanged()
+{
+ // There is a small theoretical chance that KDirWatch calls us before
+ // we are fully constructed
+ if (!addressBook())
+ return;
+ load();
+ addressBook()->emitAddressBookChanged();
+}
+
+void ResourceFile::removeAddressee( const Addressee &addr )
+{
+ QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
+ QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
+ QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
+}
+
+void ResourceFile::cleanUp()
+{
+ unlock( mFileName );
+}
+
+//US #include "resourcefile.moc"
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
new file mode 100644
index 0000000..4522d78
--- a/dev/null
+++ b/kabc/plugins/file/resourcefile.h
@@ -0,0 +1,162 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+
+#ifndef KABC_RESOURCEFILE_H
+#define KABC_RESOURCEFILE_H
+
+#include <kconfig.h>
+#include <kdirwatch.h>
+
+#include <sys/types.h>
+
+#include <resource.h>
+
+class QTimer;
+class FormatPlugin;
+
+namespace KABC {
+
+//US class FormatPlugin;
+class ResourceConfigWidget;
+
+/**
+ @internal
+*/
+class ResourceFile : public Resource
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ Constructor.
+
+ @param cfg The config object where custom resource settings are stored.
+ */
+ ResourceFile( const KConfig *cfg );
+
+ /**
+ Construct file resource on file @arg fileName using format @arg formatName.
+ */
+ ResourceFile( const QString &fileName, const QString &formatName = "vcard" );
+
+ /**
+ * Destructor.
+ */
+ ~ResourceFile();
+
+ /**
+ Writes the config back.
+ */
+ virtual void writeConfig( KConfig *cfg );
+
+ /**
+ * Tries to open the file and checks for the proper format.
+ * This method should be called before @ref load().
+ */
+ virtual bool doOpen();
+
+ /**
+ * Closes the file again.
+ */
+ virtual void doClose();
+
+ /**
+ * Requests a save ticket, that is used by @ref save()
+ */
+ virtual Ticket *requestSaveTicket();
+
+ /**
+ * Loads all addressees from file to the address book.
+ * Returns true if all addressees could be loaded otherwise false.
+ */
+ virtual bool load();
+
+ /**
+ * Saves all addresses from address book to file.
+ * Returns true if all addressees could be saved otherwise false.
+ *
+ * @param ticket The ticket returned by @ref requestSaveTicket()
+ */
+ virtual bool save( Ticket *ticket );
+
+ /**
+ * Set name of file to be used for saving.
+ */
+ void setFileName( const QString & );
+
+ /**
+ * Return name of file used for loading and saving the address book.
+ */
+ QString fileName() const;
+
+ /**
+ Sets a new format by name.
+ */
+ void setFormat( const QString &name );
+
+ /**
+ Returns the format name.
+ */
+ QString format() const;
+
+ /**
+ * Remove a addressee from its source.
+ * This method is mainly called by KABC::AddressBook.
+ */
+ virtual void removeAddressee( const Addressee& addr );
+
+ /**
+ * This method is called by an error handler if the application
+ * crashed
+ */
+ virtual void cleanUp();
+
+protected slots:
+ void fileChanged();
+
+protected:
+ void init( const QString &fileName, const QString &format );
+
+ bool lock( const QString &fileName );
+ void unlock( const QString &fileName );
+
+private:
+ QString mFileName;
+ QString mFormatName;
+
+ FormatPlugin *mFormat;
+
+ QString mLockUniqueName;
+
+ KDirWatch mDirWatch;
+};
+
+}
+
+#endif
diff --git a/kabc/plugins/file/resourcefileconfig.cpp b/kabc/plugins/file/resourcefileconfig.cpp
new file mode 100644
index 0000000..b63775d
--- a/dev/null
+++ b/kabc/plugins/file/resourcefileconfig.cpp
@@ -0,0 +1,144 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qfileinfo.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kdialog.h>
+#ifndef _WIN32_
+#include <unistd.h>
+#endif
+//US #include "formatfactory.h"
+#include <qfile.h>
+#include "resourcefile.h"
+#include "stdaddressbook.h"
+
+#include "resourcefileconfig.h"
+
+using namespace KABC;
+
+ResourceFileConfig::ResourceFileConfig( QWidget* parent, const char* name )
+ : ConfigWidget( parent, name )
+{
+//qDebug("ResourceFileConfig::ResourceFileConfig");
+
+ QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0,
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Format:" ), this );
+ mFormatBox = new KComboBox( this );
+
+ mainLayout->addWidget( label, 0, 0 );
+ mainLayout->addWidget( mFormatBox, 0, 1 );
+
+ label = new QLabel( i18n( "Location:" ), this );
+ mFileNameEdit = new KURLRequester( this );
+
+ connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
+ SLOT( checkFilePermissions( const QString & ) ) );
+
+ mainLayout->addWidget( label, 1, 0 );
+ mainLayout->addWidget( mFileNameEdit, 1, 1 );
+
+
+/*US lets hardcode the formats instead of using a factory
+ FormatFactory *factory = FormatFactory::self();
+ QStringList formats = factory->formats();
+ QStringList::Iterator it;
+
+ for ( it = formats.begin(); it != formats.end(); ++it ) {
+ FormatInfo *info = factory->info( *it );
+ if ( info ) {
+ mFormatTypes << (*it);
+ mFormatBox->insertItem( info->nameLabel );
+ }
+ }
+*/
+ mFormatTypes << "vcard";
+ mFormatTypes << "binary";
+ mFormatBox->insertItem( "vcard" );
+ mFormatBox->insertItem( "binary" );
+
+ mInEditMode = false;
+}
+
+void ResourceFileConfig::setEditMode( bool value )
+{
+ mFormatBox->setEnabled( !value );
+ mInEditMode = value;
+}
+
+void ResourceFileConfig::loadSettings( KRES::Resource *res )
+{
+//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
+ ResourceFile *resource = (ResourceFile*)( res );
+
+ if ( !resource ) {
+ kdDebug(5700) << "ResourceFileConfig::loadSettings(): cast failed" << endl;
+ return;
+ }
+
+ mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
+
+ mFileNameEdit->setURL( resource->fileName() );
+ if ( mFileNameEdit->url().isEmpty() )
+ mFileNameEdit->setURL( KABC::StdAddressBook::fileName() );
+}
+
+void ResourceFileConfig::saveSettings( KRES::Resource *res )
+{
+//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
+ ResourceFile *resource = (ResourceFile*)( res );
+
+ if ( !resource ) {
+ kdDebug(5700) << "ResourceFileConfig::saveSettings(): cast failed" << endl;
+ return;
+ }
+
+ if ( !mInEditMode )
+ resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
+
+ resource->setFileName( mFileNameEdit->url() );
+}
+void ResourceFileConfig::checkFilePermissions( const QString& fileName )
+{
+ // If file exist but is not writeable...
+#ifdef _WIN32_
+ QFileInfo fi ( QFile::encodeName( fileName ) );
+ if ( fi.exists() )
+ emit setReadOnly(!fi.isReadable() );
+#else
+ if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
+ emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
+#endif
+}
+
+//US #include "resourcefileconfig.moc"
diff --git a/kabc/plugins/file/resourcefileconfig.h b/kabc/plugins/file/resourcefileconfig.h
new file mode 100644
index 0000000..31ccaaf
--- a/dev/null
+++ b/kabc/plugins/file/resourcefileconfig.h
@@ -0,0 +1,65 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef RESOURCEFILECONFIG_H
+#define RESOURCEFILECONFIG_H
+
+#include <kcombobox.h>
+#include <kurlrequester.h>
+
+#include <kresources/configwidget.h>
+
+namespace KABC {
+
+class ResourceFileConfig : public KRES::ConfigWidget
+{
+ Q_OBJECT
+
+public:
+ ResourceFileConfig( QWidget* parent = 0, const char* name = 0 );
+
+ void setEditMode( bool value );
+
+public slots:
+ void loadSettings( KRES::Resource *resource );
+ void saveSettings( KRES::Resource *resource );
+
+protected slots:
+ void checkFilePermissions( const QString& fileName );
+
+private:
+ KComboBox* mFormatBox;
+ KURLRequester* mFileNameEdit;
+ bool mInEditMode;
+
+ QStringList mFormatTypes;
+};
+
+}
+
+#endif
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp
new file mode 100644
index 0000000..1c54f63
--- a/dev/null
+++ b/kabc/plugins/ldap/resourceldap.cpp
@@ -0,0 +1,444 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kstringhandler.h>
+
+#include <stdlib.h>
+
+#include "resourceldap.h"
+#include "resourceldapconfig.h"
+
+using namespace KABC;
+
+extern "C"
+{
+ void *init_kabc_ldap()
+ {
+ qDebug("resourceldap.cpp : init_kabc_ldap has to be changed");
+//US return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>();
+ }
+}
+
+void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value );
+
+
+ResourceLDAP::ResourceLDAP( const KConfig *config )
+ : Resource( config ), mPort( 389 ), mLdap( 0 )
+{
+ KConfig *cfg = (KConfig *)config;
+ if ( cfg ) {
+ mUser = cfg->readEntry( "LdapUser" );
+ mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) );
+ mDn = cfg->readEntry( "LdapDn" );
+ mHost = cfg->readEntry( "LdapHost" );
+ mPort = cfg->readNumEntry( "LdapPort", 389 );
+ mFilter = cfg->readEntry( "LdapFilter" );
+ mAnonymous = cfg->readBoolEntry( "LdapAnonymous" );
+
+ QStringList attributes = cfg->readListEntry( "LdapAttributes" );
+ for ( uint pos = 0; pos < attributes.count(); pos += 2 )
+ mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] );
+ }
+
+ /**
+ If you want to add new attributes, append them here, add a
+ translation string in the ctor of AttributesDialog and
+ handle them in the load() method below.
+ These are the default values from
+ */
+ if ( mAttributes.count() == 0 ) {
+ mAttributes.insert( "commonName", "cn" );
+ mAttributes.insert( "formattedName", "displayName" );
+ mAttributes.insert( "familyName", "sn" );
+ mAttributes.insert( "givenName", "givenName" );
+ mAttributes.insert( "mail", "mail" );
+ mAttributes.insert( "mailAlias", "" );
+ mAttributes.insert( "phoneNumber", "telephoneNumber" );
+ mAttributes.insert( "uid", "uid" );
+ }
+}
+
+void ResourceLDAP::writeConfig( KConfig *config )
+{
+ Resource::writeConfig( config );
+
+ config->writeEntry( "LdapUser", mUser );
+ config->writeEntry( "LdapPassword", KStringHandler::obscure( mPassword ) );
+ config->writeEntry( "LdapDn", mDn );
+ config->writeEntry( "LdapHost", mHost );
+ config->writeEntry( "LdapPort", mPort );
+ config->writeEntry( "LdapFilter", mFilter );
+ config->writeEntry( "LdapAnonymous", mAnonymous );
+
+ QStringList attributes;
+ QMap<QString, QString>::Iterator it;
+ for ( it = mAttributes.begin(); it != mAttributes.end(); ++it )
+ attributes << it.key() << it.data();
+
+ config->writeEntry( "LdapAttributes", attributes );
+}
+
+Ticket *ResourceLDAP::requestSaveTicket()
+{
+ if ( !addressBook() ) {
+ kdDebug(5700) << "no addressbook" << endl;
+ return 0;
+ }
+
+ return createTicket( this );
+}
+
+bool ResourceLDAP::doOpen()
+{
+ if ( mLdap )
+ return false;
+
+ if ( !mPort )
+ mPort = 389;
+
+ mLdap = ldap_init( mHost.local8Bit(), mPort );
+ if ( !mLdap ) {
+ addressBook()->error( i18n( "Unable to connect to server '%1' on port '%2'" ).arg( mHost ).arg( mPort ) );
+ return false;
+ }
+
+ if ( !mUser.isEmpty() && !mAnonymous ) {
+ if ( ldap_simple_bind_s( mLdap, mUser.local8Bit(), mPassword.local8Bit() ) != LDAP_SUCCESS ) {
+ addressBook()->error( i18n( "Unable to bind to server '%1'" ).arg( mHost ) );
+ return false;
+ }
+
+ kdDebug(5700) << "ResourceLDAP: bind to server successfully" << endl;
+ } else {
+ if ( ldap_simple_bind_s( mLdap, NULL, NULL ) != LDAP_SUCCESS ) {
+ addressBook()->error( i18n( "Unable to bind anonymously to server '%1'" ).arg( mHost ) );
+ return false;
+ }
+
+ kdDebug( 5700 ) << "ResourceLDAP: bind anonymously to server successfully" << endl;
+ }
+
+ int deref = LDAP_DEREF_ALWAYS;
+ if ( ldap_set_option( mLdap, LDAP_OPT_DEREF, (void *) &deref ) != LDAP_OPT_SUCCESS ) {
+ kdDebug(5700) << "ResourceLDAP: can't set 'deref' option" << endl;
+ return false;
+ }
+
+ if ( ldap_set_option( mLdap, LDAP_OPT_REFERRALS, LDAP_OPT_ON ) != LDAP_OPT_SUCCESS ) {
+ kdDebug(5700) << "ResourceLDAP: can't set 'referrals' option" << endl;
+ return false;
+ }
+
+ return true;
+}
+
+void ResourceLDAP::doClose()
+{
+ if ( ldap_unbind_s( mLdap ) != LDAP_SUCCESS ) {
+ kdDebug(5700) << "ResourceLDAP: can't unbind from server" << endl;
+ return;
+ }
+
+ mLdap = 0;
+}
+
+bool ResourceLDAP::load()
+{
+ LDAPMessage *res;
+ LDAPMessage *msg;
+ BerElement *track;
+ char *names;
+ char **values;
+
+ char **LdapSearchAttr = new char*[ mAttributes.count() + 1 ];
+
+ QMap<QString, QString>::Iterator it;
+ int i = 0;
+ for ( it = mAttributes.begin(); it != mAttributes.end(); ++it ) {
+ if ( !it.data().isEmpty() ) {
+ unsigned int len = it.data().utf8().length();
+ LdapSearchAttr[ i ] = new char[ len+1 ];
+ memcpy( LdapSearchAttr[ i ], it.data().utf8(), len );
+ LdapSearchAttr[ i ][ len ] = 0;
+ ++i;
+ }
+ }
+ LdapSearchAttr[ i ] = 0;
+
+ QString filter = mFilter;
+ if ( filter.isEmpty() )
+ filter = "cn=*";
+
+ int result;
+ if ( ( result = ldap_search_s( mLdap, mDn.local8Bit(), LDAP_SCOPE_SUBTREE, QString( "(%1)" ).arg( filter ).local8Bit(),
+ LdapSearchAttr, 0, &res ) != LDAP_SUCCESS ) ) {
+ addressBook()->error( i18n( "Unable to search on server '%1': %2" )
+ .arg( mHost )
+ .arg( ldap_err2string( result ) ) );
+
+ for ( i = 0; LdapSearchAttr[ i ]; ++i )
+ delete [] LdapSearchAttr[ i ];
+ delete [] LdapSearchAttr;
+
+ return false;
+ }
+
+ for ( msg = ldap_first_entry( mLdap, res ); msg; msg = ldap_next_entry( mLdap, msg ) ) {
+ Addressee addr;
+ addr.setResource( this );
+ for ( names = ldap_first_attribute( mLdap, msg, &track ); names; names = ldap_next_attribute( mLdap, msg, track ) ) {
+ values = ldap_get_values( mLdap, msg, names );
+ for ( int i = 0; i < ldap_count_values( values ); ++i ) {
+ QString name = QString::fromUtf8( names ).lower();
+ QString value = QString::fromUtf8( values[ i ] );
+
+ if ( name == mAttributes[ "commonName" ].lower() ) {
+ if ( !addr.formattedName().isEmpty() ) {
+ QString fn = addr.formattedName();
+ addr.setNameFromString( value );
+ addr.setFormattedName( fn );
+ } else
+ addr.setNameFromString( value );
+ } else if ( name == mAttributes[ "formattedName" ].lower() ) {
+ addr.setFormattedName( value );
+ } else if ( name == mAttributes[ "givenName" ].lower() ) {
+ addr.setGivenName( value );
+ } else if ( name == mAttributes[ "mail" ].lower() ) {
+ addr.insertEmail( value, true );
+ } else if ( name == mAttributes[ "mailAlias" ].lower() ) {
+ addr.insertEmail( value, false );
+ } else if ( name == mAttributes[ "phoneNumber" ].lower() ) {
+ PhoneNumber phone;
+ phone.setNumber( value );
+ addr.insertPhoneNumber( phone );
+ break; // read only the home number
+ } else if ( name == mAttributes[ "familyName" ].lower() ) {
+ addr.setFamilyName( value );
+ } else if ( name == mAttributes[ "uid" ].lower() ) {
+ addr.setUid( value );
+ }
+ }
+ ldap_value_free( values );
+ }
+ ber_free( track, 0 );
+
+ addressBook()->insertAddressee( addr );
+ }
+
+ ldap_msgfree( res );
+
+ for ( i = 0; LdapSearchAttr[ i ]; ++i )
+ delete [] LdapSearchAttr[ i ];
+ delete [] LdapSearchAttr;
+
+ return true;
+}
+
+bool ResourceLDAP::save( Ticket * )
+{
+ AddressBook::Iterator it;
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ if ( (*it).resource() == this && (*it).changed() ) {
+ LDAPMod **mods = NULL;
+
+ addModOp( &mods, "objectClass", "organizationalPerson" );
+ addModOp( &mods, "objectClass", "person" );
+ addModOp( &mods, "objectClass", "Top" );
+ addModOp( &mods, mAttributes[ "commonName" ].utf8(), (*it).assembledName() );
+ addModOp( &mods, mAttributes[ "formattedName" ].utf8(), (*it).formattedName() );
+ addModOp( &mods, mAttributes[ "givenName" ].utf8(), (*it).givenName() );
+ addModOp( &mods, mAttributes[ "familyName" ].utf8(), (*it).familyName() );
+ addModOp( &mods, mAttributes[ "uid" ].utf8(), (*it).uid() );
+
+ QStringList emails = (*it).emails();
+ QStringList::ConstIterator mailIt;
+ bool first = true;
+ for ( mailIt = emails.begin(); mailIt != emails.end(); ++mailIt ) {
+ if ( first ) {
+ addModOp( &mods, mAttributes[ "mail" ].utf8(), (*mailIt) );
+ first = false;
+ } else
+ addModOp( &mods, mAttributes[ "mailAlias" ].utf8(), (*mailIt) );
+ }
+
+ PhoneNumber number = (*it).phoneNumber( PhoneNumber::Home );
+ addModOp( &mods, mAttributes[ "phoneNumber" ].utf8(), number.number() );
+
+ QString dn = "cn=" + (*it).assembledName() + "," + mDn;
+
+ int retval;
+ if ( (retval = ldap_add_s( mLdap, dn.local8Bit(), mods )) != LDAP_SUCCESS )
+ addressBook()->error( i18n( "Unable to modify '%1' on server '%2'" ).arg( (*it).uid() ).arg( mHost ) );
+
+ ldap_mods_free( mods, 1 );
+
+ // mark as unchanged
+ (*it).setChanged( false );
+ }
+ }
+
+ return true;
+}
+
+void ResourceLDAP::removeAddressee( const Addressee &addr )
+{
+ LDAPMessage *res;
+ LDAPMessage *msg;
+
+ QString filter = QString( "(&(uid=%1)(%2))" ).arg( addr.uid() ).arg( mFilter );
+
+ kdDebug(5700) << "ldap:removeAddressee" << filter << endl;
+
+ ldap_search_s( mLdap, mDn.local8Bit(), LDAP_SCOPE_SUBTREE, filter.local8Bit(),
+ 0, 0, &res );
+
+ for ( msg = ldap_first_entry( mLdap, res ); msg; msg = ldap_next_entry( mLdap, msg ) ) {
+ char *dn = ldap_get_dn( mLdap, msg );
+ kdDebug(5700) << "found " << dn << endl;
+ if ( ldap_delete_s( mLdap, dn ) != LDAP_SUCCESS )
+ addressBook()->error( i18n( "Unable to delete '%1' on server '%2'" ).arg( dn ).arg( mHost ) );
+ ldap_memfree( dn );
+ }
+
+ ldap_msgfree( res );
+}
+
+void ResourceLDAP::setUser( const QString &user )
+{
+ mUser = user;
+}
+
+QString ResourceLDAP::user() const
+{
+ return mUser;
+}
+
+void ResourceLDAP::setPassword( const QString &password )
+{
+ mPassword = password;
+}
+
+QString ResourceLDAP::password() const
+{
+ return mPassword;
+}
+
+void ResourceLDAP::setDn( const QString &dn )
+{
+ mDn = dn;
+}
+
+QString ResourceLDAP::dn() const
+{
+ return mDn;
+}
+
+void ResourceLDAP::setHost( const QString &host )
+{
+ mHost = host;
+}
+
+QString ResourceLDAP::host() const
+{
+ return mHost;
+}
+
+void ResourceLDAP::setPort( int port )
+{
+ mPort = port;
+}
+
+int ResourceLDAP::port() const
+{
+ return mPort;
+}
+
+void ResourceLDAP::setFilter( const QString &filter )
+{
+ mFilter = filter;
+}
+
+QString ResourceLDAP::filter() const
+{
+ return mFilter;
+}
+
+void ResourceLDAP::setIsAnonymous( bool value )
+{
+ mAnonymous = value;
+}
+
+bool ResourceLDAP::isAnonymous() const
+{
+ return mAnonymous;
+}
+
+void ResourceLDAP::setAttributes( const QMap<QString, QString> &attributes )
+{
+ mAttributes = attributes;
+}
+
+QMap<QString, QString> ResourceLDAP::attributes() const
+{
+ return mAttributes;
+}
+
+void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value )
+{
+ if ( value.isNull() )
+ return;
+
+ LDAPMod **mods;
+
+ mods = *pmods;
+
+ uint i = 0;
+ if ( mods != 0 )
+ for ( ; mods[ i ] != 0; ++i );
+
+ if (( mods = (LDAPMod **)realloc( mods, (i + 2) * sizeof( LDAPMod * ))) == 0 ) {
+ kdError() << "ResourceLDAP: realloc" << endl;
+ return;
+ }
+
+ *pmods = mods;
+ mods[ i + 1 ] = 0;
+
+ mods[ i ] = new LDAPMod;
+
+ mods[ i ]->mod_op = 0;
+ mods[ i ]->mod_type = strdup( attr.utf8() );
+ mods[ i ]->mod_values = new char*[ 2 ];
+ mods[ i ]->mod_values[ 0 ] = strdup( value.utf8() );
+ mods[ i ]->mod_values[ 1 ] = 0;
+}
+
diff --git a/kabc/plugins/ldap/resourceldap.h b/kabc/plugins/ldap/resourceldap.h
new file mode 100644
index 0000000..0625f30
--- a/dev/null
+++ b/kabc/plugins/ldap/resourceldap.h
@@ -0,0 +1,99 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_RESOURCELDAP_H
+#define KABC_RESOURCELDAP_H
+
+
+#include <lber.h>
+#include <ldap.h>
+
+#include "addressbook.h"
+#include "resource.h"
+
+class KConfig;
+
+namespace KABC {
+
+class ResourceLDAP : public Resource
+{
+public:
+
+ ResourceLDAP( const KConfig* );
+
+ virtual void writeConfig( KConfig* );
+
+ virtual bool doOpen();
+ virtual void doClose();
+
+ virtual Ticket *requestSaveTicket();
+
+ virtual bool load();
+ virtual bool save( Ticket * );
+
+ virtual void removeAddressee( const Addressee& addr );
+
+ void setUser( const QString &user );
+ QString user() const;
+
+ void setPassword( const QString &password );
+ QString password() const;
+
+ void setDn( const QString &dn );
+ QString dn() const;
+
+ void setHost( const QString &host );
+ QString host() const;
+
+ void setPort( int port );
+ int port() const;
+
+ void setFilter( const QString &filter );
+ QString filter() const;
+
+ void setIsAnonymous( bool value );
+ bool isAnonymous() const;
+
+ void setAttributes( const QMap<QString, QString> &attributes );
+ QMap<QString, QString> attributes() const;
+
+private:
+ QString mUser;
+ QString mPassword;
+ QString mDn;
+ QString mHost;
+ QString mFilter;
+ int mPort;
+ bool mAnonymous;
+ QMap<QString, QString> mAttributes;
+
+ LDAP *mLdap;
+};
+
+}
+
+#endif
diff --git a/kabc/plugins/ldap/resourceldapconfig.cpp b/kabc/plugins/ldap/resourceldapconfig.cpp
new file mode 100644
index 0000000..2c0d030
--- a/dev/null
+++ b/kabc/plugins/ldap/resourceldapconfig.cpp
@@ -0,0 +1,254 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qspinbox.h>
+#include <qvbox.h>
+
+//US #include <kaccelmanager.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+#include <klineedit.h>
+
+#include "resourceldap.h"
+
+#include "resourceldapconfig.h"
+
+using namespace KABC;
+
+ResourceLDAPConfig::ResourceLDAPConfig( QWidget* parent, const char* name )
+ : KRES::ConfigWidget( parent, name )
+{
+ QGridLayout *mainLayout = new QGridLayout( this, 8, 2, 0,
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "User:" ), this );
+ mUser = new KLineEdit( this );
+
+ mainLayout->addWidget( label, 0, 0 );
+ mainLayout->addWidget( mUser, 0, 1 );
+
+ label = new QLabel( i18n( "Password:" ), this );
+ mPassword = new KLineEdit( this );
+ mPassword->setEchoMode( KLineEdit::Password );
+
+ mainLayout->addWidget( label, 1, 0 );
+ mainLayout->addWidget( mPassword, 1, 1 );
+
+ label = new QLabel( i18n( "Host:" ), this );
+ mHost = new KLineEdit( this );
+
+ mainLayout->addWidget( label, 2, 0 );
+ mainLayout->addWidget( mHost, 2, 1 );
+
+ label = new QLabel( i18n( "Port:" ), this );
+ QVBox *box = new QVBox( this );
+ mPort = new QSpinBox( 0, 65535, 1, box );
+ mPort->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ) );
+ mPort->setValue( 389 );
+ new QWidget( box, "dummy" );
+
+ mainLayout->addWidget( label, 3, 0 );
+ mainLayout->addWidget( box, 3, 1 );
+
+ label = new QLabel( i18n( "Dn:" ), this );
+ mDn = new KLineEdit( this );
+
+ mainLayout->addWidget( label, 4, 0 );
+ mainLayout->addWidget( mDn, 4, 1 );
+
+ label = new QLabel( i18n( "Filter:" ), this );
+ mFilter = new KLineEdit( this );
+
+ mainLayout->addWidget( label, 5, 0 );
+ mainLayout->addWidget( mFilter, 5, 1 );
+
+ mAnonymous = new QCheckBox( i18n( "Anonymous login" ), this );
+ mainLayout->addMultiCellWidget( mAnonymous, 6, 6, 0, 1 );
+
+ mEditButton = new QPushButton( i18n( "Edit Attributes..." ), this );
+ mainLayout->addMultiCellWidget( mEditButton, 7, 7, 0, 1 );
+
+ connect( mAnonymous, SIGNAL( toggled(bool) ), mUser, SLOT( setDisabled(bool) ) );
+ connect( mAnonymous, SIGNAL( toggled(bool) ), mPassword, SLOT( setDisabled(bool) ) );
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( editAttributes() ) );
+}
+
+void ResourceLDAPConfig::loadSettings( KRES::Resource *res )
+{
+//US ResourceLDAP *resource = dynamic_cast<ResourceLDAP*>( res );
+ ResourceLDAP *resource = (ResourceLDAP*)( res );
+
+ if ( !resource ) {
+ kdDebug(5700) << "ResourceLDAPConfig::loadSettings(): cast failed" << endl;
+ return;
+ }
+
+ mUser->setText( resource->user() );
+ mPassword->setText( resource->password() );
+ mHost->setText( resource->host() );
+ mPort->setValue( resource->port() );
+ mDn->setText( resource->dn() );
+ mFilter->setText( resource->filter() );
+ mAnonymous->setChecked( resource->isAnonymous() );
+ mAttributes = resource->attributes();
+}
+
+void ResourceLDAPConfig::saveSettings( KRES::Resource *res )
+{
+//US ResourceLDAP *resource = dynamic_cast<ResourceLDAP*>( res );
+ ResourceLDAP *resource = (ResourceLDAP*)( res );
+
+ if ( !resource ) {
+ kdDebug(5700) << "ResourceLDAPConfig::saveSettings(): cast failed" << endl;
+ return;
+ }
+
+ resource->setUser( mUser->text() );
+ resource->setPassword( mPassword->text() );
+ resource->setHost( mHost->text() );
+ resource->setPort( mPort->value() );
+ resource->setDn( mDn->text() );
+ resource->setFilter( mFilter->text() );
+ resource->setIsAnonymous( mAnonymous->isChecked() );
+ resource->setAttributes( mAttributes );
+}
+
+void ResourceLDAPConfig::editAttributes()
+{
+ AttributesDialog dlg( mAttributes, this );
+ if ( dlg.exec() )
+ mAttributes = dlg.attributes();
+}
+
+AttributesDialog::AttributesDialog( const QMap<QString, QString> &attributes,
+ QWidget *parent, const char *name )
+ : KDialogBase( Plain, i18n( "Attributes Configuration" ), Ok | Cancel,
+ Ok, parent, name, true, true )
+{
+ mNameDict.setAutoDelete( true );
+ mNameDict.insert( "commonName", new QString( i18n( "Common name" ) ) );
+ mNameDict.insert( "formattedName", new QString( i18n( "Formatted name" ) ) );
+ mNameDict.insert( "familyName", new QString( i18n( "Family name" ) ) );
+ mNameDict.insert( "givenName", new QString( i18n( "Given name" ) ) );
+ mNameDict.insert( "mail", new QString( i18n( "Email" ) ) );
+ mNameDict.insert( "mailAlias", new QString( i18n( "Email alias" ) ) );
+ mNameDict.insert( "phoneNumber", new QString( i18n( "Telephone number" ) ) );
+ mNameDict.insert( "uid", new QString( i18n( "UID" ) ) );
+
+ // overwrite the default values here
+ QMap<QString, QString> kolabMap, netscapeMap, evolutionMap, outlookMap;
+
+ // kolab
+ kolabMap.insert( "formattedName", "display-name" );
+ kolabMap.insert( "mailAlias", "mailalias" );
+
+ // evolution
+ evolutionMap.insert( "formattedName", "fileAs" );
+
+ mMapList.append( attributes );
+ mMapList.append( kolabMap );
+ mMapList.append( netscapeMap );
+ mMapList.append( evolutionMap );
+ mMapList.append( outlookMap );
+
+ QFrame *page = plainPage();
+ QGridLayout *layout = new QGridLayout( page, 2, attributes.count() + 1,
+ 0, spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Template:" ), page );
+ layout->addWidget( label, 0, 0 );
+ mMapCombo = new KComboBox( page );
+ layout->addWidget( mMapCombo, 0, 1 );
+
+ mMapCombo->insertItem( i18n( "User Defined" ) );
+ mMapCombo->insertItem( i18n( "Kolab" ) );
+ mMapCombo->insertItem( i18n( "Netscape" ) );
+ mMapCombo->insertItem( i18n( "Evolution" ) );
+ mMapCombo->insertItem( i18n( "Outlook" ) );
+ connect( mMapCombo, SIGNAL( activated( int ) ), SLOT( mapChanged( int ) ) );
+
+ QMap<QString, QString>::ConstIterator it;
+ int i;
+ for ( i = 1, it = attributes.begin(); it != attributes.end(); ++it, ++i ) {
+ label = new QLabel( *mNameDict[ it.key() ] + ":", page );
+ KLineEdit *lineedit = new KLineEdit( page );
+ mLineEditDict.insert( it.key(), lineedit );
+ lineedit->setText( it.data() );
+ label->setBuddy( lineedit );
+ layout->addWidget( label, i, 0 );
+ layout->addWidget( lineedit, i, 1 );
+ }
+
+//US KAcceleratorManager::manage( this );
+}
+
+AttributesDialog::~AttributesDialog()
+{
+}
+
+QMap<QString, QString> AttributesDialog::attributes() const
+{
+ QMap<QString, QString> map;
+
+ QDictIterator<KLineEdit> it( mLineEditDict );
+ for ( ; it.current(); ++it )
+ map.insert( it.currentKey(), it.current()->text() );
+
+ return map;
+}
+
+void AttributesDialog::mapChanged( int pos )
+{
+ // default map
+ QMap<QString, QString> defaultMap;
+ defaultMap.insert( "commonName", "cn" );
+ defaultMap.insert( "formattedName", "displayName" );
+ defaultMap.insert( "familyName", "sn" );
+ defaultMap.insert( "givenName", "givenName" );
+ defaultMap.insert( "mail", "mail" );
+ defaultMap.insert( "mailAlias", "" );
+ defaultMap.insert( "phoneNumber", "telephoneNumber" );
+ defaultMap.insert( "uid", "uid" );
+
+ // apply first the default and than the spezific changes
+ QMap<QString, QString>::Iterator it;
+ for ( it = defaultMap.begin(); it != defaultMap.end(); ++it )
+ mLineEditDict[ it.key() ]->setText( it.data() );
+
+ for ( it = mMapList[ pos ].begin(); it != mMapList[ pos ].end(); ++it ) {
+ if ( !it.data().isEmpty() )
+ mLineEditDict[ it.key() ]->setText( it.data() );
+ }
+}
+
+//US #include "resourceldapconfig.moc"
diff --git a/kabc/plugins/ldap/resourceldapconfig.h b/kabc/plugins/ldap/resourceldapconfig.h
new file mode 100644
index 0000000..42d30ff
--- a/dev/null
+++ b/kabc/plugins/ldap/resourceldapconfig.h
@@ -0,0 +1,100 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef RESOURCELDAPCONFIG_H
+#define RESOURCELDAPCONFIG_H
+
+#include <qmap.h>
+//US
+#include <qdict.h>
+
+#include <kdialogbase.h>
+#include <kresources/configwidget.h>
+
+class QCheckBox;
+class QPushButton;
+class QSpinBox;
+class QString;
+
+class KComboBox;
+class KLineEdit;
+
+namespace KABC {
+
+class ResourceLDAPConfig : public KRES::ConfigWidget
+{
+ Q_OBJECT
+
+ public:
+ ResourceLDAPConfig( QWidget* parent = 0, const char* name = 0 );
+
+ public slots:
+ void loadSettings( KRES::Resource* );
+ void saveSettings( KRES::Resource* );
+
+ private slots:
+ void editAttributes();
+
+ private:
+ KLineEdit *mUser;
+ KLineEdit *mPassword;
+ KLineEdit *mHost;
+ QSpinBox *mPort;
+ KLineEdit *mDn;
+ KLineEdit *mFilter;
+ QCheckBox *mAnonymous;
+ QPushButton *mEditButton;
+ QMap<QString, QString> mAttributes;
+};
+
+class AttributesDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ AttributesDialog( const QMap<QString, QString> &attributes, QWidget *parent,
+ const char *name = 0 );
+ ~AttributesDialog();
+
+ QMap<QString, QString> attributes() const;
+
+ private slots:
+ void mapChanged( int pos );
+
+ private:
+ enum { UserMap, KolabMap, NetscapeMap, EvolutionMap, OutlookMap };
+
+ KComboBox *mMapCombo;
+ QValueList< QMap<QString, QString> > mMapList;
+
+ QDict<KLineEdit> mLineEditDict;
+ QDict<QString> mNameDict;
+};
+
+}
+
+#endif
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
new file mode 100644
index 0000000..9a1a5f8
--- a/dev/null
+++ b/kabc/resource.cpp
@@ -0,0 +1,95 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <kdebug.h>
+
+#include "resource.h"
+
+using namespace KABC;
+
+Resource::Resource( const KConfig *config )
+ : KRES::Resource( config ), mAddressBook( 0 )
+{
+}
+
+Resource::~Resource()
+{
+}
+
+void Resource::writeConfig( KConfig *config )
+{
+ KRES::Resource::writeConfig( config );
+}
+
+void Resource::setAddressBook( AddressBook *ab )
+{
+ mAddressBook = ab;
+}
+
+AddressBook *Resource::addressBook()
+{
+ return mAddressBook;
+}
+
+bool Resource::doOpen()
+{
+ return true;
+}
+
+void Resource::doClose()
+{
+}
+
+Ticket *Resource::requestSaveTicket()
+{
+ return 0;
+}
+
+bool Resource::load()
+{
+ return true;
+}
+
+bool Resource::save( Ticket * )
+{
+ return false;
+}
+
+Ticket *Resource::createTicket( Resource *resource )
+{
+ return new Ticket( resource );
+}
+
+void Resource::removeAddressee( const Addressee& )
+{
+ // do nothing
+}
+
+void Resource::cleanUp()
+{
+ // do nothing
+}
diff --git a/kabc/resource.h b/kabc/resource.h
new file mode 100644
index 0000000..c363125
--- a/dev/null
+++ b/kabc/resource.h
@@ -0,0 +1,134 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_RESOURCE_H
+#define KABC_RESOURCE_H
+
+#include <kresources/resource.h>
+
+#include "addressbook.h"
+
+namespace KABC {
+
+/**
+ * @short Helper class for handling coordinated save of address books.
+ *
+ * This class is used as helper class for saving address book.
+ * @see requestSaveTicket(), save().
+ */
+class Ticket
+{
+ friend class Resource;
+ public:
+ Resource *resource() { return mResource; }
+
+ private:
+ Ticket( Resource *resource ) : mResource( resource ) {}
+
+ Resource *mResource;
+};
+
+/**
+ * @internal
+ */
+class Resource : public KRES::Resource
+{
+public:
+ /**
+ * Constructor
+ */
+ Resource( const KConfig *config );
+
+ /**
+ * Destructor.
+ */
+ virtual ~Resource();
+
+ /**
+ * Sets the address book of the resource.
+ */
+ void setAddressBook( AddressBook* );
+
+ /**
+ * Returns a pointer to the addressbook.
+ */
+ AddressBook *addressBook();
+
+ /**
+ * Writes the resource specific config to file.
+ */
+ virtual void writeConfig( KConfig *config );
+
+ /**
+ * Open the resource and returns if it was successfully
+ */
+ virtual bool doOpen();
+
+ /**
+ * Close the resource and returns if it was successfully
+ */
+ virtual void doClose();
+
+ /**
+ * Request a ticket, you have to pass through @ref save() to
+ * allow locking.
+ */
+ virtual Ticket *requestSaveTicket();
+
+ /**
+ * Load all addressees to the addressbook
+ */
+ virtual bool load();
+
+ /**
+ * Save all addressees to the addressbook.
+ *
+ * @param ticket The ticket you get by @ref requestSaveTicket()
+ */
+ virtual bool save( Ticket *ticket );
+
+ /**
+ * Removes a addressee from resource. This method is mainly
+ * used by record-based resources like LDAP or SQL.
+ */
+ virtual void removeAddressee( const Addressee& addr );
+
+ /**
+ * This method is called by an error handler if the application
+ * crashed
+ */
+ virtual void cleanUp();
+
+protected:
+ Ticket *createTicket( Resource * );
+
+private:
+ AddressBook *mAddressBook;
+};
+
+}
+#endif
diff --git a/kabc/secrecy.cpp b/kabc/secrecy.cpp
new file mode 100644
index 0000000..f4bcb51
--- a/dev/null
+++ b/kabc/secrecy.cpp
@@ -0,0 +1,107 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <klocale.h>
+
+#include "secrecy.h"
+
+using namespace KABC;
+
+Secrecy::Secrecy( int type )
+ : mType( type )
+{
+}
+
+bool Secrecy::operator==( const Secrecy &s ) const
+{
+ return ( mType == s.mType );
+}
+
+bool Secrecy::operator!=( const Secrecy &s ) const
+{
+ return !( *this == s );
+}
+
+bool Secrecy::isValid() const
+{
+ return mType != Invalid;
+}
+
+void Secrecy::setType( int type )
+{
+ mType = type;
+}
+
+int Secrecy::type() const
+{
+ return mType;
+}
+
+Secrecy::TypeList Secrecy::typeList()
+{
+ TypeList list;
+ list << Public;
+ list << Private;
+ list << Confidential;
+
+ return list;
+}
+
+QString Secrecy::typeLabel( int type )
+{
+ switch ( type ) {
+ case Public:
+ return i18n( "Public" );
+ break;
+ case Private:
+ return i18n( "Private" );
+ break;
+ case Confidential:
+ return i18n( "Confidential" );
+ break;
+ default:
+ return i18n( "Unknown type" );
+ break;
+ }
+}
+
+QString Secrecy::asString() const
+{
+ return typeLabel( mType );
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Secrecy &secrecy )
+{
+ return s << secrecy.mType;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Secrecy &secrecy )
+{
+ s >> secrecy.mType;
+
+ return s;
+}
diff --git a/kabc/secrecy.h b/kabc/secrecy.h
new file mode 100644
index 0000000..8f2f736
--- a/dev/null
+++ b/kabc/secrecy.h
@@ -0,0 +1,102 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_SECRECY_H
+#define KABC_SECRECY_H
+
+#include <qvaluelist.h>
+
+namespace KABC {
+
+class Secrecy
+{
+ friend QDataStream &operator<<( QDataStream &, const Secrecy & );
+ friend QDataStream &operator>>( QDataStream &, Secrecy & );
+
+public:
+ typedef QValueList<int> TypeList;
+
+ /**
+ * Secrecy types
+ *
+ * @li Public - for public access
+ * @li Private - only private access
+ * @li Confidential - access for confidential persons
+ */
+ enum Types {
+ Public,
+ Private,
+ Confidential,
+ Invalid
+ };
+
+ /**
+ * Constructor.
+ *
+ * @param type The secrecy type, @see Types.
+ */
+ Secrecy( int type = Invalid );
+
+ bool operator==( const Secrecy & ) const;
+ bool operator!=( const Secrecy & ) const;
+
+ /**
+ Returns if the Secrecy object has a valid value.
+ */
+ bool isValid() const;
+
+ /**
+ * Sets the type, @see Types.
+ */
+ void setType( int type );
+
+ /**
+ * Returns the type, @see Types.
+ */
+ int type() const;
+
+ /**
+ * Returns a list of all available secrecy types.
+ */
+ static TypeList typeList();
+
+ /**
+ * Returns a translated label for a given secrecy type.
+ */
+ static QString typeLabel( int type );
+
+ /**
+ * For debug.
+ */
+ QString asString() const;
+
+private:
+ int mType;
+};
+
+}
+#endif
diff --git a/kabc/sound.cpp b/kabc/sound.cpp
new file mode 100644
index 0000000..b2e5254
--- a/dev/null
+++ b/kabc/sound.cpp
@@ -0,0 +1,117 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk changes
+
+$Id$
+*/
+
+#include "sound.h"
+
+#include <qdatastream.h>
+
+using namespace KABC;
+
+Sound::Sound()
+ : mIntern( false )
+{
+}
+
+Sound::Sound( const QString &url )
+ : mUrl( url ), mIntern( false )
+{
+}
+
+Sound::Sound( const QByteArray &data )
+ : mData( data ), mIntern( true )
+{
+}
+
+Sound::~Sound()
+{
+}
+
+bool Sound::operator==( const Sound &s ) const
+{
+ if ( mIntern != s.mIntern ) return false;
+
+ if ( mIntern ) {
+ if ( mData != s.mData )
+ return false;
+ } else {
+ if ( mUrl != s.mUrl )
+ return false;
+ }
+
+ return true;
+}
+
+bool Sound::operator!=( const Sound &s ) const
+{
+ return !( s == *this );
+}
+
+void Sound::setUrl( const QString &url )
+{
+ mUrl = url;
+ mIntern = false;
+}
+
+void Sound::setData( const QByteArray &data )
+{
+ mData = data;
+ mIntern = true;
+}
+
+bool Sound::isIntern() const
+{
+ return mIntern;
+}
+
+QString Sound::url() const
+{
+ return mUrl;
+}
+
+QByteArray Sound::data() const
+{
+ return mData;
+}
+
+QString Sound::asString() const
+{
+ if ( mIntern )
+ return "intern sound";
+ else
+ return mUrl;
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Sound &sound )
+{
+ return s << sound.mIntern << sound.mUrl << sound.mData;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Sound &sound )
+{
+ s >> sound.mIntern >> sound.mUrl >> sound.mData;
+ return s;
+}
diff --git a/kabc/sound.h b/kabc/sound.h
new file mode 100644
index 0000000..0ec5ec8
--- a/dev/null
+++ b/kabc/sound.h
@@ -0,0 +1,123 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_SOUND_H
+#define KABC_SOUND_H
+
+#include <qcstring.h>
+#include <qstring.h>
+
+namespace KABC {
+
+class Sound
+{
+ friend QDataStream &operator<<( QDataStream &, const Sound & );
+ friend QDataStream &operator>>( QDataStream &, Sound & );
+
+public:
+
+ /**
+ * Consturctor. Creates an empty object.
+ */
+ Sound();
+
+ /**
+ * Consturctor.
+ *
+ * @param url A URL that describes the position of the sound file.
+ */
+ Sound( const QString &url );
+
+ /**
+ * Consturctor.
+ *
+ * @param data The raw data of the sound.
+ */
+ Sound( const QByteArray &data );
+
+ /**
+ * Destructor.
+ */
+ ~Sound();
+
+
+ bool operator==( const Sound & ) const;
+ bool operator!=( const Sound & ) const;
+
+ /**
+ * Sets a URL for the location of the sound file. When using this
+ * function, @ref isIntern() will return 'false' until you use
+ * @ref setData().
+ *
+ * @param url The location URL of the sound file.
+ */
+ void setUrl( const QString &url );
+
+ /**
+ * Sets the raw data of the sound. When using this function,
+ * @ref isIntern() will return 'true' until you use @ref setUrl().
+ *
+ * @param data The raw data of the sound.
+ */
+ void setData( const QByteArray &data );
+
+ /**
+ * Returns whether the sound is described by a URL (extern) or
+ * by the raw data (intern).
+ * When this method returns 'true' you can use @ref data() to
+ * get the raw data. Otherwise you can request the URL of this
+ * sound by @ref url() and load the raw data from that location.
+ */
+ bool isIntern() const;
+
+ /**
+ * Returns the location URL of this sound.
+ */
+ QString url() const;
+
+ /**
+ * Returns the raw data of this sound.
+ */
+ QByteArray data() const;
+
+ /**
+ * Returns string representation of the sound.
+ */
+ QString asString() const;
+
+private:
+ QString mUrl;
+ QByteArray mData;
+
+ int mIntern;
+};
+
+QDataStream &operator<<( QDataStream &, const Sound & );
+QDataStream &operator>>( QDataStream &, Sound & );
+
+}
+#endif
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
new file mode 100644
index 0000000..f9fc70b
--- a/dev/null
+++ b/kabc/stdaddressbook.cpp
@@ -0,0 +1,249 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+#ifndef DESKTOP_VERSION
+#include <qpe/global.h>
+#else
+
+#include <qdir.h>
+#endif
+#ifdef KAB_EMBEDDED
+
+#include <stdlib.h>
+#else //KAB_EMBEDDED
+
+#include <stdlib.h>
+
+//US#include <kresources/manager.h>
+#include <kapplication.h>
+#include <kcrash.h>
+#include <ksimpleconfig.h>
+
+
+#endif //KAB_EMBEDDED
+
+#include "resource.h"
+#include <kresources/manager.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kstaticdeleter.h>
+#include <kstandarddirs.h>
+
+#include "stdaddressbook.h"
+
+using namespace KABC;
+
+StdAddressBook *StdAddressBook::mSelf = 0;
+bool StdAddressBook::mAutomaticSave = true;
+
+static KStaticDeleter<StdAddressBook> addressBookDeleter;
+
+QString StdAddressBook::fileName()
+{
+ return locateLocal( "data", "kabc/std.vcf" );
+}
+
+QString StdAddressBook::directoryName()
+{
+ qDebug("StdAddressBook::directoryName() WILL FAIL OR NOT" );
+ return locateLocal( "data", "kabc/stdvcf" );
+}
+
+void StdAddressBook::handleCrash()
+{
+ StdAddressBook::self()->cleanUp();
+}
+
+StdAddressBook *StdAddressBook::self()
+{
+
+ if ( !mSelf )
+ {
+ QString appdir = StdAddressBook::setTempAppDir();
+
+ kdDebug(5700) << "StdAddressBook::self()" << endl;
+// US im am not sure why I have to use the other format here??
+#ifdef KAB_EMBEDDED
+ mSelf = addressBookDeleter.setObject( new StdAddressBook );
+#else //KAB_EMBEDDED
+ addressBookDeleter.setObject( mSelf, new StdAddressBook );
+#endif //KAB_EMBEDDED
+ KStandardDirs::setAppDir( appdir );
+ }
+
+ return mSelf;
+}
+
+QString StdAddressBook::setTempAppDir()
+{
+ QString appDIR = KStandardDirs::appDir();
+#ifdef DESKTOP_VERSION
+ QString appdir = QDir::homeDirPath();
+ if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
+ appdir += "kaddressbook/";
+ else
+ appdir += "/kaddressbook/";
+ KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
+#else
+ KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) );
+#endif
+
+ return appDIR;
+}
+StdAddressBook *StdAddressBook::self( bool onlyFastResources )
+{
+
+ if ( !mSelf )
+ {
+ QString appdir =StdAddressBook::setTempAppDir();
+#ifdef KAB_EMBEDDED
+ mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
+#else //KAB_EMBEDDED
+ addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
+#endif //KAB_EMBEDDED
+ KStandardDirs::setAppDir( appdir );
+ }
+ return mSelf;
+}
+
+StdAddressBook::StdAddressBook()
+//US : AddressBook( "kabcrc" )
+ : AddressBook( locateLocal( "config", "kabcrc") )
+{
+
+ init( false );
+}
+
+StdAddressBook::StdAddressBook( bool onlyFastResources )
+//US : AddressBook( "kabcrc" )
+ : AddressBook( locateLocal( "config", "kabcrc") )
+{
+
+ init( onlyFastResources );
+}
+
+StdAddressBook::~StdAddressBook()
+{
+ if ( mAutomaticSave )
+ save();
+}
+
+void StdAddressBook::init( bool )
+{
+ KRES::Manager<Resource> *manager = resourceManager();
+ KRES::Manager<Resource>::ActiveIterator it;
+
+ for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
+ (*it)->setAddressBook( this );
+ if ( !(*it)->open() )
+ error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
+ }
+
+ Resource *res = standardResource();
+ if ( !res ) {
+ res = manager->createResource( "file" );
+ if ( res )
+ {
+ addResource( res );
+ }
+ else
+ kdDebug(5700) << "No resource available!!!" << endl;
+ }
+
+ setStandardResource( res );
+ manager->writeConfig();
+
+ load();
+}
+
+bool StdAddressBook::save()
+{
+ kdDebug(5700) << "StdAddressBook::save()" << endl;
+
+ bool ok = true;
+ AddressBook *ab = self();
+
+ ab->deleteRemovedAddressees();
+
+ KRES::Manager<Resource>::ActiveIterator it;
+ KRES::Manager<Resource> *manager = ab->resourceManager();
+ for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
+ if ( !(*it)->readOnly() && (*it)->isOpen() ) {
+ Ticket *ticket = ab->requestSaveTicket( *it );
+// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
+ if ( !ticket ) {
+ ab->error( i18n( "Unable to save to resource '%1'. It is locked." )
+ .arg( (*it)->resourceName() ) );
+ return false;
+ }
+
+ if ( !ab->save( ticket ) )
+ ok = false;
+ }
+ }
+
+ return ok;
+}
+
+void StdAddressBook::close()
+{
+//US destructObject is not defined on my system???. Is setObject(0) the same ???
+#ifndef KAB_EMBEDDED
+ addressBookDeleter.destructObject();
+#else //KAB_EMBEDDED
+ addressBookDeleter.setObject(0);
+#endif //KAB_EMBEDDED
+
+}
+
+void StdAddressBook::setAutomaticSave( bool enable )
+{
+ mAutomaticSave = enable;
+}
+
+bool StdAddressBook::automaticSave()
+{
+ return mAutomaticSave;
+}
+
+// should get const for 4.X
+Addressee StdAddressBook::whoAmI()
+{
+//US KConfig config( "kabcrc" );
+ KConfig config( locateLocal("config", "kabcrc") );
+ config.setGroup( "General" );
+
+ return findByUid( config.readEntry( "WhoAmI" ) );
+}
+
+void StdAddressBook::setWhoAmI( const Addressee &addr )
+{
+//US KConfig config( "kabcrc" );
+ KConfig config( locateLocal("config", "kabcrc") );
+ config.setGroup( "General" );
+
+ config.writeEntry( "WhoAmI", addr.uid() );
+}
diff --git a/kabc/stdaddressbook.h b/kabc/stdaddressbook.h
new file mode 100644
index 0000000..9ec53b0
--- a/dev/null
+++ b/kabc/stdaddressbook.h
@@ -0,0 +1,151 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_STDADDRESSBOOK_H
+#define KABC_STDADDRESSBOOK_H
+
+#include "addressbook.h"
+
+namespace KABC {
+
+/**
+ Standard KDE address book
+
+ This class provides access to the standard KDE address book shared by all
+ applications.
+
+ It's implemented as a singleton. Use @ref self() to get the address book
+ object. On the first self() call the address book also gets loaded.
+
+ Example:
+
+ <pre>
+ KABC::AddressBook *ab = KABC::StdAddressBook::self();
+
+ KABC::AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it ) {
+ kdDebug() << "UID=" << (*it).uid() << endl;
+
+ // do some other stuff
+ }
+
+ KABC::StdAddressBook::save();
+ </pre>
+*/
+class StdAddressBook : public AddressBook
+{
+ public:
+
+ /**
+ Destructor.
+ */
+ ~StdAddressBook();
+
+ /**
+ Return the standard addressbook object. It also loads slow resources.
+ It is the same as self(false); .
+ */
+ static StdAddressBook *self();
+
+ /**
+ This is the same as above, but with specified
+ behaviour of resource loading.
+
+ @param onlyFastResource Only resources marked as 'fast' should be loaded
+ */
+ // FIXME for KDE4 return StdAddressBook and merge with the metod above -zecke
+ static StdAddressBook *self( bool onlyFastResources );
+
+ /**
+ Save the standard address book to disk.
+ */
+ static bool save();
+
+ /**
+ Call this method in your crash handler to allow the library clean up
+ possible locks.
+ */
+ static void handleCrash();
+
+ /**
+ Returns the default file name for vcard-based addressbook
+ */
+ static QString fileName();
+
+ /**
+ Returns the default directory name for vcard-based addressbook
+ */
+ static QString directoryName();
+
+ /**
+ Set the automatic save property of the address book.
+ If @p enable is TRUE (default) the address book is saved at
+ destruction time otherwise you have to call @ref save() to
+ explicitely save it.
+ */
+ static void setAutomaticSave( bool enable );
+
+ /**
+ Closes the address book. Depending on @ref automaticSave() it will
+ save the address book first.
+ */
+ static void close();
+
+ /**
+ Returns whether the address book is saved at destruction time.
+ See also @ref setAutomaticSave().
+ */
+ static bool automaticSave();
+
+ /**
+ Returns the contact, that is associated with the owner of the
+ address book. This contact should be used by other programs
+ to access user specific data.
+ */
+ Addressee whoAmI();
+
+ /**
+ Sets the users contact. See @ref whoAmI() for more information.
+
+ @param uid The uid of the users contact.
+ */
+ void setWhoAmI( const Addressee &addr );
+
+ protected:
+ StdAddressBook();
+ StdAddressBook( bool onlyFastResources );
+
+ void init( bool onlyFastResources );
+
+ private:
+ static QString setTempAppDir();
+ static StdAddressBook *mSelf;
+ static bool mAutomaticSave;
+};
+
+}
+#endif
diff --git a/kabc/timezone.cpp b/kabc/timezone.cpp
new file mode 100644
index 0000000..2018395
--- a/dev/null
+++ b/kabc/timezone.cpp
@@ -0,0 +1,92 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qdatastream.h>
+
+#include "timezone.h"
+
+using namespace KABC;
+
+TimeZone::TimeZone() :
+ mOffset( 0 ), mValid( false )
+{
+}
+
+TimeZone::TimeZone( int offset ) :
+ mOffset( offset ), mValid( true )
+{
+}
+
+void TimeZone::setOffset( int offset )
+{
+ mOffset = offset;
+ mValid = true;
+}
+
+int TimeZone::offset() const
+{
+ return mOffset;
+}
+
+bool TimeZone::isValid() const
+{
+ return mValid;
+}
+
+bool TimeZone::operator==( const TimeZone &t ) const
+{
+ if ( !t.isValid() && !isValid() ) return true;
+ if ( !t.isValid() || !isValid() ) return false;
+ if ( t.mOffset == mOffset ) return true;
+ return false;
+}
+
+bool TimeZone::operator!=( const TimeZone &t ) const
+{
+ if ( !t.isValid() && !isValid() ) return false;
+ if ( !t.isValid() || !isValid() ) return true;
+ if ( t.mOffset != mOffset ) return true;
+ return false;
+}
+
+QString TimeZone::asString() const
+{
+ return QString::number( mOffset );
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const TimeZone &zone )
+{
+ return s << zone.mOffset;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, TimeZone &zone )
+{
+ s >> zone.mOffset;
+ zone.mValid = true;
+
+ return s;
+}
diff --git a/kabc/timezone.h b/kabc/timezone.h
new file mode 100644
index 0000000..8d96e03
--- a/dev/null
+++ b/kabc/timezone.h
@@ -0,0 +1,94 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_TIMEZONE_H
+#define KABC_TIMEZONE_H
+
+#include <qstring.h>
+
+namespace KABC {
+
+/**
+ * @short Time zone information.
+ *
+ * This class stores information about a time zone.
+ */
+class TimeZone
+{
+ friend QDataStream &operator<<( QDataStream &, const TimeZone & );
+ friend QDataStream &operator>>( QDataStream &, TimeZone & );
+
+public:
+
+ /**
+ * Construct invalid time zone.
+ */
+ TimeZone();
+
+ /**
+ * Construct time zone.
+ *
+ * @param offset Offset in minutes relative to UTC.
+ */
+ TimeZone( int offset );
+
+ /**
+ * Set time zone offset relative to UTC.
+ *
+ * @param offset Offset in minutes.
+ */
+ void setOffset( int );
+
+ /**
+ * Return offset in minutes relative to UTC.
+ */
+ int offset() const;
+
+ /**
+ * Return, if this time zone object is valid.
+ */
+ bool isValid() const;
+
+ bool operator==( const TimeZone & ) const;
+ bool operator!=( const TimeZone & ) const;
+
+ /**
+ * Return string representation of time zone offset.
+ */
+ QString asString() const;
+
+private:
+ int mOffset; // Offset in minutes
+
+ bool mValid;
+};
+
+QDataStream &operator<<( QDataStream &, const TimeZone & );
+QDataStream &operator>>( QDataStream &, TimeZone & );
+
+}
+#endif
diff --git a/kabc/vcard/AdrParam.cpp b/kabc/vcard/AdrParam.cpp
new file mode 100644
index 0000000..fa46499
--- a/dev/null
+++ b/kabc/vcard/AdrParam.cpp
@@ -0,0 +1,126 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardRToken.h>
+#include <VCardAdrParam.h>
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+AdrParam::AdrParam()
+ : Param()
+{
+}
+
+AdrParam::AdrParam(const AdrParam & x)
+ : Param(x),
+ adrTypeList_ (x.adrTypeList_)
+{
+}
+
+AdrParam::AdrParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ AdrParam &
+AdrParam::operator = (AdrParam & x)
+{
+ if (*this == x) return *this;
+
+ adrTypeList_ = x.adrTypeList();
+ textParam_ = x.textParam();
+
+ Param::operator = (x);
+ return *this;
+}
+
+ AdrParam &
+AdrParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+
+ adrTypeList_.clear();
+ textParam_.truncate(0);
+
+ return *this;
+}
+
+ bool
+AdrParam::operator == (AdrParam & x)
+{
+ parse();
+
+ if (!x.textParam().isEmpty())
+ return (x.textParam_ == textParam_);
+
+ if (x.adrTypeList().count() != adrTypeList_.count())
+ return false;
+
+ QStrListIterator it(x.adrTypeList_);
+
+ for (; it.current(); ++it)
+ if (!adrTypeList_.find(it.current()))
+ return false;
+
+ return true;
+}
+
+AdrParam::~AdrParam()
+{
+}
+
+ void
+AdrParam::_parse()
+{
+ adrTypeList_.clear();
+
+ if (strRep_.left(4) != "TYPE") {
+ textParam_ = strRep_;
+ return;
+ }
+
+ if (!strRep_.contains('='))
+ return;
+
+ RTokenise(strRep_, ",", adrTypeList_);
+}
+
+ void
+AdrParam::_assemble()
+{
+ if (!textParam_.isEmpty()) {
+ strRep_ = textParam_;
+ return;
+ }
+
+ QStrListIterator it(adrTypeList_);
+
+ for (; it.current(); ++it) {
+
+ strRep_ += it.current();
+
+ if (it.current() != adrTypeList_.last())
+ strRep_ += ',';
+ }
+}
diff --git a/kabc/vcard/AdrValue.cpp b/kabc/vcard/AdrValue.cpp
new file mode 100644
index 0000000..7ecef33
--- a/dev/null
+++ b/kabc/vcard/AdrValue.cpp
@@ -0,0 +1,140 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardRToken.h>
+#include <VCardAdrValue.h>
+#include <VCardValue.h>
+#include <VCardDefines.h>
+
+using namespace VCARD;
+
+AdrValue::AdrValue()
+ : Value()
+{
+}
+
+AdrValue::AdrValue(const AdrValue & x)
+ : Value(x),
+ poBox_ (x.poBox_),
+ extAddress_ (x.extAddress_),
+ street_ (x.street_),
+ locality_ (x.locality_),
+ region_ (x.region_),
+ postCode_ (x.postCode_),
+ countryName_ (x.countryName_)
+{
+}
+
+AdrValue::AdrValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ AdrValue &
+AdrValue::operator = (AdrValue & x)
+{
+ if (*this == x) return *this;
+
+ poBox_ = x.poBox_;
+ extAddress_ = x.extAddress_;
+ street_ = x.street_;
+ locality_ = x.locality_;
+ region_ = x.region_;
+ postCode_ = x.postCode_;
+ countryName_ = x.countryName_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ AdrValue &
+AdrValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+AdrValue::operator == (AdrValue & x)
+{
+ parse();
+ x.parse();
+
+ return (
+ poBox_ == x.poBox_ &&
+ extAddress_ == x.extAddress_ &&
+ street_ == x.street_ &&
+ locality_ == x.locality_ &&
+ region_ == x.region_ &&
+ postCode_ == x.postCode_ &&
+ countryName_ == x.countryName_);
+}
+
+AdrValue::~AdrValue()
+{
+}
+
+ AdrValue *
+AdrValue::clone()
+{
+ return new AdrValue( *this );
+}
+
+ void
+AdrValue::_parse()
+{
+ vDebug("AdrValue::_parse()");
+
+ QStrList l;
+ RTokenise(strRep_, ";", l);
+
+ for (unsigned int i = 0; i < l.count(); i++) {
+
+ switch (i) {
+
+ case 0: poBox_ = l.at(0); break;
+ case 1: extAddress_ = l.at(1); break;
+ case 2: street_ = l.at(2); break;
+ case 3: locality_ = l.at(3); break;
+ case 4: region_ = l.at(4); break;
+ case 5: postCode_ = l.at(5); break;
+ case 6: countryName_ = l.at(6); break;
+ default: break;
+ }
+ }
+}
+
+ void
+AdrValue::_assemble()
+{
+ vDebug("AdrValue::_assemble");
+
+ strRep_ = poBox_;
+ strRep_ += ";" + extAddress_;
+ strRep_ += ";" + street_;
+ strRep_ += ";" + locality_;
+ strRep_ += ";" + region_;
+ strRep_ += ";" + postCode_;
+ strRep_ += ";" + countryName_;
+}
+
diff --git a/kabc/vcard/AgentParam.cpp b/kabc/vcard/AgentParam.cpp
new file mode 100644
index 0000000..5625e00
--- a/dev/null
+++ b/kabc/vcard/AgentParam.cpp
@@ -0,0 +1,103 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardAgentParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+AgentParam::AgentParam()
+ : Param()
+{
+}
+
+AgentParam::AgentParam(const AgentParam & x)
+ : Param(x),
+ refer_ (x.refer_),
+ uri_ (x.uri_)
+{
+}
+
+AgentParam::AgentParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ AgentParam &
+AgentParam::operator = (AgentParam & x)
+{
+ if (*this == x) return *this;
+
+ refer_ = x.refer_;
+ uri_ = x.uri_;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ AgentParam &
+AgentParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+AgentParam::operator == (AgentParam & x)
+{
+ parse();
+
+ if (refer_)
+ return (x.refer() && uri_ == x.uri_);
+
+ return !x.refer();
+}
+
+AgentParam::~AgentParam()
+{
+}
+
+ void
+AgentParam::_parse()
+{
+ if (strRep_.isEmpty()) {
+ refer_ = false;
+ return;
+ }
+
+ refer_ = true;
+ uri_ = strRep_;
+}
+
+ void
+AgentParam::_assemble()
+{
+ if (!refer_) {
+ strRep_.truncate(0);
+ return;
+ }
+
+ strRep_ = uri_.asString();
+ return;
+}
diff --git a/kabc/vcard/AgentValue.cpp b/kabc/vcard/AgentValue.cpp
new file mode 100644
index 0000000..bccde80
--- a/dev/null
+++ b/kabc/vcard/AgentValue.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardAgentValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+AgentValue::AgentValue()
+ : Value()
+{
+}
+
+AgentValue::AgentValue(const AgentValue & x)
+ : Value(x)
+{
+}
+
+AgentValue::AgentValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ AgentValue &
+AgentValue::operator = (AgentValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ AgentValue &
+AgentValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+AgentValue::operator == (AgentValue & x)
+{
+ x.parse();
+ return false;
+}
+
+AgentValue::~AgentValue()
+{
+}
+
+ void
+AgentValue::_parse()
+{
+}
+
+ void
+AgentValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/ClassValue.cpp b/kabc/vcard/ClassValue.cpp
new file mode 100644
index 0000000..f01e5a6
--- a/dev/null
+++ b/kabc/vcard/ClassValue.cpp
@@ -0,0 +1,120 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardClassValue.h>
+
+#include <VCardValue.h>
+
+#include <kdebug.h>
+
+using namespace VCARD;
+
+ClassValue::ClassValue()
+ : Value()
+{
+}
+
+ClassValue::ClassValue(const ClassValue & x)
+ : Value(x),
+ classType_(x.classType_)
+{
+}
+
+ClassValue::ClassValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ ClassValue &
+ClassValue::operator = (ClassValue & x)
+{
+ if (*this == x) return *this;
+ x.parse();
+
+ classType_ = x.classType_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ ClassValue &
+ClassValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+ClassValue::operator == (ClassValue & x)
+{
+ x.parse();
+ return ( classType_ == x.classType_ );
+}
+
+ClassValue::~ClassValue()
+{
+}
+
+ ClassValue *
+ClassValue::clone()
+{
+ return new ClassValue( *this );
+}
+
+ void
+ClassValue::_parse()
+{
+ if (qstricmp(strRep_, "PUBLIC") == 0)
+ classType_ = Public;
+
+ else if (qstricmp(strRep_, "PRIVATE") == 0)
+ classType_ = Private;
+
+ else if (qstricmp(strRep_, "CONFIDENTIAL") == 0)
+ classType_ = Confidential;
+
+ else classType_ = Other;
+}
+
+ void
+ClassValue::_assemble()
+{
+ switch (classType_) {
+
+ case Public:
+ strRep_ = "PUBLIC";
+ break;
+
+ case Private:
+ strRep_ = "PRIVATE";
+ break;
+
+ case Confidential:
+ strRep_ = "CONFIDENTIAL";
+ break;
+
+ default:
+ break;
+ }
+}
+
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp
new file mode 100644
index 0000000..6fa1a8f
--- a/dev/null
+++ b/kabc/vcard/ContentLine.cpp
@@ -0,0 +1,289 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <qcstring.h>
+#include <qstrlist.h>
+#include <qregexp.h>
+
+#include <kdebug.h>
+
+#include <VCardAdrParam.h>
+#include <VCardAgentParam.h>
+#include <VCardDateParam.h>
+#include <VCardEmailParam.h>
+#include <VCardImageParam.h>
+#include <VCardSourceParam.h>
+#include <VCardTelParam.h>
+#include <VCardTextBinParam.h>
+#include <VCardTextParam.h>
+
+#include <VCardAdrValue.h>
+#include <VCardAgentValue.h>
+#include <VCardDateValue.h>
+#include <VCardImageValue.h>
+#include <VCardTextValue.h>
+#include <VCardTextBinValue.h>
+#include <VCardLangValue.h>
+#include <VCardNValue.h>
+#include <VCardURIValue.h>
+#include <VCardSoundValue.h>
+#include <VCardClassValue.h>
+#include <VCardFloatValue.h>
+#include <VCardOrgValue.h>
+#include <VCardTelValue.h>
+#include <VCardTextListValue.h>
+#include <VCardUTCValue.h>
+#include <VCardGeoValue.h>
+
+#include <VCardRToken.h>
+#include <VCardContentLine.h>
+
+#include <VCardEntity.h>
+#include <VCardEnum.h>
+#include <VCardDefines.h>
+
+using namespace VCARD;
+
+ContentLine::ContentLine()
+ : Entity(),
+ value_(0)
+{
+}
+
+ContentLine::ContentLine(const ContentLine & x)
+ : Entity(x),
+ group_ (x.group_),
+ name_ (x.name_),
+ paramList_(x.paramList_),
+ value_(x.value_->clone())
+{
+}
+
+ContentLine::ContentLine(const QCString & s)
+ : Entity(s),
+ value_(0)
+{
+}
+
+ ContentLine &
+ContentLine::operator = (ContentLine & x)
+{
+ if (*this == x) return *this;
+
+ paramList_ = x.paramList();
+ value_ = x.value_->clone();
+
+ Entity::operator = (x);
+ return *this;
+}
+
+ ContentLine &
+ContentLine::operator = (const QCString & s)
+{
+ Entity::operator = (s);
+ delete value_;
+ value_ = 0;
+ return *this;
+}
+
+ bool
+ContentLine::operator == (ContentLine & x)
+{
+ x.parse();
+
+ QPtrListIterator<Param> it(x.paramList());
+
+ if (!paramList_.find(it.current()))
+ return false;
+
+ return true;
+}
+
+ContentLine::~ContentLine()
+{
+ delete value_;
+ value_ = 0;
+}
+
+ void
+ContentLine::_parse()
+{
+ vDebug("parse");
+
+ // Unqote newlines
+ strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" );
+
+ int split = strRep_.find(':');
+
+ if (split == -1) { // invalid content line
+ vDebug("No ':'");
+ return;
+ }
+
+ QCString firstPart(strRep_.left(split));
+ QCString valuePart(strRep_.mid(split + 1));
+
+ split = firstPart.find('.');
+
+ if (split != -1) {
+ group_ = firstPart.left(split);
+ firstPart = firstPart.mid(split + 1);
+ }
+
+ vDebug("Group == " + group_);
+ vDebug("firstPart == " + firstPart);
+ vDebug("valuePart == " + valuePart);
+
+ // Now we have the group, the name and param list together and the value.
+
+ QStrList l;
+
+ RTokenise(firstPart, ";", l);
+
+ if (l.count() == 0) {// invalid - no name !
+ vDebug("No name for this content line !");
+ return;
+ }
+
+ name_ = l.at(0);
+
+ // Now we have the name, so the rest of 'l' is the params.
+ // Remove the name part.
+ l.remove(0u);
+
+ entityType_ = EntityNameToEntityType(name_);
+ paramType_ = EntityTypeToParamType(entityType_);
+
+ unsigned int i = 0;
+
+ // For each parameter, create a new parameter of the correct type.
+
+ QStrListIterator it(l);
+
+ for (; it.current(); ++it, i++) {
+
+ QCString str = *it;
+
+ split = str.find("=");
+ if (split < 0 ) {
+ vDebug("No '=' in paramter.");
+ continue;
+ }
+
+ QCString paraName = str.left(split);
+ QCString paraValue = str.mid(split + 1);
+
+ QStrList paraValues;
+ RTokenise(paraValue, ",", paraValues);
+
+ QStrListIterator it2( paraValues );
+
+ for(; it2.current(); ++it2) {
+
+ Param *p = new Param;
+ p->setName( paraName );
+ p->setValue( *it2 );
+
+ paramList_.append(p);
+ }
+ }
+
+ // Create a new value of the correct type.
+
+ valueType_ = EntityTypeToValueType(entityType_);
+
+// kdDebug(5710) << "valueType: " << valueType_ << endl;
+
+ switch (valueType_) {
+
+ case ValueSound: value_ = new SoundValue; break;
+ case ValueAgent: value_ = new AgentValue; break;
+ case ValueAddress: value_ = new AdrValue; break;
+ case ValueTel: value_ = new TelValue; break;
+ case ValueTextBin: value_ = new TextBinValue; break;
+ case ValueOrg: value_ = new OrgValue; break;
+ case ValueN: value_ = new NValue; break;
+ case ValueUTC: value_ = new UTCValue; break;
+ case ValueURI: value_ = new URIValue; break;
+ case ValueClass: value_ = new ClassValue; break;
+ case ValueFloat: value_ = new FloatValue; break;
+ case ValueImage: value_ = new ImageValue; break;
+ case ValueDate: value_ = new DateValue; break;
+ case ValueTextList: value_ = new TextListValue; break;
+ case ValueGeo: value_ = new GeoValue; break;
+ case ValueText:
+ case ValueUnknown:
+ default: value_ = new TextValue; break;
+ }
+
+ *value_ = valuePart;
+}
+
+ void
+ContentLine::_assemble()
+{
+ vDebug("Assemble (argl) - my name is \"" + name_ + "\"");
+ strRep_.truncate(0);
+
+ QCString line;
+
+ if (!group_.isEmpty())
+ line += group_ + '.';
+
+ line += name_;
+
+ vDebug("Adding parameters");
+ ParamListIterator it(paramList_);
+
+ for (; it.current(); ++it)
+ line += ";" + it.current()->asString();
+
+ vDebug("Adding value");
+ if (value_ != 0)
+ line += ":" + value_->asString();
+ else
+ vDebug("No value");
+
+ // Quote newlines
+ line = line.replace( QRegExp( "\n" ), "\\n" );
+
+ // Fold lines longer than 72 chars
+ const int maxLen = 72;
+ uint cursor = 0;
+ while( line.length() > ( cursor + 1 ) * maxLen ) {
+ strRep_ += line.mid( cursor * maxLen, maxLen );
+ strRep_ += "\r\n ";
+ ++cursor;
+ }
+ strRep_ += line.mid( cursor * maxLen );
+}
+
+ void
+ContentLine::clear()
+{
+ group_.truncate(0);
+ name_.truncate(0);
+ paramList_.clear();
+ delete value_;
+ value_ = 0;
+}
diff --git a/kabc/vcard/DateParam.cpp b/kabc/vcard/DateParam.cpp
new file mode 100644
index 0000000..52af089
--- a/dev/null
+++ b/kabc/vcard/DateParam.cpp
@@ -0,0 +1,82 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardDateParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+DateParam::DateParam()
+ : Param()
+{
+}
+
+DateParam::DateParam(const DateParam & x)
+ : Param(x)
+{
+}
+
+DateParam::DateParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ DateParam &
+DateParam::operator = (DateParam & x)
+{
+ if (*this == x) return *this;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ DateParam &
+DateParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+DateParam::operator == (DateParam & x)
+{
+ x.parse();
+
+ return false;
+}
+
+DateParam::~DateParam()
+{
+}
+
+ void
+DateParam::_parse()
+{
+}
+
+ void
+DateParam::_assemble()
+{
+}
+
diff --git a/kabc/vcard/DateValue.cpp b/kabc/vcard/DateValue.cpp
new file mode 100644
index 0000000..c5c5c85
--- a/dev/null
+++ b/kabc/vcard/DateValue.cpp
@@ -0,0 +1,434 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <qregexp.h>
+
+#include <kdebug.h>
+
+#include <VCardDefines.h>
+#include <VCardDateValue.h>
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+DateValue::DateValue()
+ : Value()
+{
+ vDebug("DateValue::DateValue()");
+}
+
+DateValue::DateValue(
+ unsigned int year,
+ unsigned int month,
+ unsigned int day,
+ unsigned int hour,
+ unsigned int minute,
+ unsigned int second,
+ double secFrac,
+ bool zonePositive,
+ unsigned int zoneHour,
+ unsigned int zoneMinute)
+ : Value (),
+ year_ (year),
+ month_ (month),
+ day_ (day),
+ hour_ (hour),
+ minute_ (minute),
+ second_ (second),
+ zoneHour_ (zoneHour),
+ zoneMinute_ (zoneMinute),
+ secFrac_ (secFrac),
+ zonePositive_ (zonePositive),
+ hasTime_(true)
+{
+ parsed_ = true;
+ assembled_ = false;
+}
+
+DateValue::DateValue(const QDate & d)
+ : Value (),
+ year_ (d.year()),
+ month_ (d.month()),
+ day_ (d.day()),
+ hasTime_(false)
+{
+ parsed_ = true;
+ assembled_ = false;
+}
+
+DateValue::DateValue(const QDateTime & d)
+ : Value (),
+ year_ (d.date().year()),
+ month_ (d.date().month()),
+ day_ (d.date().day()),
+ hour_ (d.time().hour()),
+ minute_ (d.time().minute()),
+ second_ (d.time().second()),
+ hasTime_(true)
+{
+ parsed_ = true;
+ assembled_ = false;
+}
+
+DateValue::DateValue(const DateValue & x)
+ : Value(x)
+{
+ year_ = x.year_;
+ month_ = x.month_;
+ day_ = x.day_;
+ hour_ = x.hour_;
+ minute_ = x.minute_;
+ second_ = x.second_;
+ zoneHour_ = x.zoneHour_;
+ zoneMinute_ = x.zoneMinute_;
+ secFrac_ = x.secFrac_;
+ hasTime_ = x.hasTime_;
+}
+
+DateValue::DateValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ DateValue &
+DateValue::operator = (DateValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ DateValue &
+DateValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+DateValue::operator == (DateValue & x)
+{
+ x.parse();
+ return false;
+}
+
+DateValue::~DateValue()
+{
+}
+
+ DateValue *
+DateValue::clone()
+{
+ return new DateValue( *this );
+}
+
+ void
+DateValue::_parse()
+{
+ vDebug("DateValue::_parse()");
+
+ // date = date-full-year ["-"] date-month ["-"] date-mday
+ // time = time-hour [":"] time-minute [":"] time-second [":"]
+ // [time-secfrac] [time-zone]
+
+ int timeSep = strRep_.find('T');
+
+ QCString dateStr;
+ QCString timeStr;
+
+ if (timeSep == -1) {
+
+ dateStr = strRep_;
+ vDebug("Has date string \"" + dateStr + "\"");
+
+ } else {
+
+ dateStr = strRep_.left(timeSep);
+ vDebug("Has date string \"" + dateStr + "\"");
+
+ timeStr = strRep_.mid(timeSep + 1);
+ vDebug("Has time string \"" + timeStr + "\"");
+ }
+
+ /////////////////////////////////////////////////////////////// DATE
+
+ dateStr.replace(QRegExp("-"), "");
+
+ kdDebug(5710) << "dateStr: " << dateStr << endl;
+
+ year_ = dateStr.left(4).toInt();
+ month_ = dateStr.mid(4, 2).toInt();
+ day_ = dateStr.right(2).toInt();
+
+ if (timeSep == -1) {
+ hasTime_ = false;
+ return; // No time, done.
+ }
+ else
+ hasTime_ = true;
+
+ /////////////////////////////////////////////////////////////// TIME
+
+ /////////////////////////////////////////////////////////////// ZONE
+
+ int zoneSep = timeStr.find('Z');
+
+ if (zoneSep != -1 && timeStr.length() - zoneSep > 3) {
+
+ QCString zoneStr(timeStr.mid(zoneSep + 1));
+ vDebug("zoneStr == " + zoneStr);
+
+ zonePositive_ = (zoneStr[0] == '+');
+ zoneHour_ = zoneStr.mid(1, 2).toInt();
+ zoneMinute_ = zoneStr.right(2).toInt();
+
+ timeStr.remove(zoneSep, timeStr.length() - zoneSep);
+ }
+
+ //////////////////////////////////////////////////// SECOND FRACTION
+
+ int secFracSep = timeStr.findRev(',');
+
+ if (secFracSep != -1 && zoneSep != -1) { // zoneSep checked to avoid errors.
+ QCString quirkafleeg = "0." + timeStr.mid(secFracSep + 1, zoneSep);
+ secFrac_ = quirkafleeg.toDouble();
+ }
+
+ /////////////////////////////////////////////////////////////// HMS
+
+ timeStr.replace(QRegExp(":"), "");
+
+ hour_ = timeStr.left(2).toInt();
+ minute_ = timeStr.mid(2, 2).toInt();
+ second_ = timeStr.mid(4, 2).toInt();
+}
+
+ void
+DateValue::_assemble()
+{
+ vDebug("DateValue::_assemble");
+
+ QCString year;
+ QCString month;
+ QCString day;
+
+ year.setNum( year_ );
+ month.setNum( month_ );
+ day.setNum( day_ );
+
+ if ( month.length() < 2 ) month.prepend( "0" );
+ if ( day.length() < 2 ) day.prepend( "0" );
+
+ strRep_ = year + '-' + month + '-' + day;
+
+ if ( hasTime_ ) {
+ QCString hour;
+ QCString minute;
+ QCString second;
+
+ hour.setNum( hour_ );
+ minute.setNum( minute_ );
+ second.setNum( second_ );
+
+ if ( hour.length() < 2 ) hour.prepend( "0" );
+ if ( minute.length() < 2 ) minute.prepend( "0" );
+ if ( second.length() < 2 ) second.prepend( "0" );
+
+ strRep_ += 'T' + hour + ':' + minute + ':' + second + 'Z';
+ }
+}
+
+ unsigned int
+DateValue::year()
+{
+ parse();
+ return year_;
+}
+
+ unsigned int
+DateValue::month()
+{
+ parse();
+ return month_;
+}
+
+ unsigned int
+DateValue::day()
+{
+ parse();
+ return day_;
+}
+ unsigned int
+DateValue::hour()
+{
+ parse();
+ return hour_;
+}
+
+ unsigned int
+DateValue::minute()
+{
+ parse();
+ return minute_;
+}
+
+ unsigned int
+DateValue::second()
+{
+ parse();
+ return second_;
+}
+
+ double
+DateValue::secondFraction()
+{
+ parse();
+ return secFrac_;
+}
+
+ bool
+DateValue::zonePositive()
+{
+ parse();
+ return zonePositive_;
+}
+
+ unsigned int
+DateValue::zoneHour()
+{
+ parse();
+ return zoneHour_;
+}
+
+ unsigned int
+DateValue::zoneMinute()
+{
+ parse();
+ return zoneMinute_;
+}
+
+ void
+DateValue::setYear(unsigned int i)
+{
+ year_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setMonth(unsigned int i)
+{
+ month_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setDay(unsigned int i)
+{
+ day_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setHour(unsigned int i)
+{
+ hour_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setMinute(unsigned int i)
+{
+ minute_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setSecond(unsigned int i)
+{
+ second_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setSecondFraction(double d)
+{
+ secFrac_ = d;
+ assembled_ = false;
+}
+
+ void
+DateValue::setZonePositive(bool b)
+{
+ zonePositive_ = b;
+ assembled_ = false;
+}
+
+ void
+DateValue::setZoneHour(unsigned int i)
+{
+ zoneHour_ = i;
+ assembled_ = false;
+}
+
+ void
+DateValue::setZoneMinute(unsigned int i)
+{
+ zoneMinute_ = i;
+ assembled_ = false;
+}
+
+ QDate
+DateValue::qdate()
+{
+ parse();
+ QDate d(year_, month_, day_);
+ return d;
+}
+
+ QTime
+DateValue::qtime()
+{
+ parse();
+ QTime t(hour_, minute_, second_);
+// t.setMs(1 / secFrac_);
+ return t;
+}
+
+ QDateTime
+DateValue::qdt()
+{
+ parse();
+ QDateTime dt;
+ dt.setDate(qdate());
+ dt.setTime(qtime());
+ return dt;
+}
+
+ bool
+DateValue::hasTime()
+{
+ parse();
+ return hasTime_;
+}
+
diff --git a/kabc/vcard/EmailParam.cpp b/kabc/vcard/EmailParam.cpp
new file mode 100644
index 0000000..8c87477
--- a/dev/null
+++ b/kabc/vcard/EmailParam.cpp
@@ -0,0 +1,116 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardEmailParam.h>
+#include <VCardParam.h>
+#include <VCardDefines.h>
+
+using namespace VCARD;
+
+EmailParam::EmailParam()
+ : Param()
+{
+ vDebug("ctor");
+}
+
+EmailParam::EmailParam(const EmailParam & x)
+ : Param(x),
+ emailType_ (x.emailType_),
+ pref_ (x.pref_)
+{
+}
+
+EmailParam::EmailParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ EmailParam &
+EmailParam::operator = (EmailParam & x)
+{
+ if (*this == x) return *this;
+
+ emailType_ = x.emailType();
+ pref_ = x.pref_;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ EmailParam &
+EmailParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+EmailParam::operator == (EmailParam & x)
+{
+ parse();
+
+ if (pref_)
+ return (x.pref_ && x.emailType() == emailType_);
+
+ return !x.pref();
+}
+
+EmailParam::~EmailParam()
+{
+}
+
+ void
+EmailParam::_parse()
+{
+#if 0
+ Param::parseToList();
+
+ SubParamListIterator it(subParamList_);
+
+ pref_ = true;
+ emailType_ = "";
+
+ for (; it.current(); ++it) {
+
+ if (qstricmp(it.current()->name(), "TYPE") == 0) {
+ emailType_ = it.current()->value();
+ continue;
+ }
+
+ if (qstricmp(it.current()->name(), "PREF") == 0) {
+ pref_ = true;
+ }
+ }
+#endif
+}
+
+ void
+EmailParam::_assemble()
+{
+ strRep_ = "TYPE=";
+ strRep_ += emailType_;
+
+ if (pref_)
+ strRep_ += ",PREF";
+}
+
diff --git a/kabc/vcard/Entity.cpp b/kabc/vcard/Entity.cpp
new file mode 100644
index 0000000..b7d09e0
--- a/dev/null
+++ b/kabc/vcard/Entity.cpp
@@ -0,0 +1,134 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardEntity.h>
+
+using namespace VCARD;
+
+Entity::Entity()
+ : parsed_ (false),
+ assembled_ (true)
+{
+ // empty
+}
+
+Entity::Entity(const Entity & e)
+ : strRep_ (e.strRep_),
+ parsed_ (e.parsed_),
+ assembled_ (e.assembled_)
+{
+ // empty
+}
+
+Entity::Entity(const QCString & s)
+ : strRep_ (s),
+ parsed_ (false),
+ assembled_ (true)
+{
+ // empty
+}
+
+ Entity &
+Entity::operator = (const Entity & e)
+{
+ if (this == &e) return *this;
+
+ strRep_ = e.strRep_;
+ parsed_ = e.parsed_;
+ assembled_ = e.assembled_;
+
+ return *this;
+}
+
+ Entity &
+Entity::operator = (const QCString & s)
+{
+ strRep_ = s;
+ parsed_ = false;
+ assembled_ = true;
+
+ return *this;
+}
+
+ bool
+Entity::operator == (Entity & e)
+{
+ return asString() == e.asString();
+}
+
+ bool
+Entity::operator != (Entity & e)
+{
+ return !(*this == e);
+}
+
+ bool
+Entity::operator == (const QCString & s)
+{
+ return asString() == s;
+}
+
+ bool
+Entity::operator != (const QCString & s)
+{
+ return !(*this == s);
+}
+
+Entity::~Entity()
+{
+ // empty
+}
+
+ QCString
+Entity::asString()
+{
+// vDebug("Entity::asString()");
+ assemble();
+
+ return strRep_;
+}
+
+ void
+Entity::parse()
+{
+// vDebug( "Entity::parse()" );
+
+ if (!parsed_) _parse();
+
+ parsed_ = true;
+ assembled_ = false;
+}
+
+ void
+Entity::assemble()
+{
+// vDebug( "Entity::assemble()" );
+
+ if (assembled_) return;
+
+ parse();
+ _assemble();
+
+ assembled_ = true;
+}
+
diff --git a/kabc/vcard/Enum.cpp b/kabc/vcard/Enum.cpp
new file mode 100644
index 0000000..cc48b5a
--- a/dev/null
+++ b/kabc/vcard/Enum.cpp
@@ -0,0 +1,482 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <qcstring.h>
+#include <ctype.h>
+
+#include <VCardEnum.h>
+
+using namespace VCARD;
+
+// There are 31 possible types, not including extensions.
+ const QCString
+VCARD::paramNames [] =
+{
+ "NAME",
+ "PROFILE",
+ "SOURCE",
+ "FN",
+ "N",
+ "NICKNAME",
+ "PHOTO",
+ "BDAY",
+ "ADR",
+ "LABEL",
+ "TEL",
+ "EMAIL",
+ "MAILER",
+ "TZ",
+ "GEO",
+ "TITLE",
+ "ROLE",
+ "LOGO",
+ "AGENT",
+ "ORG",
+ "CATEGORIES",
+ "NOTE",
+ "PRODID",
+ "REV",
+ "SORT-STRING",
+ "SOUND",
+ "UID",
+ "URL",
+ "VERSION",
+ "CLASS",
+ "KEY"
+};
+
+ const ParamType
+VCARD::paramTypesTable[] = {
+ ParamNone, // NAME
+ ParamNone, // PROFILE
+ ParamSource, // SOURCE
+ ParamText, // FN
+ ParamText, // N
+ ParamText, // NICKNAME
+ ParamImage, // PHOTO (inline/refer)
+ ParamDate, // BDAY ("VALUE = "date-time/date)
+ ParamAddrText, // ADR (adr-param/text-param)
+ ParamAddrText, // LABEL (adr-param/text-param)
+ ParamTel, // TEL
+ ParamEmail, // EMAIL
+ ParamText, // MAILER
+ ParamNone, // TZ
+ ParamNone, // GEO
+ ParamText, // TITLE
+ ParamText, // ROLE
+ ParamImage, // LOGO
+ ParamAgent, // AGENT
+ ParamText, // ORG
+ ParamText, // CATEGORIES
+ ParamText, // NOTE
+ ParamNone, // PRODID
+ ParamDate, // REV
+ ParamText, // SORT-STRING
+ ParamSound, // SOUND
+ ParamNone, // UID
+ ParamNone, // URL
+ ParamNone, // VERSION
+ ParamNone, // CLASS
+ ParamTextBin, // KEY
+ ParamTextNS // X
+};
+
+ ParamType
+VCARD::EntityTypeToParamType(EntityType e)
+{
+ ParamType t(ParamUnknown);
+
+ switch (e) {
+
+ //---------------------------------------------------------------//
+ case EntityAgent: t = ParamAgent; break;
+ //---------------------------------------------------------------//
+ case EntitySound: t = ParamSound; break;
+ //---------------------------------------------------------------//
+ case EntitySource: t = ParamSource; break;
+ //---------------------------------------------------------------//
+ case EntityTelephone: t = ParamTel; break;
+ //---------------------------------------------------------------//
+ case EntityEmail: t = ParamEmail; break;
+ //---------------------------------------------------------------//
+ case EntityKey: t = ParamTextBin; break;
+ //---------------------------------------------------------------//
+ case EntityExtension: t = ParamTextNS; break;
+ //---------------------------------------------------------------//
+ case EntityAddress:
+ case EntityLabel: t = ParamAddrText; break;
+ //---------------------------------------------------------------//
+ case EntityBirthday:
+ case EntityRevision: t = ParamDate; break;
+ //---------------------------------------------------------------//
+ case EntityPhoto:
+ case EntityLogo: t = ParamImage; break;
+ //---------------------------------------------------------------//
+ case EntityOrganisation:
+ case EntityTitle:
+ case EntityRole:
+ case EntityFullName:
+ case EntityMailer:
+ case EntityN:
+ case EntitySortString:
+ case EntityNickname:
+ case EntityCategories:
+ case EntityNote: t = ParamText; break;
+ //---------------------------------------------------------------//
+ case EntityProductID:
+ case EntityTimeZone:
+ case EntityUID:
+ case EntityURL:
+ case EntityClass:
+ case EntityGeo:
+ case EntityName:
+ case EntityVersion:
+ case EntityProfile:
+ default: t = ParamNone; break;
+ //---------------------------------------------------------------//
+
+ }
+
+ return t;
+}
+
+ ValueType
+VCARD::EntityTypeToValueType(EntityType e)
+{
+ ValueType t(ValueUnknown);
+
+ switch (e) {
+
+ //---------------------------------------------------------------//
+ case EntitySound: t = ValueSound; break;
+ //---------------------------------------------------------------//
+ case EntityAgent: t = ValueAgent; break;
+ //---------------------------------------------------------------//
+ case EntityAddress: t = ValueAddress; break;
+ //---------------------------------------------------------------//
+ case EntityTelephone: t = ValueTel; break;
+ //---------------------------------------------------------------//
+ case EntityKey: t = ValueTextBin; break;
+ //---------------------------------------------------------------//
+ case EntityOrganisation: t = ValueOrg; break;
+ //---------------------------------------------------------------//
+ case EntityN: t = ValueN; break;
+ //---------------------------------------------------------------//
+ case EntityTimeZone: t = ValueUTC; break;
+ //---------------------------------------------------------------//
+ case EntityClass: t = ValueClass; break;
+ //---------------------------------------------------------------//
+ case EntityGeo: t = ValueGeo; break;
+ //---------------------------------------------------------------//
+ case EntitySource:
+ case EntityURL: t = ValueURI; break;
+ //---------------------------------------------------------------//
+ case EntityPhoto:
+ case EntityLogo: t = ValueImage; break;
+ //---------------------------------------------------------------//
+ case EntityBirthday:
+ case EntityRevision: t = ValueDate; break;
+ //---------------------------------------------------------------//
+ case EntityCategories:
+ case EntityNickname: t = ValueTextList; break;
+ //---------------------------------------------------------------//
+ case EntityLabel:
+ case EntityExtension:
+ case EntityEmail:
+ case EntityTitle:
+ case EntityRole:
+ case EntityFullName:
+ case EntityMailer:
+ case EntityProductID:
+ case EntityName:
+ case EntitySortString:
+ case EntityVersion:
+ case EntityProfile:
+ case EntityUID:
+ case EntityNote:
+ default: t = ValueText; break;
+ //---------------------------------------------------------------//
+
+ }
+
+ return t;
+}
+
+ QCString
+VCARD::EntityTypeToParamName(EntityType e)
+{
+ if ( e > EntityUnknown ) e = EntityUnknown;
+ return paramNames[ int( e ) ];
+}
+
+ EntityType
+VCARD::EntityNameToEntityType(const QCString & s)
+{
+ if (s.isEmpty()) return EntityUnknown;
+
+ EntityType t(EntityUnknown);
+
+ switch (s[0]) {
+
+ case 'A':
+ if (s == "ADR")
+ t = EntityAddress;
+ else if (s == "AGENT")
+ t = EntityAgent;
+ break;
+
+ case 'B':
+ if (s == "BDAY")
+ t = EntityBirthday;
+ break;
+
+ case 'C':
+ if (s == "CATEGORIES")
+ t = EntityCategories;
+ else if (s == "CLASS")
+ t = EntityClass;
+ break;
+
+ case 'E':
+ if (s == "EMAIL")
+ t = EntityEmail;
+ break;
+
+ case 'F':
+ if (s == "FN")
+ t = EntityFullName;
+ break;
+
+ case 'G':
+ if (s == "GEO")
+ t = EntityGeo;
+ break;
+
+ case 'K':
+ if (s == "KEY")
+ t = EntityKey;
+ break;
+
+ case 'L':
+ if (s == "LABEL")
+ t = EntityLabel;
+ else if (s == "LOGO")
+ t = EntityLogo;
+ break;
+
+ case 'M':
+ if (s == "MAILER")
+ t = EntityMailer;
+ break;
+
+ case 'N':
+ if (s == "N")
+ t = EntityN;
+ else if (s == "NAME")
+ t = EntityName;
+ else if (s == "NICKNAME")
+ t = EntityNickname;
+ else if (s == "NOTE")
+ t = EntityNote;
+ break;
+
+ case 'O':
+ if (s == "ORG")
+ t = EntityOrganisation;
+ break;
+
+ case 'P':
+ if (s == "PHOTO")
+ t = EntityPhoto;
+ else if (s == "PRODID")
+ t = EntityProductID;
+ else if (s == "PROFILE")
+ t = EntityProfile;
+ break;
+
+ case 'R':
+ if (s == "REV")
+ t = EntityRevision;
+ else if (s == "ROLE")
+ t = EntityRole;
+ break;
+
+ case 'S':
+ if (s == "SORT-STRING")
+ t = EntitySortString;
+ else if (s == "SOUND")
+ t = EntitySound;
+ else if (s == "SOURCE")
+ t = EntitySource;
+ break;
+
+ case 'T':
+ if (s == "TEL")
+ t = EntityTelephone;
+ else if (s == "TITLE")
+ t = EntityTitle;
+ else if (s == "TZ")
+ t = EntityTimeZone;
+ break;
+
+ case 'U':
+ if (s == "UID")
+ t = EntityUID;
+ else if (s == "URL")
+ t = EntityURL;
+ case 'V':
+ if (s == "VERSION")
+ t = EntityVersion;
+ break;
+
+ case 'X':
+ if (s.left(2) == "X-")
+ t = EntityExtension;
+ break;
+
+ default:
+
+ t = EntityUnknown;
+ }
+
+ return t;
+}
+
+// The copyright notice below refers to the base64 codec functions used below,
+// which are modified from the original sources.
+
+/*
+ * Original version Copyright 1988 by The Leland Stanford Junior University
+ * Copyright 1998 by the University of Washington
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notices appear in all copies and that both the
+ * above copyright notices and this permission notice appear in supporting
+ * documentation, and that the name of the University of Washington or The
+ * Leland Stanford Junior University not be used in advertising or publicity
+ * pertaining to distribution of the software without specific, written prior
+ * permission. This software is made available "as is", and
+ * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY
+ * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
+ * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+static char B64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+// the mime base64 disctionary used for decoding
+static signed char b64dec[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 30
+ -1, -1, -1,-19, -1, -1, -1,-16, -4, -4, // 40 -19 == '+' -16 == '/'
+ -4, -4, -4, -4, -4, -4, -4, -4, -1, -1, // 50 -4 == '0'
+ -1, 0, -1, -1, -1, 65, 65, 65, 65, 65, // 60 0 == '=' 65 == 'A'
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // 70
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // 80
+ 65, -1, -1, -1, -1, -1, -1, 71, 71, 71, // 90 71 == 'a'
+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, // 100
+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, // 110
+ 71, 71, 71, -1, -1, -1, -1, -1, -1, -1, // 120
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 130
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 140
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 150
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 160
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 170
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 180
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 190
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 200
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 210
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 220
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 230
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 240
+ -1, -1, -1, -1, -1, -1, -1 // 250
+};
+
+ char *
+VCARD::decodeBase64(const char * s, unsigned long srcl, unsigned long & len)
+{
+ register unsigned char c;
+ register unsigned long e(0);
+ len = 0;
+ unsigned const char * src = (unsigned const char *)s;
+ char * ret = new char[srcl + (srcl / 4 + 1)];
+ register char *d = ret;
+ while (srcl--) { // Critical loop
+ c = *src++;
+ int dec = b64dec[c];
+ if (dec == -1) continue;
+ if (c == '=') {
+ switch (e++) {
+ case 3: e = 0; break;
+ case 2: if (*src == '=') break;
+ default: delete [] ret; ret = 0; return 0; break;
+ }
+ continue;
+ }
+ c -= dec;
+ if (e == 0) { *d = c << 2; ++e; continue; }
+ switch (e) {
+ case 1: *d |= c >> 4; *++d = c << 4; break;
+ case 2: *d |= c >> 2; *++d = c << 6; break;
+ case 3: *d++ |= c; e = 0; continue; break;
+ }
+ ++e;
+ }
+ len = d - (char *)ret;
+ return ret;
+}
+
+
+ char *
+VCARD::encodeBase64(const char * src, unsigned long srcl, unsigned long & destl)
+{
+ register const unsigned char *s = (unsigned char *)src;
+ register unsigned long i = ((srcl + 2) / 3) * 4;
+ destl = i += 2 * ((i / 60) + 1);
+ i = 0;
+ char * ret = new char[destl];
+ register unsigned char *d((unsigned char *)ret);
+ while (srcl != 0) { // Critical loop
+ *d++ = B64[s[0] >> 2];
+ *d++ = B64[((s[0] << 4) + (--srcl == 0 ? 0 : s[1] >> 4)) & 0x3f];
+ *d++ = srcl == 0 ? '=' :
+ B64[((s[1] << 2) + (--srcl == 0 ? 0 : s[2] >> 6)) & 0x3f];
+ *d++ = srcl == 0 ? '=' : B64[s[2] & 0x3f];
+ if (srcl != 0) srcl--;
+ if (++i == 15) { i = 0; *d++ = '\r'; *d++ = '\n'; }
+ s += 3;
+ }
+ *d = '\r'; *++d = '\n'; *++d = '\0';
+ return ret;
+}
+
diff --git a/kabc/vcard/FloatValue.cpp b/kabc/vcard/FloatValue.cpp
new file mode 100644
index 0000000..15bb664
--- a/dev/null
+++ b/kabc/vcard/FloatValue.cpp
@@ -0,0 +1,120 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardFloatValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+FloatValue::FloatValue()
+ : Value()
+{
+}
+
+FloatValue::FloatValue(float f)
+ : Value (),
+ value_ (f)
+{
+ parsed_ = true;
+}
+
+FloatValue::FloatValue(const FloatValue & x)
+ : Value(x)
+{
+ value_ = x.value_;
+}
+
+FloatValue::FloatValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ FloatValue &
+FloatValue::operator = (FloatValue & x)
+{
+ if (*this == x) return *this;
+
+ x.parse();
+ value_ = x.value_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ FloatValue &
+FloatValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+FloatValue::operator == (FloatValue & x)
+{
+ x.parse();
+ return (value_ == x.value_);
+}
+
+FloatValue::~FloatValue()
+{
+}
+
+ void
+FloatValue::_parse()
+{
+ bool negative(false);
+
+ if (strRep_[0] == '-' || strRep_[1] == '+') {
+
+ if (strRep_[0] == '-')
+ negative = true;
+
+ strRep_.remove(0, 1);
+ }
+
+ value_ = strRep_.toFloat();
+ if (negative)
+ value_ = -value_;
+}
+
+ void
+FloatValue::_assemble()
+{
+ strRep_ = QCString().setNum(value_);
+}
+
+ float
+FloatValue::value()
+{
+ parse();
+ return value_;
+}
+
+ void
+FloatValue::setValue(float f)
+{
+ parsed_ = true;
+ value_ = f;
+}
+
diff --git a/kabc/vcard/GeoValue.cpp b/kabc/vcard/GeoValue.cpp
new file mode 100644
index 0000000..e02b402
--- a/dev/null
+++ b/kabc/vcard/GeoValue.cpp
@@ -0,0 +1,100 @@
+/*
+ This file is part of libvcard.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <VCardGeoValue.h>
+
+#include <VCardValue.h>
+
+#include <kdebug.h>
+
+using namespace VCARD;
+
+GeoValue::GeoValue()
+ : Value()
+{
+}
+
+GeoValue::GeoValue(const GeoValue & x)
+ : Value(x), latitude_(x.latitude_), longitude_(x.longitude_)
+{
+}
+
+GeoValue::GeoValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ GeoValue &
+GeoValue::operator = (GeoValue & x)
+{
+ if (*this == x) return *this;
+
+ latitude_ = x.latitude_;
+ longitude_ = x.longitude_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ GeoValue &
+GeoValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+GeoValue::operator == (GeoValue & x)
+{
+ x.parse();
+
+ if ( latitude_ != x.latitude_ ) return false;
+ if ( longitude_ != x.longitude_ ) return false;
+
+ return true;
+}
+
+GeoValue::~GeoValue()
+{
+}
+
+ GeoValue *
+GeoValue::clone()
+{
+ return new GeoValue( *this );
+}
+
+ void
+GeoValue::_parse()
+{
+ int semiColon = strRep_.find( ";" );
+
+ if ( semiColon == -1 ) // invalid
+ return;
+
+ latitude_ = strRep_.left( semiColon ).toFloat();
+ longitude_ = strRep_.mid( semiColon + 1, strRep_.length() - semiColon ).toFloat();
+}
+
+ void
+GeoValue::_assemble()
+{
+ strRep_.sprintf( "%.6f;%.6f", latitude_, longitude_ );
+}
diff --git a/kabc/vcard/ImageParam.cpp b/kabc/vcard/ImageParam.cpp
new file mode 100644
index 0000000..c9cf6fd
--- a/dev/null
+++ b/kabc/vcard/ImageParam.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardImageParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+ImageParam::ImageParam()
+ : Param()
+{
+}
+
+ImageParam::ImageParam(const ImageParam & x)
+ : Param(x)
+{
+}
+
+ImageParam::ImageParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ ImageParam &
+ImageParam::operator = (ImageParam & x)
+{
+ if (*this == x) return *this;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ ImageParam &
+ImageParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+ImageParam::operator == (ImageParam & x)
+{
+ x.parse();
+ return false;
+}
+
+ImageParam::~ImageParam()
+{
+}
+
+ void
+ImageParam::_parse()
+{
+}
+
+ void
+ImageParam::_assemble()
+{
+}
+
diff --git a/kabc/vcard/ImageValue.cpp b/kabc/vcard/ImageValue.cpp
new file mode 100644
index 0000000..4630fac
--- a/dev/null
+++ b/kabc/vcard/ImageValue.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardImageValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+ImageValue::ImageValue()
+ : Value()
+{
+}
+
+ImageValue::ImageValue(const ImageValue & x)
+ : Value(x)
+{
+}
+
+ImageValue::ImageValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ ImageValue &
+ImageValue::operator = (ImageValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ ImageValue &
+ImageValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+ImageValue::operator == (ImageValue & x)
+{
+ x.parse();
+ return false;
+}
+
+ImageValue::~ImageValue()
+{
+}
+
+ void
+ImageValue::_parse()
+{
+}
+
+ void
+ImageValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/ImgValue.cpp b/kabc/vcard/ImgValue.cpp
new file mode 100644
index 0000000..7b961f8
--- a/dev/null
+++ b/kabc/vcard/ImgValue.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardImgValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+ImgValue::ImgValue()
+ : Value()
+{
+}
+
+ImgValue::ImgValue(const ImgValue & x)
+ : Value(x)
+{
+}
+
+ImgValue::ImgValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ ImgValue &
+ImgValue::operator = (ImgValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ ImgValue &
+ImgValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+ImgValue::operator == (ImgValue & x)
+{
+ x.parse();
+ return false;
+}
+
+ImgValue::~ImgValue()
+{
+}
+
+ void
+ImgValue::_parse()
+{
+}
+
+ void
+ImgValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/LangValue.cpp b/kabc/vcard/LangValue.cpp
new file mode 100644
index 0000000..edf1804
--- a/dev/null
+++ b/kabc/vcard/LangValue.cpp
@@ -0,0 +1,127 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardRToken.h>
+
+#include <VCardLangValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+LangValue::LangValue()
+ : Value()
+{
+}
+
+LangValue::LangValue(const LangValue & x)
+ : Value(x)
+{
+}
+
+LangValue::LangValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ LangValue &
+LangValue::operator = (LangValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ LangValue &
+LangValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+LangValue::operator == (LangValue & x)
+{
+ x.parse();
+ return false;
+}
+
+LangValue::~LangValue()
+{
+}
+
+ void
+LangValue::_parse()
+{
+ QStrList l;
+ RTokenise(strRep_, "-", l);
+
+ if (l.count() == 0) return;
+
+ primary_ = l.at(0);
+
+ l.remove(0u);
+
+ subtags_ = l;
+}
+
+ void
+LangValue::_assemble()
+{
+ strRep_ = primary_;
+
+ QStrListIterator it(subtags_);
+
+ for (; it.current(); ++it)
+ strRep_ += QCString('-') + it.current();
+}
+
+ QCString
+LangValue::primary()
+{
+ parse();
+ return primary_;
+}
+
+ QStrList
+LangValue::subtags()
+{
+ parse();
+ return subtags_;
+}
+
+ void
+LangValue::setPrimary(const QCString & s)
+{
+ parse();
+ primary_ = s;
+}
+
+ void
+LangValue::setSubTags(const QStrList & l)
+{
+ parse();
+ subtags_ = l;
+}
+
diff --git a/kabc/vcard/NValue.cpp b/kabc/vcard/NValue.cpp
new file mode 100644
index 0000000..cdec621
--- a/dev/null
+++ b/kabc/vcard/NValue.cpp
@@ -0,0 +1,128 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <qstrlist.h>
+
+#include <VCardRToken.h>
+#include <VCardNValue.h>
+#include <VCardValue.h>
+#include <VCardDefines.h>
+
+using namespace VCARD;
+
+NValue::NValue()
+ : Value()
+{
+ vDebug("ctor");
+}
+
+NValue::NValue(const NValue & x)
+ : Value(x),
+ family_ (x.family_),
+ given_ (x.given_),
+ middle_ (x.middle_),
+ prefix_ (x.prefix_),
+ suffix_ (x.suffix_)
+{
+}
+
+NValue::NValue(const QCString & s)
+ : Value(s)
+{
+ vDebug("ctor");
+}
+
+ NValue &
+NValue::operator = (NValue & x)
+{
+ if (*this == x) return *this;
+
+ family_ = x.family_;
+ given_ = x.given_;
+ middle_ = x.middle_;
+ prefix_ = x.prefix_;
+ suffix_ = x.suffix_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ NValue &
+NValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+NValue::operator == (NValue & x)
+{
+ x.parse();
+
+ return (
+ family_ == x.family_ &&
+ given_ == x.given_ &&
+ middle_ == x.middle_ &&
+ prefix_ == x.prefix_ &&
+ suffix_ == x.suffix_);
+}
+
+NValue::~NValue()
+{
+}
+
+ NValue *
+NValue::clone()
+{
+ return new NValue( *this );
+}
+
+ void
+NValue::_parse()
+{
+ QStrList l;
+ RTokenise(strRep_, ";", l);
+
+ for (unsigned int i = 0; i < l.count(); i++) {
+
+ switch (i) {
+ case 0: family_ = l.at(0); break;
+ case 1: given_ = l.at(1); break;
+ case 2: middle_ = l.at(2); break;
+ case 3: prefix_ = l.at(3); break;
+ case 4: suffix_ = l.at(4); break;
+ default: break;
+ }
+ }
+}
+
+ void
+NValue::_assemble()
+{
+ strRep_ = family_;
+ strRep_ += ";" + given_;
+ strRep_ += ";" + middle_;
+ strRep_ += ";" + prefix_;
+ strRep_ += ";" + suffix_;
+}
+
diff --git a/kabc/vcard/OrgValue.cpp b/kabc/vcard/OrgValue.cpp
new file mode 100644
index 0000000..c3134c8
--- a/dev/null
+++ b/kabc/vcard/OrgValue.cpp
@@ -0,0 +1,107 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardRToken.h>
+
+#include <VCardOrgValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+OrgValue::OrgValue()
+ : Value()
+{
+}
+
+OrgValue::OrgValue(const OrgValue & x)
+ : Value(x)
+{
+}
+
+OrgValue::OrgValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ OrgValue &
+OrgValue::operator = (OrgValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ OrgValue &
+OrgValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+OrgValue::operator == (OrgValue & x)
+{
+ x.parse();
+ return false;
+}
+
+OrgValue::~OrgValue()
+{
+}
+
+ void
+OrgValue::_parse()
+{
+ RTokenise(strRep_, ";", valueList_);
+}
+
+ void
+OrgValue::_assemble()
+{
+ bool first(true);
+
+ QStrListIterator it(valueList_);
+
+ for (; it.current(); ++it) {
+ if (!first) strRep_ += ';';
+ strRep_ += it.current();
+ first = false;
+ }
+}
+
+ unsigned int
+OrgValue::numValues()
+{
+ parse();
+ return valueList_.count();
+}
+
+ QCString
+OrgValue::value(unsigned int i)
+{
+ parse();
+ return valueList_.at(i);
+}
+
diff --git a/kabc/vcard/Param.cpp b/kabc/vcard/Param.cpp
new file mode 100644
index 0000000..c513613
--- a/dev/null
+++ b/kabc/vcard/Param.cpp
@@ -0,0 +1,129 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardParam.h>
+
+#include <VCardEntity.h>
+
+#include <VCardRToken.h>
+
+using namespace VCARD;
+
+Param::Param()
+ : Entity(),
+ name_(""),
+ value_("")
+{
+}
+
+Param::Param(const Param & x)
+ : Entity(x),
+ name_(x.name_),
+ value_(x.value_)
+{
+}
+
+Param::Param(const QCString & s)
+ : Entity(s),
+ name_(""),
+ value_("")
+{
+}
+
+ Param &
+Param::operator = (Param & x)
+{
+ if (*this == x) return *this;
+
+ Entity::operator = (x);
+ name_ = x.name_;
+ value_ = x.value_;
+
+ return *this;
+}
+
+ Param &
+Param::operator = (const QCString & s)
+{
+ Entity::operator = (s);
+ return *this;
+}
+
+ bool
+Param::operator == (Param & x)
+{
+ x.parse();
+ return false;
+}
+
+Param::~Param()
+{
+}
+
+ void
+Param::_parse()
+{
+}
+
+ void
+Param::_assemble()
+{
+ strRep_ = name_ + "=" + value_;
+}
+
+Param::Param(const QCString &name, const QCString &value)
+ : Entity(),
+ name_(name),
+ value_(value)
+{
+ parsed_ = true;
+ assembled_ = false;
+}
+
+ void
+Param::setName(const QCString & name)
+{
+ name_ = name;
+
+ assembled_ = false;
+}
+
+ void
+Param::setValue(const QCString & value)
+{
+ value_ = value;
+
+ assembled_ = false;
+}
+
+ QCString
+Param::name()
+{
+ return name_;
+}
+
+ QCString
+Param::value()
+{
+ return value_;
+}
diff --git a/kabc/vcard/PhoneNumberValue.cpp b/kabc/vcard/PhoneNumberValue.cpp
new file mode 100644
index 0000000..17b1400
--- a/dev/null
+++ b/kabc/vcard/PhoneNumberValue.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardPhoneNumberValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+PhoneNumberValue::PhoneNumberValue()
+ : Value()
+{
+}
+
+PhoneNumberValue::PhoneNumberValue(const PhoneNumberValue & x)
+ : Value(x)
+{
+}
+
+PhoneNumberValue::PhoneNumberValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ PhoneNumberValue &
+PhoneNumberValue::operator = (PhoneNumberValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ PhoneNumberValue &
+PhoneNumberValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+PhoneNumberValue::operator == (PhoneNumberValue & x)
+{
+ x.parse();
+ return false;
+}
+
+PhoneNumberValue::~PhoneNumberValue()
+{
+}
+
+ void
+PhoneNumberValue::_parse()
+{
+}
+
+ void
+PhoneNumberValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/README b/kabc/vcard/README
new file mode 100644
index 0000000..18a9daf
--- a/dev/null
+++ b/kabc/vcard/README
@@ -0,0 +1,15 @@
+libvcard (C) 1999 Rik Hemsley <rik@kde.org>
+Written for the KDE project.
+
+This software is licensed under the MIT license.
+
+A vCard 3.0 parser based on the same principles that librmm (from Empath) uses.
+
+It's small and very fast due to parsing and assembly of object being lazy.
+
+There is a base64 codec declared in Enum.h
+
+Feedback welcome.
+
+Rik <rik@kde.org>
+
diff --git a/kabc/vcard/RToken.cpp b/kabc/vcard/RToken.cpp
new file mode 100644
index 0000000..2a85820
--- a/dev/null
+++ b/kabc/vcard/RToken.cpp
@@ -0,0 +1,88 @@
+/*
+
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <string.h>
+#include <stddef.h>
+#include <qcstring.h>
+#include <qstrlist.h>
+
+namespace VCARD
+{
+
+ Q_UINT32
+RTokenise(const char * str, const char * delim, QStrList & l)
+{
+ // FIXME no stderr !
+ l.clear();
+
+ if (!delim || !str || strlen(delim) == 0 || strlen(str) == 0) return 0;
+
+ char * len = (char *)(str + strlen(str)); // End of string.
+
+ register char * rstart = new char[strlen(str) + 1];
+ register char * r = rstart;
+
+
+ register const char * i = str; // Cursor.
+
+ while (i <= len) {
+
+ if (*i == '\\') { // Escaped chars go straight through.
+ *r++ = *i++;
+ if (i <= len)
+ *r++ = *i++;
+ continue;
+ }
+
+ if (strchr(delim, *i) != 0) {
+ // We hit a delimiter. If we have some text, make a new token.
+ // This has the effect that multiple delimiters are collapsed.
+ // cs: We mustn't collapse multiple delimiters, otherwise we
+ // lose empty fields.
+ *r = '\0';
+// if (r != rstart) {
+ l.append(rstart);
+// }
+ r = rstart;
+ ++i;
+ continue;
+ }
+
+ *r++ = *i++;
+ }
+
+ // Catch last token
+// if (r != rstart) {
+ *r = '\0';
+ l.append(rstart);
+// }
+
+ r = 0;
+
+ delete [] rstart;
+
+ return l.count();
+}
+
+}
diff --git a/kabc/vcard/SoundValue.cpp b/kabc/vcard/SoundValue.cpp
new file mode 100644
index 0000000..81040d1
--- a/dev/null
+++ b/kabc/vcard/SoundValue.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardSoundValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+SoundValue::SoundValue()
+ : Value()
+{
+}
+
+SoundValue::SoundValue(const SoundValue & x)
+ : Value(x)
+{
+}
+
+SoundValue::SoundValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ SoundValue &
+SoundValue::operator = (SoundValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ SoundValue &
+SoundValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+SoundValue::operator == (SoundValue & x)
+{
+ x.parse();
+ return false;
+}
+
+SoundValue::~SoundValue()
+{
+}
+
+ void
+SoundValue::_parse()
+{
+}
+
+ void
+SoundValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/SourceParam.cpp b/kabc/vcard/SourceParam.cpp
new file mode 100644
index 0000000..cd51cbd
--- a/dev/null
+++ b/kabc/vcard/SourceParam.cpp
@@ -0,0 +1,112 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardSourceParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+SourceParam::SourceParam()
+ : Param(),
+ type_(SourceParam::TypeUnknown)
+{
+}
+
+SourceParam::SourceParam(const SourceParam & x)
+ : Param(x),
+ type_ (x.type_),
+ par_ (x.par_),
+ val_ (x.val_)
+{
+}
+
+SourceParam::SourceParam(const QCString & s)
+ : Param(s),
+ type_(SourceParam::TypeUnknown)
+{
+}
+
+ SourceParam &
+SourceParam::operator = (SourceParam & x)
+{
+ if (*this == x) return *this;
+ type_ = x.type();
+ par_ = x.par();
+ val_ = x.val();
+
+ Param::operator = (x);
+ return *this;
+}
+
+ SourceParam &
+SourceParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+SourceParam::operator == (SourceParam & x)
+{
+ x.parse();
+ return false;
+}
+
+SourceParam::~SourceParam()
+{
+}
+
+ void
+SourceParam::_parse()
+{
+ int i = strRep_.find('=');
+ if (i == -1) // Invalid
+ return;
+
+ par_ = strRep_.left(i);
+ val_ = strRep_.right(strRep_.length() - i - 1);
+
+ if (qstricmp(par_, "VALUE") == 0 && qstricmp(val_, "uri") == 0)
+ type_ = TypeValue;
+ else if (qstricmp(par_, "CONTEXT") == 0 && qstricmp(val_, "word") == 0)
+ type_ = TypeContext;
+ else if (qstrnicmp(par_, "X-", 2) == 0) {
+ type_ = TypeX;
+ }
+ else type_ = TypeUnknown;
+
+}
+
+ void
+SourceParam::_assemble()
+{
+ if (type_ == TypeValue)
+ strRep_ = "VALUE=uri";
+ else if (type_ == TypeContext)
+ strRep_ = "CONTEXT=word";
+ else if (type_ == TypeX)
+ strRep_ = par_ + "=" + val_;
+ else strRep_ = "";
+}
+
diff --git a/kabc/vcard/TelParam.cpp b/kabc/vcard/TelParam.cpp
new file mode 100644
index 0000000..9d9fe4d
--- a/dev/null
+++ b/kabc/vcard/TelParam.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardTelParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+TelParam::TelParam()
+ : Param()
+{
+}
+
+TelParam::TelParam(const TelParam & x)
+ : Param(x)
+{
+}
+
+TelParam::TelParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ TelParam &
+TelParam::operator = (TelParam & x)
+{
+ if (*this == x) return *this;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ TelParam &
+TelParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+TelParam::operator == (TelParam & x)
+{
+ x.parse();
+ return false;
+}
+
+TelParam::~TelParam()
+{
+}
+
+ void
+TelParam::_parse()
+{
+}
+
+ void
+TelParam::_assemble()
+{
+}
+
diff --git a/kabc/vcard/TelValue.cpp b/kabc/vcard/TelValue.cpp
new file mode 100644
index 0000000..349f99a
--- a/dev/null
+++ b/kabc/vcard/TelValue.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardTelValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+TelValue::TelValue()
+ : Value()
+{
+}
+
+TelValue::TelValue(const TelValue & x)
+ : Value(x)
+{
+}
+
+TelValue::TelValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ TelValue &
+TelValue::operator = (TelValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ TelValue &
+TelValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+TelValue::operator == (TelValue & x)
+{
+ x.parse();
+ return false;
+}
+
+TelValue::~TelValue()
+{
+}
+
+ void
+TelValue::_parse()
+{
+}
+
+ void
+TelValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/TextBinParam.cpp b/kabc/vcard/TextBinParam.cpp
new file mode 100644
index 0000000..66f2946
--- a/dev/null
+++ b/kabc/vcard/TextBinParam.cpp
@@ -0,0 +1,81 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardTextBinParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+TextBinParam::TextBinParam()
+ : Param()
+{
+}
+
+TextBinParam::TextBinParam(const TextBinParam & x)
+ : Param(x)
+{
+}
+
+TextBinParam::TextBinParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ TextBinParam &
+TextBinParam::operator = (TextBinParam & x)
+{
+ if (*this == x) return *this;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ TextBinParam &
+TextBinParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+TextBinParam::operator == (TextBinParam & x)
+{
+ x.parse();
+ return false;
+}
+
+TextBinParam::~TextBinParam()
+{
+}
+
+ void
+TextBinParam::_parse()
+{
+}
+
+ void
+TextBinParam::_assemble()
+{
+}
+
diff --git a/kabc/vcard/TextBinValue.cpp b/kabc/vcard/TextBinValue.cpp
new file mode 100644
index 0000000..c584009
--- a/dev/null
+++ b/kabc/vcard/TextBinValue.cpp
@@ -0,0 +1,104 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <kmdcodec.h>
+
+#include <VCardTextBinValue.h>
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+TextBinValue::TextBinValue()
+ : Value()
+{
+}
+
+TextBinValue::TextBinValue(const TextBinValue & x)
+ : Value(x)
+{
+ mIsBinary_ = x.mIsBinary_;
+ mData_ = x.mData_;
+ mUrl_ = x.mUrl_;
+}
+
+TextBinValue::TextBinValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ TextBinValue &
+TextBinValue::operator = (TextBinValue & x)
+{
+ if (*this == x) return *this;
+
+ mIsBinary_ = x.mIsBinary_;
+ mData_ = x.mData_;
+ mUrl_ = x.mUrl_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ TextBinValue &
+TextBinValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+TextBinValue::operator == (TextBinValue & x)
+{
+ x.parse();
+
+ if ( mIsBinary_ != x.mIsBinary_ ) return false;
+ if ( mData_ != x.mData_ ) return false;
+ if ( mUrl_ != x.mUrl_ ) return false;
+
+ return true;
+}
+
+TextBinValue::~TextBinValue()
+{
+}
+
+ TextBinValue *
+TextBinValue::clone()
+{
+ return new TextBinValue( *this );
+}
+
+ void
+TextBinValue::_parse()
+{
+}
+
+ void
+TextBinValue::_assemble()
+{
+ if ( mIsBinary_ ) {
+ strRep_ = KCodecs::base64Encode( mData_ );
+ } else
+ strRep_ = mUrl_.utf8();
+}
+
diff --git a/kabc/vcard/TextListValue.cpp b/kabc/vcard/TextListValue.cpp
new file mode 100644
index 0000000..c4ac1e3
--- a/dev/null
+++ b/kabc/vcard/TextListValue.cpp
@@ -0,0 +1,107 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardRToken.h>
+
+#include <VCardTextListValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+TextListValue::TextListValue()
+ : Value()
+{
+}
+
+TextListValue::TextListValue(const TextListValue & x)
+ : Value(x)
+{
+}
+
+TextListValue::TextListValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ TextListValue &
+TextListValue::operator = (TextListValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ TextListValue &
+TextListValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+TextListValue::operator == (TextListValue & x)
+{
+ x.parse();
+ return false;
+}
+
+TextListValue::~TextListValue()
+{
+}
+
+ void
+TextListValue::_parse()
+{
+ RTokenise(strRep_, ";", valueList_);
+}
+
+ void
+TextListValue::_assemble()
+{
+ bool first(true);
+
+ QStrListIterator it(valueList_);
+
+ for (; it.current(); ++it) {
+ if (!first) strRep_ += ';';
+ strRep_ += it.current();
+ first = false;
+ }
+}
+
+ unsigned int
+TextListValue::numValues()
+{
+ parse();
+ return valueList_.count();
+}
+
+ QCString
+TextListValue::value(unsigned int i)
+{
+ parse();
+ return valueList_.at(i);
+}
+
diff --git a/kabc/vcard/TextParam.cpp b/kabc/vcard/TextParam.cpp
new file mode 100644
index 0000000..7c68700
--- a/dev/null
+++ b/kabc/vcard/TextParam.cpp
@@ -0,0 +1,82 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardTextParam.h>
+
+#include <VCardParam.h>
+
+using namespace VCARD;
+
+TextParam::TextParam()
+ : Param()
+{
+}
+
+TextParam::TextParam(const TextParam & x)
+ : Param(x)
+{
+}
+
+TextParam::TextParam(const QCString & s)
+ : Param(s)
+{
+}
+
+ TextParam &
+TextParam::operator = (TextParam & x)
+{
+ if (*this == x) return *this;
+
+ Param::operator = (x);
+ return *this;
+}
+
+ TextParam &
+TextParam::operator = (const QCString & s)
+{
+ Param::operator = (s);
+ return *this;
+}
+
+ bool
+TextParam::operator == (TextParam & x)
+{
+ x.parse();
+
+ return false;
+}
+
+TextParam::~TextParam()
+{
+}
+
+ void
+TextParam::_parse()
+{
+}
+
+ void
+TextParam::_assemble()
+{
+}
+
diff --git a/kabc/vcard/TextValue.cpp b/kabc/vcard/TextValue.cpp
new file mode 100644
index 0000000..09934fa
--- a/dev/null
+++ b/kabc/vcard/TextValue.cpp
@@ -0,0 +1,86 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardTextValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+TextValue::TextValue()
+ : Value()
+{
+}
+
+TextValue::TextValue(const TextValue & x)
+ : Value(x)
+{
+}
+
+TextValue::TextValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ TextValue &
+TextValue::operator = (TextValue & x)
+{
+ if (*this == x) return *this;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ TextValue &
+TextValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+TextValue::operator == (TextValue & x)
+{
+ return strRep_ = x.strRep_;
+}
+
+TextValue::~TextValue()
+{
+}
+
+ TextValue *
+TextValue::clone()
+{
+ return new TextValue( *this );
+}
+
+ void
+TextValue::_parse()
+{
+}
+
+ void
+TextValue::_assemble()
+{
+}
+
diff --git a/kabc/vcard/URIValue.cpp b/kabc/vcard/URIValue.cpp
new file mode 100644
index 0000000..c1d1022
--- a/dev/null
+++ b/kabc/vcard/URIValue.cpp
@@ -0,0 +1,133 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardURIValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+URIValue::URIValue()
+ : Value()
+{
+}
+
+URIValue::URIValue(const QCString & scheme, const QCString & schemeSpecificPart)
+ : Value(),
+ scheme_ (scheme),
+ schemeSpecificPart_ (schemeSpecificPart)
+{
+ parsed_ = true;
+}
+
+URIValue::URIValue(const URIValue & x)
+ : Value (x),
+ scheme_ (x.scheme_),
+ schemeSpecificPart_ (x.schemeSpecificPart_)
+{
+}
+
+URIValue::URIValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ URIValue &
+URIValue::operator = (URIValue & x)
+{
+ if (*this == x) return *this;
+
+ scheme_ = x.scheme_;
+ schemeSpecificPart_ = x.schemeSpecificPart_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ URIValue &
+URIValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+URIValue::operator == (URIValue & x)
+{
+ x.parse();
+ return (
+ (scheme_ == x.scheme_) &&
+ (schemeSpecificPart_ == x.schemeSpecificPart_));
+
+ return false;
+}
+
+URIValue::~URIValue()
+{
+}
+
+ void
+URIValue::_parse()
+{
+ int split = strRep_.find(':');
+ if (split == -1)
+ return;
+
+ scheme_ = strRep_.left(split);
+ schemeSpecificPart_ = strRep_.mid(split + 1);
+}
+
+ void
+URIValue::_assemble()
+{
+ strRep_ = scheme_ + ':' + schemeSpecificPart_;
+}
+
+ QCString
+URIValue::scheme()
+{
+ parse();
+ return scheme_;
+}
+
+ QCString
+URIValue::schemeSpecificPart()
+{
+ parse();
+ return schemeSpecificPart_;
+}
+
+ void
+URIValue::setScheme(const QCString & s)
+{
+ parse();
+ scheme_ = s;
+}
+
+ void
+URIValue::setSchemeSpecificPart(const QCString & s)
+{
+ parse();
+ schemeSpecificPart_ = s;
+}
+
diff --git a/kabc/vcard/UTCValue.cpp b/kabc/vcard/UTCValue.cpp
new file mode 100644
index 0000000..374306c
--- a/dev/null
+++ b/kabc/vcard/UTCValue.cpp
@@ -0,0 +1,110 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardUTCValue.h>
+
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+UTCValue::UTCValue()
+ : Value()
+{
+}
+
+UTCValue::UTCValue(const UTCValue & x)
+ : Value(x), positive_(x.positive_), hour_(x.hour_), minute_(x.minute_)
+
+{
+}
+
+UTCValue::UTCValue(const QCString & s)
+ : Value(s)
+{
+}
+
+ UTCValue &
+UTCValue::operator = (UTCValue & x)
+{
+ if (*this == x) return *this;
+
+ positive_ = x.positive_;
+ hour_ = x.hour_;
+ minute_ = x.minute_;
+
+ Value::operator = (x);
+ return *this;
+}
+
+ UTCValue &
+UTCValue::operator = (const QCString & s)
+{
+ Value::operator = (s);
+ return *this;
+}
+
+ bool
+UTCValue::operator == (UTCValue & x)
+{
+ x.parse();
+
+ if (positive_ != x.positive_) return false;
+ if (hour_ != x.hour_) return false;
+ if (minute_ != x.minute_) return false;
+
+ return true;
+}
+
+UTCValue::~UTCValue()
+{
+}
+
+ UTCValue *
+UTCValue::clone()
+{
+ return new UTCValue( *this );
+}
+
+ void
+UTCValue::_parse()
+{
+ if ( strRep_.isEmpty() )
+ return;
+
+ positive_ = ( strRep_[0] == '+' );
+
+ int colon = strRep_.find( ':' );
+
+ if ( colon == -1 ) // Not valid.
+ return;
+
+ hour_ = strRep_.mid( 1, 2 ).toInt();
+ minute_ = strRep_.right( 2 ).toInt();
+}
+
+ void
+UTCValue::_assemble()
+{
+ strRep_.sprintf( "%c%.2i:%.2i", (positive_ ? '+' : '-'), hour_, minute_ );
+}
+
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp
new file mode 100644
index 0000000..0c21e2f
--- a/dev/null
+++ b/kabc/vcard/VCardEntity.cpp
@@ -0,0 +1,119 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <qregexp.h>
+
+#include <VCardDefines.h>
+#include <VCardVCardEntity.h>
+
+using namespace VCARD;
+
+VCardEntity::VCardEntity()
+ : Entity()
+{
+}
+
+VCardEntity::VCardEntity(const VCardEntity & x)
+ : Entity(x)
+{
+}
+
+VCardEntity::VCardEntity(const QCString & s)
+ : Entity(s)
+{
+}
+
+ VCardEntity &
+VCardEntity::operator = (VCardEntity & x)
+{
+ if (*this == x) return *this;
+
+ Entity::operator = (x);
+ return *this;
+}
+
+ VCardEntity &
+VCardEntity::operator = (const QCString & s)
+{
+ Entity::operator = (s);
+ return *this;
+}
+
+ bool
+VCardEntity::operator == (VCardEntity & x)
+{
+ x.parse();
+ return false;
+}
+
+VCardEntity::~VCardEntity()
+{
+}
+
+ void
+VCardEntity::_parse()
+{
+ vDebug("parse");
+ QCString s(strRep_);
+
+ int i = s.find(QRegExp("BEGIN:VCARD", false));
+
+ while (i != -1) {
+
+ i = s.find(QRegExp("BEGIN:VCARD", false), 11);
+
+ QCString cardStr(s.left(i));
+
+ VCard * v = new VCard(cardStr);
+
+ cardList_.append(v);
+
+ v->parse();
+
+ s.remove(0, i);
+ }
+}
+
+ void
+VCardEntity::_assemble()
+{
+ VCardListIterator it(cardList_);
+
+ for (; it.current(); ++it)
+ strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck.
+}
+
+ VCardList &
+VCardEntity::cardList()
+{
+ parse();
+ return cardList_;
+}
+
+ void
+VCardEntity::setCardList(const VCardList & l)
+{
+ parse();
+ cardList_ = l;
+}
+
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp
new file mode 100644
index 0000000..8d271f4
--- a/dev/null
+++ b/kabc/vcard/VCardv.cpp
@@ -0,0 +1,282 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <qcstring.h>
+#include <qstrlist.h>
+
+#include <VCardEntity.h>
+#include <VCardVCard.h>
+#include <VCardContentLine.h>
+#include <VCardRToken.h>
+
+#include <VCardDefines.h>
+
+using namespace VCARD;
+
+VCard::VCard()
+ : Entity()
+{
+}
+
+VCard::VCard(const VCard & x)
+ : Entity(x),
+ group_(x.group_),
+ contentLineList_(x.contentLineList_)
+{
+}
+
+VCard::VCard(const QCString & s)
+ : Entity(s)
+{
+}
+
+ VCard &
+VCard::operator = (VCard & x)
+{
+ if (*this == x) return *this;
+
+ group_ = x.group();
+ contentLineList_ = x.contentLineList_;
+
+ Entity::operator = (x);
+ return *this;
+}
+
+ VCard &
+VCard::operator = (const QCString & s)
+{
+ Entity::operator = (s);
+ return *this;
+}
+
+ bool
+VCard::operator == (VCard & x)
+{
+ x.parse();
+ return false;
+}
+
+VCard::~VCard()
+{
+}
+
+ void
+VCard::_parse()
+{
+ vDebug("parse() called");
+ QStrList l;
+
+ RTokenise(strRep_, "\r\n", l);
+
+ if (l.count() < 3) { // Invalid VCARD !
+ vDebug("Invalid vcard");
+ return;
+ }
+
+ // Get the first line
+ QCString beginLine = QCString(l.at(0)).stripWhiteSpace();
+
+ vDebug("Begin line == \"" + beginLine + "\"");
+
+ // Remove extra blank lines
+ while (QCString(l.last()).isEmpty())
+ l.remove(l.last());
+
+ // Now we know this is the last line
+ QCString endLine = l.last();
+
+ // Trash the first and last lines as we have seen them.
+ l.remove(0u);
+ l.remove(l.last());
+
+ ///////////////////////////////////////////////////////////////
+ // FIRST LINE
+
+ int split = beginLine.find(':');
+
+ if (split == -1) { // invalid, no BEGIN
+ vDebug("No split");
+ return;
+ }
+
+ QCString firstPart(beginLine.left(split));
+ QCString valuePart(beginLine.mid(split + 1));
+
+ split = firstPart.find('.');
+
+ if (split != -1) {
+ group_ = firstPart.left(split);
+ firstPart = firstPart.right(firstPart.length() - split - 1);
+ }
+
+ if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN !
+ vDebug("No BEGIN");
+ return;
+ }
+
+ if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard !
+ vDebug("No VCARD");
+ return;
+ }
+
+ ///////////////////////////////////////////////////////////////
+ // CONTENT LINES
+ //
+ vDebug("Content lines");
+
+ // Handle folded lines.
+
+ QStrList refolded;
+
+ QStrListIterator it(l);
+
+ QCString cur;
+
+ for (; it.current(); ++it) {
+
+ cur = it.current();
+
+ ++it;
+
+ while (
+ it.current() &&
+ it.current()[0] == ' ' &&
+ strlen(it.current()) != 1)
+ {
+ cur += it.current() + 1;
+ ++it;
+ }
+
+ --it;
+
+ refolded.append(cur);
+ }
+
+ QStrListIterator it2(refolded);
+
+ for (; it2.current(); ++it2) {
+
+ vDebug("New contentline using \"" + QCString(it2.current()) + "\"");
+ ContentLine * cl = new ContentLine(it2.current());
+
+ cl->parse();
+
+ contentLineList_.append(cl);
+ }
+
+ ///////////////////////////////////////////////////////////////
+ // LAST LINE
+
+ split = endLine.find(':');
+
+ if (split == -1) // invalid, no END
+ return;
+
+ firstPart = endLine.left(split);
+ valuePart = endLine.right(firstPart.length() - split - 1);
+
+ split = firstPart.find('.');
+
+ if (split != -1) {
+ group_ = firstPart.left(split);
+ firstPart = firstPart.right(firstPart.length() - split - 1);
+ }
+
+ if (qstricmp(firstPart, "END") != 0) // No END !
+ return;
+
+ if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard !
+ return;
+}
+
+ void
+VCard::_assemble()
+{
+ vDebug("Assembling vcard");
+ strRep_ = "BEGIN:VCARD\r\n";
+ strRep_ += "VERSION:3.0\r\n";
+
+ QPtrListIterator<ContentLine> it(contentLineList_);
+
+ for (; it.current(); ++it)
+ strRep_ += it.current()->asString() + "\r\n";
+
+ strRep_ += "END:VCARD\r\n";
+}
+
+ bool
+VCard::has(EntityType t)
+{
+ parse();
+ return contentLine(t) == 0 ? false : true;
+}
+
+ bool
+VCard::has(const QCString & s)
+{
+ parse();
+ return contentLine(s) == 0 ? false : true;
+}
+
+ void
+VCard::add(const ContentLine & cl)
+{
+ parse();
+ ContentLine * c = new ContentLine(cl);
+ contentLineList_.append(c);
+}
+
+ void
+VCard::add(const QCString & s)
+{
+ parse();
+ ContentLine * c = new ContentLine(s);
+ contentLineList_.append(c);
+}
+
+ ContentLine *
+VCard::contentLine(EntityType t)
+{
+ parse();
+ QPtrListIterator<ContentLine> it(contentLineList_);
+
+ for (; it.current(); ++it)
+ if (it.current()->entityType() == t)
+ return it.current();
+
+ return 0;
+}
+
+ ContentLine *
+VCard::contentLine(const QCString & s)
+{
+ parse();
+ QPtrListIterator<ContentLine> it(contentLineList_);
+
+ for (; it.current(); ++it)
+ if (it.current()->entityType() == EntityNameToEntityType(s))
+ return it.current();
+
+ return 0;
+}
+
diff --git a/kabc/vcard/Value.cpp b/kabc/vcard/Value.cpp
new file mode 100644
index 0000000..1978af2
--- a/dev/null
+++ b/kabc/vcard/Value.cpp
@@ -0,0 +1,82 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <VCardEntity.h>
+#include <VCardValue.h>
+
+using namespace VCARD;
+
+Value::Value()
+ : Entity()
+{
+}
+
+Value::Value(const Value & x)
+ : Entity(x)
+{
+}
+
+Value::Value(const QCString & s)
+ : Entity(s)
+{
+}
+
+ Value &
+Value::operator = (Value & x)
+{
+ if (*this == x) return *this;
+
+ Entity::operator = (x);
+ return *this;
+}
+
+ Value &
+Value::operator = (const QCString & s)
+{
+ Entity::operator = (s);
+ return *this;
+}
+
+ bool
+Value::operator == (Value & x)
+{
+ x.parse();
+ return false;
+}
+
+Value::~Value()
+{
+}
+
+ void
+Value::_parse()
+{
+}
+
+ void
+Value::_assemble()
+{
+//US vDebug("Value::_assemble()");
+ qDebug("Value::_assemble()");
+}
+
diff --git a/kabc/vcard/include/VCard.h b/kabc/vcard/include/VCard.h
new file mode 100644
index 0000000..17b50e8
--- a/dev/null
+++ b/kabc/vcard/include/VCard.h
@@ -0,0 +1,43 @@
+#ifndef VCARD_H
+#define VCARD_H
+
+#include "VCardAdrParam.h"
+#include "VCardAdrValue.h"
+#include "VCardAgentParam.h"
+#include "VCardAgentValue.h"
+#include "VCardClassValue.h"
+#include "VCardContentLine.h"
+#include "VCardDateParam.h"
+#include "VCardDateValue.h"
+#include "VCardDefines.h"
+#include "VCardEmailParam.h"
+#include "VCardEntity.h"
+#include "VCardEnum.h"
+#include "VCardFloatValue.h"
+#include "VCardGeoValue.h"
+#include "VCardGroup.h"
+#include "VCardImageParam.h"
+#include "VCardImageValue.h"
+#include "VCardImgValue.h"
+#include "VCardLangValue.h"
+#include "VCardNValue.h"
+#include "VCardOrgValue.h"
+#include "VCardParam.h"
+#include "VCardPhoneNumberValue.h"
+#include "VCardRToken.h"
+#include "VCardSoundValue.h"
+#include "VCardSourceParam.h"
+#include "VCardTelParam.h"
+#include "VCardTelValue.h"
+#include "VCardTextBinParam.h"
+#include "VCardTextBinValue.h"
+#include "VCardTextListValue.h"
+#include "VCardTextParam.h"
+#include "VCardTextValue.h"
+#include "VCardURIValue.h"
+#include "VCardUTCValue.h"
+#include "VCardVCard.h"
+#include "VCardVCardEntity.h"
+#include "VCardValue.h"
+
+#endif
diff --git a/kabc/vcard/include/VCardAdrParam.h b/kabc/vcard/include/VCardAdrParam.h
new file mode 100644
index 0000000..89dcb64
--- a/dev/null
+++ b/kabc/vcard/include/VCardAdrParam.h
@@ -0,0 +1,64 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef ADRPARAM_H
+#define ADRPARAM_H
+
+#include <qcstring.h>
+#include <qstrlist.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class AdrParam : public Param
+{
+
+#include "AdrParam-generated.h"
+
+ QStrList adrTypeList()
+ { parse(); return adrTypeList_; }
+
+ QCString textParam()
+ { parse(); return textParam_; }
+
+ void setAdrTypeList(const QStrList & l)
+ { adrTypeList_ = l; assembled_ = false; }
+
+ void setTextParam(const QCString & s)
+ { textParam_ = s; assembled_ = false; }
+
+ enum AdrType {
+ AdrDom, AdrIntl, AdrPostal, AdrParcel, AdrHome, AdrWork, AdrPref,
+ AdrIANA, AdrX
+ };
+
+ private:
+
+ QStrList adrTypeList_;
+ QCString textParam_;
+};
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardAdrValue.h b/kabc/vcard/include/VCardAdrValue.h
new file mode 100644
index 0000000..0731924
--- a/dev/null
+++ b/kabc/vcard/include/VCardAdrValue.h
@@ -0,0 +1,83 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef ADRVALUE_H
+#define ADRVALUE_H
+
+#include <qstrlist.h>
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class AdrValue : public Value
+{
+
+#include "AdrValue-generated.h"
+
+ AdrValue *clone();
+
+ void setPOBox(const QCString & s)
+ { poBox_ = s; assembled_ = false; }
+
+ void setExtAddress(const QCString & s)
+ { extAddress_ = s; assembled_ = false; }
+
+ void setStreet(const QCString & s)
+ { street_ = s; assembled_ = false; }
+
+ void setLocality(const QCString & s)
+ { locality_ = s; assembled_ = false; }
+
+ void setRegion(const QCString & s)
+ { region_ = s; assembled_ = false; }
+
+ void setPostCode(const QCString & s)
+ { postCode_ = s; assembled_ = false; }
+
+ void setCountryName(const QCString & s)
+ { countryName_ = s; assembled_ = false; }
+
+ QCString poBox() { parse(); return poBox_; }
+ QCString extAddress() { parse(); return extAddress_; }
+ QCString street() { parse(); return street_; }
+ QCString locality() { parse(); return locality_; }
+ QCString region() { parse(); return region_; }
+ QCString postCode() { parse(); return postCode_; }
+ QCString countryName() { parse(); return countryName_; }
+
+ private:
+
+ QCString poBox_;
+ QCString extAddress_;
+ QCString street_;
+ QCString locality_;
+ QCString region_;
+ QCString postCode_;
+ QCString countryName_;
+};
+
+}
+
+#endif
+
diff --git a/kabc/vcard/include/VCardAgentParam.h b/kabc/vcard/include/VCardAgentParam.h
new file mode 100644
index 0000000..72a05db
--- a/dev/null
+++ b/kabc/vcard/include/VCardAgentParam.h
@@ -0,0 +1,60 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef AGENTPARAM_H
+#define AGENTPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+#include <VCardURIValue.h>
+
+namespace VCARD
+{
+
+class AgentParam : public Param
+{
+
+#include "AgentParam-generated.h"
+
+ bool refer()
+ { parse(); return refer_; }
+
+ URIValue uri()
+ { parse(); return uri_; }
+
+ void setRefer(bool b)
+ { refer_ = b; assembled_ = false; }
+
+ void setURI(const QCString & s)
+ { uri_ = s; assembled_ = false; }
+
+ private:
+
+ bool refer_;
+ URIValue uri_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardAgentValue.h b/kabc/vcard/include/VCardAgentValue.h
new file mode 100644
index 0000000..f655836
--- a/dev/null
+++ b/kabc/vcard/include/VCardAgentValue.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef AGENTVALUE_H
+#define AGENTVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class AgentValue : public Value
+{
+
+#include "AgentValue-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardClassValue.h b/kabc/vcard/include/VCardClassValue.h
new file mode 100644
index 0000000..ff133c2
--- a/dev/null
+++ b/kabc/vcard/include/VCardClassValue.h
@@ -0,0 +1,56 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef CLASSVALUE_H
+#define CLASSVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+#include <kdebug.h>
+
+namespace VCARD
+{
+
+class ClassValue : public Value
+{
+
+#include "ClassValue-generated.h"
+
+ enum ClassType {
+ Public, Private, Confidential, Other
+ };
+
+ ClassValue *clone();
+
+ void setType( int type ) { classType_ = type; assembled_ = false; parsed_ = true; }
+ int type() { parse(); return classType_; }
+
+ private:
+ int classType_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardContentLine.h b/kabc/vcard/include/VCardContentLine.h
new file mode 100644
index 0000000..1c5f5be
--- a/dev/null
+++ b/kabc/vcard/include/VCardContentLine.h
@@ -0,0 +1,77 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef CONTENTLINE_H
+#define CONTENTLINE_H
+
+#include <qptrlist.h>
+
+#include "VCardEnum.h"
+#include "VCardEntity.h"
+#include "VCardParam.h"
+#include "VCardValue.h"
+
+namespace VCARD
+{
+
+class ContentLine : public Entity
+{
+
+#include "ContentLine-generated.h"
+
+ QCString group() { parse(); return group_; }
+ QCString name() { parse(); return name_; }
+ Value * value() { parse(); return value_; }
+ ParamList paramList() { parse(); return paramList_; }
+ ParamType paramType() { parse(); return paramType_; }
+ ValueType valueType() { parse(); return valueType_; }
+ EntityType entityType() { parse(); return entityType_; }
+
+ void setGroup (const QCString & s)
+ { group_ = s; assembled_ = false; }
+
+ void setName (const QCString & s)
+ { name_ = s; assembled_ = false; }
+
+ void setValue (Value *s)
+ { value_ = s; assembled_ = false; }
+
+ void setParamList (const ParamList & l)
+ { paramList_ = l; assembled_ = false; }
+
+ void clear ();
+
+ private:
+
+ QCString group_;
+ QCString name_;
+ QPtrList<Param> paramList_;
+ Value * value_;
+
+ ParamType paramType_;
+ ValueType valueType_;
+ EntityType entityType_;
+};
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardDateParam.h b/kabc/vcard/include/VCardDateParam.h
new file mode 100644
index 0000000..21ac1f1
--- a/dev/null
+++ b/kabc/vcard/include/VCardDateParam.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef DATEPARAM_H
+#define DATEPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class DateParam : public Param
+{
+
+#include "DateParam-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardDateValue.h b/kabc/vcard/include/VCardDateValue.h
new file mode 100644
index 0000000..c248966
--- a/dev/null
+++ b/kabc/vcard/include/VCardDateValue.h
@@ -0,0 +1,99 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef DATEVALUE_H
+#define DATEVALUE_H
+
+#include <qcstring.h>
+#include <qdatetime.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class DateValue : public Value
+{
+#include "DateValue-generated.h"
+
+ DateValue(
+ unsigned int year,
+ unsigned int month,
+ unsigned int day,
+ unsigned int hour = 0,
+ unsigned int minute = 0,
+ unsigned int second = 0,
+ double secFrac = 0,
+ bool zonePositive = true,
+ unsigned int zoneHour = 0,
+ unsigned int zoneMinute = 0);
+
+ DateValue(const QDate &);
+ DateValue(const QDateTime &);
+
+ DateValue *clone();
+
+ bool hasTime();
+
+ unsigned int year();
+ unsigned int month();
+ unsigned int day();
+ unsigned int hour();
+ unsigned int minute();
+ unsigned int second();
+ double secondFraction();
+ bool zonePositive();
+ unsigned int zoneHour();
+ unsigned int zoneMinute();
+
+ void setYear (unsigned int);
+ void setMonth (unsigned int);
+ void setDay (unsigned int);
+ void setHour (unsigned int);
+ void setMinute (unsigned int);
+ void setSecond (unsigned int);
+ void setSecondFraction (double);
+ void setZonePositive (bool);
+ void setZoneHour (unsigned int);
+ void setZoneMinute (unsigned int);
+
+ QDate qdate();
+ QTime qtime();
+ QDateTime qdt();
+
+ private:
+
+ unsigned int year_, month_, day_,
+ hour_, minute_, second_,
+ zoneHour_, zoneMinute_;
+
+ double secFrac_;
+
+ bool zonePositive_;
+
+ bool hasTime_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardDefines.h b/kabc/vcard/include/VCardDefines.h
new file mode 100644
index 0000000..dd38ae2
--- a/dev/null
+++ b/kabc/vcard/include/VCardDefines.h
@@ -0,0 +1,52 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1998 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef VCARD_DEFINES_H
+#define VCARD_DEFINES_H
+
+#include <kdebug.h>
+
+#ifdef VCARD_DEBUG
+#define vDebug(a) kdDebug(5710) << a << endl;
+#else
+#define vDebug(a)
+#endif
+
+#if 0
+#ifndef NDEBUG
+# include <qcstring.h>
+# include <iostream>
+# ifdef __GNUG__
+# define vDebug(a) cerr << className() << ":" << __FUNCTION__ << " (" \
+ << __LINE__ << "): " << QCString((a)).data() << endl;
+# else
+# define vDebug(a) cerr << className() << ": " \
+ << QCString((a)).data() << endl;
+# endif
+#else
+# define vDebug(a)
+#endif
+#endif
+
+#endif // Included this file
+
diff --git a/kabc/vcard/include/VCardEmailParam.h b/kabc/vcard/include/VCardEmailParam.h
new file mode 100644
index 0000000..98d1b30
--- a/dev/null
+++ b/kabc/vcard/include/VCardEmailParam.h
@@ -0,0 +1,56 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef EMAILPARAM_H
+#define EMAILPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class EmailParam : public Param
+{
+
+#include "EmailParam-generated.h"
+
+ QCString emailType() { parse(); return emailType_; }
+ bool pref() { parse(); return pref_; }
+
+ void setEmailType(const QCString & s)
+ { emailType_ = s; assembled_ = false; }
+
+ void setPref(bool b)
+ { pref_ = b; assembled_ = false; }
+
+ private:
+
+ QCString emailType_;
+ bool pref_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardEntity.h b/kabc/vcard/include/VCardEntity.h
new file mode 100644
index 0000000..3c945b5
--- a/dev/null
+++ b/kabc/vcard/include/VCardEntity.h
@@ -0,0 +1,67 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef ENTITY_H
+#define ENTITY_H
+
+#include <qcstring.h>
+
+namespace VCARD
+{
+
+class Entity
+{
+ public:
+
+ Entity();
+ Entity(const Entity & e);
+ Entity(const QCString & s);
+
+ virtual Entity & operator = (const Entity & e);
+ virtual Entity & operator = (const QCString & s);
+
+ virtual bool operator == (Entity & e);
+ virtual bool operator != (Entity & e);
+ virtual bool operator == (const QCString & s);
+ virtual bool operator != (const QCString & s);
+
+ virtual ~Entity();
+
+ QCString asString();
+
+ virtual void parse();
+ virtual void assemble();
+
+ virtual void _parse() = 0;
+ virtual void _assemble() = 0;
+
+ protected:
+
+ QCString strRep_;
+ bool parsed_;
+ bool assembled_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardEnum.h b/kabc/vcard/include/VCardEnum.h
new file mode 100644
index 0000000..b4e4094
--- a/dev/null
+++ b/kabc/vcard/include/VCardEnum.h
@@ -0,0 +1,120 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef ENUM_H
+#define ENUM_H
+
+#include <qcstring.h>
+
+namespace VCARD
+{
+
+extern const QCString paramNames [];
+
+enum EntityType {
+ EntityName,
+ EntityProfile,
+ EntitySource,
+ EntityFullName,
+ EntityN,
+ EntityNickname,
+ EntityPhoto,
+ EntityBirthday,
+ EntityAddress,
+ EntityLabel,
+ EntityTelephone,
+ EntityEmail,
+ EntityMailer,
+ EntityTimeZone,
+ EntityGeo,
+ EntityTitle,
+ EntityRole,
+ EntityLogo,
+ EntityAgent,
+ EntityOrganisation,
+ EntityCategories,
+ EntityNote,
+ EntityProductID,
+ EntityRevision,
+ EntitySortString,
+ EntitySound,
+ EntityUID,
+ EntityURL,
+ EntityVersion,
+ EntityClass,
+ EntityKey,
+ EntityExtension,
+ EntityUnknown
+};
+
+enum ValueType {
+ ValueSound,
+ ValueAgent,
+ ValueAddress,
+ ValueTel,
+ ValueTextBin,
+ ValueOrg,
+ ValueN,
+ ValueUTC,
+ ValueURI,
+ ValueClass,
+ ValueFloat,
+ ValueImage,
+ ValueDate,
+ ValueTextList,
+ ValueText,
+ ValueGeo,
+ ValueUnknown
+};
+
+enum ParamType {
+ ParamUnknown,
+ ParamNone,
+ ParamSource,
+ ParamText,
+ ParamImage,
+ ParamDate,
+ ParamAddrText,
+ ParamTel,
+ ParamEmail,
+ ParamMailer,
+ ParamAgent,
+ ParamTextBin,
+ ParamTextNS,
+ ParamSound
+};
+
+extern const ParamType paramTypesTable[];
+
+ParamType EntityTypeToParamType(EntityType);
+ValueType EntityTypeToValueType(EntityType);
+QCString EntityTypeToParamName(EntityType);
+EntityType EntityNameToEntityType(const QCString &);
+
+char * encodeBase64(const char *, unsigned long, unsigned long &);
+char * decodeBase64(const char *, unsigned long, unsigned long &);
+
+}
+
+#endif
+
diff --git a/kabc/vcard/include/VCardFloatValue.h b/kabc/vcard/include/VCardFloatValue.h
new file mode 100644
index 0000000..69fdc22
--- a/dev/null
+++ b/kabc/vcard/include/VCardFloatValue.h
@@ -0,0 +1,51 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef FLOATVALUE_H
+#define FLOATVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class FloatValue : public Value
+{
+
+#include "FloatValue-generated.h"
+
+ FloatValue(float);
+
+ float value();
+ void setValue(float);
+
+ private:
+
+ float value_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardGeoValue.h b/kabc/vcard/include/VCardGeoValue.h
new file mode 100644
index 0000000..662761c
--- a/dev/null
+++ b/kabc/vcard/include/VCardGeoValue.h
@@ -0,0 +1,49 @@
+/*
+ This file is part of libvcard.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef GEOVALUE_H
+#define GEOVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class GeoValue : public Value
+{
+
+#include "GeoValue-generated.h"
+
+ GeoValue *clone();
+
+ void setLatitude( float lat ) { latitude_ = lat; assembled_ = false; }
+ void setLongitude( float lon ) { longitude_ = lon; assembled_ = false; }
+
+ float latitude() { parse(); return latitude_; }
+ float longitude() { parse(); return longitude_; }
+
+ private:
+ float latitude_;
+ float longitude_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardGroup.h b/kabc/vcard/include/VCardGroup.h
new file mode 100644
index 0000000..ff775fb
--- a/dev/null
+++ b/kabc/vcard/include/VCardGroup.h
@@ -0,0 +1,39 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef GROUP_H
+#define GROUP_H
+
+#include <VCardEntity.h>
+
+namespace VCARD
+{
+
+class Group : public Entity
+{
+#include "Group-generated.h"
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardImageParam.h b/kabc/vcard/include/VCardImageParam.h
new file mode 100644
index 0000000..ce99ccc
--- a/dev/null
+++ b/kabc/vcard/include/VCardImageParam.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef IMGPARAM_H
+#define IMGPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class ImageParam : public Param
+{
+
+#include "ImageParam-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardImageValue.h b/kabc/vcard/include/VCardImageValue.h
new file mode 100644
index 0000000..6ce0371
--- a/dev/null
+++ b/kabc/vcard/include/VCardImageValue.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef IMAGEVALUE_H
+#define IMAGEVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class ImageValue : public Value
+{
+
+#include "ImageValue-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardImgValue.h b/kabc/vcard/include/VCardImgValue.h
new file mode 100644
index 0000000..b09ad64
--- a/dev/null
+++ b/kabc/vcard/include/VCardImgValue.h
@@ -0,0 +1,39 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef IMGVALUE_H
+#define IMGVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class ImgValue : public Value
+{
+#include "ImgValue-generated.h"
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardLangValue.h b/kabc/vcard/include/VCardLangValue.h
new file mode 100644
index 0000000..991ceed
--- a/dev/null
+++ b/kabc/vcard/include/VCardLangValue.h
@@ -0,0 +1,51 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef LANGVALUE_H
+#define LANGVALUE_H
+
+#include <qcstring.h>
+#include <qstrlist.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class LangValue : public Value
+{
+#include "LangValue-generated.h"
+
+ QCString primary();
+ QStrList subtags();
+
+ void setPrimary(const QCString &);
+ void setSubTags(const QStrList &);
+
+ QCString primary_;
+ QStrList subtags_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardNValue.h b/kabc/vcard/include/VCardNValue.h
new file mode 100644
index 0000000..306821b
--- a/dev/null
+++ b/kabc/vcard/include/VCardNValue.h
@@ -0,0 +1,56 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef NVALUE_H
+#define NVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class NValue : public Value
+{
+#include "NValue-generated.h"
+ NValue *clone();
+
+ QCString family() { parse(); return family_; }
+ QCString given() { parse(); return given_; }
+ QCString middle() { parse(); return middle_; }
+ QCString prefix() { parse(); return prefix_; }
+ QCString suffix() { parse(); return suffix_; }
+
+ void setFamily (const QCString & s) { family_ = s; assembled_ = false; }
+ void setGiven (const QCString & s) { given_ = s; assembled_ = false; }
+ void setMiddle (const QCString & s) { middle_ = s; assembled_ = false; }
+ void setPrefix (const QCString & s) { prefix_ = s; assembled_ = false; }
+ void setSuffix (const QCString & s) { suffix_ = s; assembled_ = false; }
+
+ private:
+
+ QCString family_, given_, middle_, prefix_, suffix_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardOrgValue.h b/kabc/vcard/include/VCardOrgValue.h
new file mode 100644
index 0000000..c4f3f25
--- a/dev/null
+++ b/kabc/vcard/include/VCardOrgValue.h
@@ -0,0 +1,50 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef ORGVALUE_H
+#define ORGVALUE_H
+
+#include <qcstring.h>
+#include <qstrlist.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class OrgValue : public Value
+{
+
+#include "OrgValue-generated.h"
+
+ unsigned int numValues();
+ QCString value(unsigned int);
+
+ private:
+
+ QStrList valueList_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardParam.h b/kabc/vcard/include/VCardParam.h
new file mode 100644
index 0000000..b61ce5c
--- a/dev/null
+++ b/kabc/vcard/include/VCardParam.h
@@ -0,0 +1,59 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef PARAM_H
+#define PARAM_H
+
+#include <qcstring.h>
+#include <qptrlist.h>
+
+#include <VCardEntity.h>
+
+namespace VCARD
+{
+
+class Param : public Entity
+{
+
+#include "Param-generated.h"
+
+ Param(const QCString &name, const QCString &value);
+
+ void setName(const QCString &);
+ void setValue(const QCString &);
+
+ QCString name();
+ QCString value();
+
+ private:
+
+ QCString name_;
+ QCString value_;
+};
+
+typedef QPtrList<Param> ParamList;
+typedef QPtrListIterator<Param> ParamListIterator;
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardPhoneNumberValue.h b/kabc/vcard/include/VCardPhoneNumberValue.h
new file mode 100644
index 0000000..a567bdc
--- a/dev/null
+++ b/kabc/vcard/include/VCardPhoneNumberValue.h
@@ -0,0 +1,39 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef PHONENUMBERVALUE_H
+#define PHONENUMBERVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class PhoneNumberValue : public Value
+{
+#include "PhoneNumberValue-generated.h"
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardRToken.h b/kabc/vcard/include/VCardRToken.h
new file mode 100644
index 0000000..2f95f1b
--- a/dev/null
+++ b/kabc/vcard/include/VCardRToken.h
@@ -0,0 +1,38 @@
+/*
+
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef RTOKEN_H
+#define RTOKEN_H
+
+#include <qstrlist.h>
+
+namespace VCARD
+{
+
+Q_UINT32 RTokenise(const char * str, const char * delim, QStrList & l);
+
+}
+
+#endif
+
diff --git a/kabc/vcard/include/VCardSndValue.h b/kabc/vcard/include/VCardSndValue.h
new file mode 100644
index 0000000..ce56221
--- a/dev/null
+++ b/kabc/vcard/include/VCardSndValue.h
@@ -0,0 +1,39 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef SNDVALUE_H
+#define SNDVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class SndValue : public Value
+{
+#include "SndValue-generated.h"
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardSoundValue.h b/kabc/vcard/include/VCardSoundValue.h
new file mode 100644
index 0000000..994f55e
--- a/dev/null
+++ b/kabc/vcard/include/VCardSoundValue.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef SOUNDVALUE_H
+#define SOUNDVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class SoundValue : public Value
+{
+
+#include "SoundValue-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardSourceParam.h b/kabc/vcard/include/VCardSourceParam.h
new file mode 100644
index 0000000..887ea20
--- a/dev/null
+++ b/kabc/vcard/include/VCardSourceParam.h
@@ -0,0 +1,58 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef SOURCEPARAM_H
+#define SOURCEPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class SourceParam : public Param
+{
+
+#include "SourceParam-generated.h"
+
+ enum SourceParamType { TypeUnknown, TypeValue, TypeContext, TypeX };
+
+ SourceParamType type() { parse(); return type_;}
+ QCString par() { parse(); return par_; }
+ QCString val() { parse(); return val_; }
+
+ void setType(SourceParamType t) { type_ = t; assembled_ = false; }
+ void setPar(const QCString & s) { par_ = s; assembled_ = false; }
+ void setVal(const QCString & s) { val_ = s; assembled_ = false; }
+
+ private:
+
+ SourceParamType type_;
+ // May be "VALUE = uri" or "CONTEXT = word" or "x-name = *SAFE-CHAR"
+ QCString par_, val_; // Sub-parameter, value
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTelParam.h b/kabc/vcard/include/VCardTelParam.h
new file mode 100644
index 0000000..27d7dcc
--- a/dev/null
+++ b/kabc/vcard/include/VCardTelParam.h
@@ -0,0 +1,51 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TELPARAM_H
+#define TELPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class TelParam : public Param
+{
+#include "TelParam-generated.h"
+
+ enum TelType {
+ TelHome, TelWork, TelPref, TelVoice, TelFex, TelMsg, TelCell,
+ TelPager, TelBBS, TelModem, TelCar, TelISDN, TelVideo, TelPCS,
+ TelIANA, TelX
+ };
+
+ private:
+
+ QPtrList<TelType> types_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTelValue.h b/kabc/vcard/include/VCardTelValue.h
new file mode 100644
index 0000000..9cf5a98
--- a/dev/null
+++ b/kabc/vcard/include/VCardTelValue.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TELVALUE_H
+#define TELVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class TelValue : public Value
+{
+
+#include "TelValue-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTextBinParam.h b/kabc/vcard/include/VCardTextBinParam.h
new file mode 100644
index 0000000..31dec86
--- a/dev/null
+++ b/kabc/vcard/include/VCardTextBinParam.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TEXTBINPARAM_H
+#define TEXTBINPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class TextBinParam : public Param
+{
+
+#include "TextBinParam-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTextBinValue.h b/kabc/vcard/include/VCardTextBinValue.h
new file mode 100644
index 0000000..8d44fdf
--- a/dev/null
+++ b/kabc/vcard/include/VCardTextBinValue.h
@@ -0,0 +1,67 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TEXTBINVALUE_H
+#define TEXTBINVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class TextBinValue : public Value
+{
+
+#include "TextBinValue-generated.h"
+
+ TextBinValue *clone();
+
+ bool isBinary() { parse(); return mIsBinary_; }
+ QByteArray data() { parse(); return mData_; }
+ QString url() { parse(); return mUrl_; }
+
+ void setData( const QByteArray &data )
+ {
+ mData_ = data;
+ mIsBinary_ = true;
+ assembled_ = false;
+ }
+
+ void setUrl( const QString &url )
+ {
+ mUrl_ = url;
+ mIsBinary_ = false;
+ assembled_ = false;
+ }
+
+ private:
+ int mIsBinary_;
+ QByteArray mData_;
+ QString mUrl_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTextListValue.h b/kabc/vcard/include/VCardTextListValue.h
new file mode 100644
index 0000000..8e47af5
--- a/dev/null
+++ b/kabc/vcard/include/VCardTextListValue.h
@@ -0,0 +1,51 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TEXTLISTVALUE_H
+#define TEXTLISTVALUE_H
+
+#include <qstrlist.h>
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class TextListValue : public Value
+{
+
+#include "TextListValue-generated.h"
+
+ unsigned int numValues();
+ QCString value(unsigned int);
+
+ private:
+
+ QStrList valueList_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTextParam.h b/kabc/vcard/include/VCardTextParam.h
new file mode 100644
index 0000000..08b5f57
--- a/dev/null
+++ b/kabc/vcard/include/VCardTextParam.h
@@ -0,0 +1,44 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TEXTPARAM_H
+#define TEXTPARAM_H
+
+#include <qcstring.h>
+
+#include <VCardParam.h>
+
+namespace VCARD
+{
+
+class TextParam : public Param
+{
+
+#include "TextParam-generated.h"
+
+ private:
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardTextValue.h b/kabc/vcard/include/VCardTextValue.h
new file mode 100644
index 0000000..afe8753
--- a/dev/null
+++ b/kabc/vcard/include/VCardTextValue.h
@@ -0,0 +1,41 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TEXTVALUE_H
+#define TEXTVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class TextValue : public Value
+{
+#include "TextValue-generated.h"
+
+ TextValue *clone();
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardURIValue.h b/kabc/vcard/include/VCardURIValue.h
new file mode 100644
index 0000000..5fd7184
--- a/dev/null
+++ b/kabc/vcard/include/VCardURIValue.h
@@ -0,0 +1,52 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef URIVALUE_H
+#define URIVALUE_H
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class URIValue : public Value
+{
+#include "URIValue-generated.h"
+
+ URIValue(const QCString & scheme, const QCString & schemeSpecificPart);
+
+ QCString scheme();
+ QCString schemeSpecificPart();
+
+ void setScheme (const QCString &);
+ void setSchemeSpecificPart (const QCString &);
+
+ private:
+
+ QCString scheme_;
+ QCString schemeSpecificPart_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardUTCValue.h b/kabc/vcard/include/VCardUTCValue.h
new file mode 100644
index 0000000..ff695e0
--- a/dev/null
+++ b/kabc/vcard/include/VCardUTCValue.h
@@ -0,0 +1,58 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef UTCVALUE_H
+#define UTCVALUE_H
+
+#include <qcstring.h>
+
+#include <VCardValue.h>
+
+namespace VCARD
+{
+
+class UTCValue : public Value
+{
+
+#include "UTCValue-generated.h"
+
+ UTCValue *clone();
+
+ void setPositive( int p ) { positive_ = p; assembled_ = false; }
+ void setHour( int h ) { hour_ = h; assembled_ = false; }
+ void setMinute( int m ) { minute_ = m; assembled_ = false; }
+
+ bool positive() { parse(); return positive_; }
+ unsigned int hour() { parse(); return hour_; }
+ unsigned int minute() { parse(); return minute_; }
+
+ private:
+
+ bool positive_;
+ unsigned int hour_;
+ unsigned int minute_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardVCard.h b/kabc/vcard/include/VCardVCard.h
new file mode 100644
index 0000000..5dec166
--- a/dev/null
+++ b/kabc/vcard/include/VCardVCard.h
@@ -0,0 +1,63 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef VCARD_VCARD_H
+#define VCARD_VCARD_H
+
+#include <qstring.h>
+#include <qptrlist.h>
+
+#include <VCardEnum.h>
+#include <VCardEntity.h>
+#include <VCardContentLine.h>
+
+namespace VCARD
+{
+
+class VCard : public Entity
+{
+
+#include "VCard-generated.h"
+
+ bool has(EntityType);
+ bool has(const QCString &);
+
+ void add(const ContentLine &);
+ void add(const QCString &);
+
+ ContentLine * contentLine(EntityType);
+ ContentLine * contentLine(const QCString &);
+
+ QCString group() { parse(); return group_; }
+
+ QPtrList<ContentLine> contentLineList() { parse(); return contentLineList_; }
+
+ private:
+
+ QCString group_;
+ QPtrList<ContentLine> contentLineList_;
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardVCardEntity.h b/kabc/vcard/include/VCardVCardEntity.h
new file mode 100644
index 0000000..47ba370
--- a/dev/null
+++ b/kabc/vcard/include/VCardVCardEntity.h
@@ -0,0 +1,56 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef VCARD_ENTITY_H
+#define VCARD_ENTITY_H
+
+#include <qstring.h>
+#include <qptrlist.h>
+
+#include <VCardEnum.h>
+#include <VCardVCard.h>
+#include <VCardEntity.h>
+
+namespace VCARD
+{
+
+typedef QPtrList<VCard> VCardList;
+typedef QPtrListIterator<VCard> VCardListIterator;
+
+class VCardEntity : public Entity
+{
+
+#include "VCardEntity-generated.h"
+
+ void setCardList(const VCardList & l);
+ VCardList & cardList();
+
+ private:
+
+ VCardList cardList_;
+
+};
+
+}
+
+#endif
diff --git a/kabc/vcard/include/VCardValue.h b/kabc/vcard/include/VCardValue.h
new file mode 100644
index 0000000..7cfe4a0
--- a/dev/null
+++ b/kabc/vcard/include/VCardValue.h
@@ -0,0 +1,46 @@
+/*
+ libvcard - vCard parsing library for vCard version 3.0
+
+ Copyright (C) 1999 Rik Hemsley rik@kde.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef VALUE_H
+#define VALUE_H
+
+#include <qptrlist.h>
+
+#include <VCardEntity.h>
+
+namespace VCARD
+{
+
+class Value : public Entity
+{
+#include "Value-generated.h"
+
+ virtual Value *clone() { return new Value( *this ); }
+};
+
+typedef QPtrList<Value> ValueList;
+typedef QPtrListIterator<Value> ValueListIterator;
+
+}
+
+#endif
diff --git a/kabc/vcard/include/generated/AdrParam-generated.h b/kabc/vcard/include/generated/AdrParam-generated.h
new file mode 100644
index 0000000..3e265d8
--- a/dev/null
+++ b/kabc/vcard/include/generated/AdrParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+AdrParam();
+AdrParam(const AdrParam&);
+AdrParam(const QCString&);
+AdrParam & operator = (AdrParam&);
+AdrParam & operator = (const QCString&);
+bool operator ==(AdrParam&);
+bool operator !=(AdrParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {AdrParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~AdrParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "AdrParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/AdrValue-generated.h b/kabc/vcard/include/generated/AdrValue-generated.h
new file mode 100644
index 0000000..e1d93e4
--- a/dev/null
+++ b/kabc/vcard/include/generated/AdrValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+AdrValue();
+AdrValue(const AdrValue&);
+AdrValue(const QCString&);
+AdrValue & operator = (AdrValue&);
+AdrValue & operator = (const QCString&);
+bool operator ==(AdrValue&);
+bool operator !=(AdrValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {AdrValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~AdrValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "AdrValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/AgentParam-generated.h b/kabc/vcard/include/generated/AgentParam-generated.h
new file mode 100644
index 0000000..6423867
--- a/dev/null
+++ b/kabc/vcard/include/generated/AgentParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+AgentParam();
+AgentParam(const AgentParam&);
+AgentParam(const QCString&);
+AgentParam & operator = (AgentParam&);
+AgentParam & operator = (const QCString&);
+bool operator ==(AgentParam&);
+bool operator !=(AgentParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {AgentParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~AgentParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "AgentParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/AgentValue-generated.h b/kabc/vcard/include/generated/AgentValue-generated.h
new file mode 100644
index 0000000..76bb81c
--- a/dev/null
+++ b/kabc/vcard/include/generated/AgentValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+AgentValue();
+AgentValue(const AgentValue&);
+AgentValue(const QCString&);
+AgentValue & operator = (AgentValue&);
+AgentValue & operator = (const QCString&);
+bool operator ==(AgentValue&);
+bool operator !=(AgentValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {AgentValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~AgentValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "AgentValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ClassValue-generated.h b/kabc/vcard/include/generated/ClassValue-generated.h
new file mode 100644
index 0000000..df4ed5f
--- a/dev/null
+++ b/kabc/vcard/include/generated/ClassValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+ClassValue();
+ClassValue(const ClassValue&);
+ClassValue(const QCString&);
+ClassValue & operator = (ClassValue&);
+ClassValue & operator = (const QCString&);
+bool operator ==(ClassValue&);
+bool operator !=(ClassValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {ClassValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~ClassValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "ClassValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ContentLine-generated.h b/kabc/vcard/include/generated/ContentLine-generated.h
new file mode 100644
index 0000000..9efe273
--- a/dev/null
+++ b/kabc/vcard/include/generated/ContentLine-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+ContentLine();
+ContentLine(const ContentLine&);
+ContentLine(const QCString&);
+ContentLine & operator = (ContentLine&);
+ContentLine & operator = (const QCString&);
+bool operator ==(ContentLine&);
+bool operator !=(ContentLine& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {ContentLine a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~ContentLine();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "ContentLine"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/DateParam-generated.h b/kabc/vcard/include/generated/DateParam-generated.h
new file mode 100644
index 0000000..ff1da58
--- a/dev/null
+++ b/kabc/vcard/include/generated/DateParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+DateParam();
+DateParam(const DateParam&);
+DateParam(const QCString&);
+DateParam & operator = (DateParam&);
+DateParam & operator = (const QCString&);
+bool operator ==(DateParam&);
+bool operator !=(DateParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {DateParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~DateParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "DateParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/DateValue-generated.h b/kabc/vcard/include/generated/DateValue-generated.h
new file mode 100644
index 0000000..a382823
--- a/dev/null
+++ b/kabc/vcard/include/generated/DateValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+DateValue();
+DateValue(const DateValue&);
+DateValue(const QCString&);
+DateValue & operator = (DateValue&);
+DateValue & operator = (const QCString&);
+bool operator ==(DateValue&);
+bool operator !=(DateValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {DateValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~DateValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "DateValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/EmailParam-generated.h b/kabc/vcard/include/generated/EmailParam-generated.h
new file mode 100644
index 0000000..428a6fc
--- a/dev/null
+++ b/kabc/vcard/include/generated/EmailParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+EmailParam();
+EmailParam(const EmailParam&);
+EmailParam(const QCString&);
+EmailParam & operator = (EmailParam&);
+EmailParam & operator = (const QCString&);
+bool operator ==(EmailParam&);
+bool operator !=(EmailParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {EmailParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~EmailParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "EmailParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/FloatValue-generated.h b/kabc/vcard/include/generated/FloatValue-generated.h
new file mode 100644
index 0000000..cac55cf
--- a/dev/null
+++ b/kabc/vcard/include/generated/FloatValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+FloatValue();
+FloatValue(const FloatValue&);
+FloatValue(const QCString&);
+FloatValue & operator = (FloatValue&);
+FloatValue & operator = (const QCString&);
+bool operator ==(FloatValue&);
+bool operator !=(FloatValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {FloatValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~FloatValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "FloatValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/GeoValue-generated.h b/kabc/vcard/include/generated/GeoValue-generated.h
new file mode 100644
index 0000000..594f3ad
--- a/dev/null
+++ b/kabc/vcard/include/generated/GeoValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+GeoValue();
+GeoValue(const GeoValue&);
+GeoValue(const QCString&);
+GeoValue & operator = (GeoValue&);
+GeoValue & operator = (const QCString&);
+bool operator ==(GeoValue&);
+bool operator !=(GeoValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {GeoValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~GeoValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "GeoValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/Group-generated.h b/kabc/vcard/include/generated/Group-generated.h
new file mode 100644
index 0000000..f39302d
--- a/dev/null
+++ b/kabc/vcard/include/generated/Group-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+Group();
+Group(const Group&);
+Group(const QCString&);
+Group & operator = (Group&);
+Group & operator = (const QCString&);
+bool operator ==(Group&);
+bool operator !=(Group& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {Group a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~Group();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "Group"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ImageParam-generated.h b/kabc/vcard/include/generated/ImageParam-generated.h
new file mode 100644
index 0000000..81edfd2
--- a/dev/null
+++ b/kabc/vcard/include/generated/ImageParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+ImageParam();
+ImageParam(const ImageParam&);
+ImageParam(const QCString&);
+ImageParam & operator = (ImageParam&);
+ImageParam & operator = (const QCString&);
+bool operator ==(ImageParam&);
+bool operator !=(ImageParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {ImageParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~ImageParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "ImageParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ImageValue-generated.h b/kabc/vcard/include/generated/ImageValue-generated.h
new file mode 100644
index 0000000..5a2c493
--- a/dev/null
+++ b/kabc/vcard/include/generated/ImageValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+ImageValue();
+ImageValue(const ImageValue&);
+ImageValue(const QCString&);
+ImageValue & operator = (ImageValue&);
+ImageValue & operator = (const QCString&);
+bool operator ==(ImageValue&);
+bool operator !=(ImageValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {ImageValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~ImageValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "ImageValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ImgParam-generated.h b/kabc/vcard/include/generated/ImgParam-generated.h
new file mode 100644
index 0000000..46a6ca0
--- a/dev/null
+++ b/kabc/vcard/include/generated/ImgParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+ImgParam();
+ImgParam(const ImgParam&);
+ImgParam(const QCString&);
+ImgParam & operator = (ImgParam&);
+ImgParam & operator = (const QCString&);
+bool operator ==(ImgParam&);
+bool operator !=(ImgParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {ImgParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~ImgParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+virtual const char * className() const { return "ImgParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ImgValue-generated.h b/kabc/vcard/include/generated/ImgValue-generated.h
new file mode 100644
index 0000000..d75d545
--- a/dev/null
+++ b/kabc/vcard/include/generated/ImgValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+ImgValue();
+ImgValue(const ImgValue&);
+ImgValue(const QCString&);
+ImgValue & operator = (ImgValue&);
+ImgValue & operator = (const QCString&);
+bool operator ==(ImgValue&);
+bool operator !=(ImgValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {ImgValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~ImgValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+virtual const char * className() const { return "ImgValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/LangValue-generated.h b/kabc/vcard/include/generated/LangValue-generated.h
new file mode 100644
index 0000000..23e138b
--- a/dev/null
+++ b/kabc/vcard/include/generated/LangValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+LangValue();
+LangValue(const LangValue&);
+LangValue(const QCString&);
+LangValue & operator = (LangValue&);
+LangValue & operator = (const QCString&);
+bool operator ==(LangValue&);
+bool operator !=(LangValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {LangValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~LangValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "LangValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/NValue-generated.h b/kabc/vcard/include/generated/NValue-generated.h
new file mode 100644
index 0000000..082c253
--- a/dev/null
+++ b/kabc/vcard/include/generated/NValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+NValue();
+NValue(const NValue&);
+NValue(const QCString&);
+NValue & operator = (NValue&);
+NValue & operator = (const QCString&);
+bool operator ==(NValue&);
+bool operator !=(NValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {NValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~NValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "NValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/Name-generated.h b/kabc/vcard/include/generated/Name-generated.h
new file mode 100644
index 0000000..0e69abd
--- a/dev/null
+++ b/kabc/vcard/include/generated/Name-generated.h
@@ -0,0 +1,22 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+V_Name();
+V_Name(const V_Name&);
+V_Name(const QCString&);
+V_Name & operator = (V_Name&);
+V_Name & operator = (const QCString&);
+bool operator ==(V_Name&);
+bool operator !=(V_Name& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {V_Name a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~V_Name();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/OrgValue-generated.h b/kabc/vcard/include/generated/OrgValue-generated.h
new file mode 100644
index 0000000..51eb1b7
--- a/dev/null
+++ b/kabc/vcard/include/generated/OrgValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+OrgValue();
+OrgValue(const OrgValue&);
+OrgValue(const QCString&);
+OrgValue & operator = (OrgValue&);
+OrgValue & operator = (const QCString&);
+bool operator ==(OrgValue&);
+bool operator !=(OrgValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {OrgValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~OrgValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "OrgValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/Param-generated.h b/kabc/vcard/include/generated/Param-generated.h
new file mode 100644
index 0000000..cf4666a
--- a/dev/null
+++ b/kabc/vcard/include/generated/Param-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+Param();
+Param(const Param&);
+Param(const QCString&);
+Param & operator = (Param&);
+Param & operator = (const QCString&);
+bool operator ==(Param&);
+bool operator !=(Param& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {Param a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~Param();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "Param"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ParamName-generated.h b/kabc/vcard/include/generated/ParamName-generated.h
new file mode 100644
index 0000000..ef673c3
--- a/dev/null
+++ b/kabc/vcard/include/generated/ParamName-generated.h
@@ -0,0 +1,22 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+V_ParamName();
+V_ParamName(const V_ParamName&);
+V_ParamName(const QCString&);
+V_ParamName & operator = (V_ParamName&);
+V_ParamName & operator = (const QCString&);
+bool operator ==(V_ParamName&);
+bool operator !=(V_ParamName& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {V_ParamName a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~V_ParamName();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/ParamValue-generated.h b/kabc/vcard/include/generated/ParamValue-generated.h
new file mode 100644
index 0000000..e73500f
--- a/dev/null
+++ b/kabc/vcard/include/generated/ParamValue-generated.h
@@ -0,0 +1,22 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+V_ParamValue();
+V_ParamValue(const V_ParamValue&);
+V_ParamValue(const QCString&);
+V_ParamValue & operator = (V_ParamValue&);
+V_ParamValue & operator = (const QCString&);
+bool operator ==(V_ParamValue&);
+bool operator !=(V_ParamValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {V_ParamValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~V_ParamValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/PhoneNumberValue-generated.h b/kabc/vcard/include/generated/PhoneNumberValue-generated.h
new file mode 100644
index 0000000..1320f18
--- a/dev/null
+++ b/kabc/vcard/include/generated/PhoneNumberValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+PhoneNumberValue();
+PhoneNumberValue(const PhoneNumberValue&);
+PhoneNumberValue(const QCString&);
+PhoneNumberValue & operator = (PhoneNumberValue&);
+PhoneNumberValue & operator = (const QCString&);
+bool operator ==(PhoneNumberValue&);
+bool operator !=(PhoneNumberValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {PhoneNumberValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~PhoneNumberValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "PhoneNumberValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/SoundValue-generated.h b/kabc/vcard/include/generated/SoundValue-generated.h
new file mode 100644
index 0000000..a9ab2e8
--- a/dev/null
+++ b/kabc/vcard/include/generated/SoundValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+SoundValue();
+SoundValue(const SoundValue&);
+SoundValue(const QCString&);
+SoundValue & operator = (SoundValue&);
+SoundValue & operator = (const QCString&);
+bool operator ==(SoundValue&);
+bool operator !=(SoundValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {SoundValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~SoundValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "SoundValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/SourceParam-generated.h b/kabc/vcard/include/generated/SourceParam-generated.h
new file mode 100644
index 0000000..75fefb8
--- a/dev/null
+++ b/kabc/vcard/include/generated/SourceParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+SourceParam();
+SourceParam(const SourceParam&);
+SourceParam(const QCString&);
+SourceParam & operator = (SourceParam&);
+SourceParam & operator = (const QCString&);
+bool operator ==(SourceParam&);
+bool operator !=(SourceParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {SourceParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~SourceParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "SourceParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TelParam-generated.h b/kabc/vcard/include/generated/TelParam-generated.h
new file mode 100644
index 0000000..3ee77cc
--- a/dev/null
+++ b/kabc/vcard/include/generated/TelParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TelParam();
+TelParam(const TelParam&);
+TelParam(const QCString&);
+TelParam & operator = (TelParam&);
+TelParam & operator = (const QCString&);
+bool operator ==(TelParam&);
+bool operator !=(TelParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TelParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TelParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TelParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TelValue-generated.h b/kabc/vcard/include/generated/TelValue-generated.h
new file mode 100644
index 0000000..3213e1c
--- a/dev/null
+++ b/kabc/vcard/include/generated/TelValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TelValue();
+TelValue(const TelValue&);
+TelValue(const QCString&);
+TelValue & operator = (TelValue&);
+TelValue & operator = (const QCString&);
+bool operator ==(TelValue&);
+bool operator !=(TelValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TelValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TelValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TelValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TextBinParam-generated.h b/kabc/vcard/include/generated/TextBinParam-generated.h
new file mode 100644
index 0000000..d075c10
--- a/dev/null
+++ b/kabc/vcard/include/generated/TextBinParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TextBinParam();
+TextBinParam(const TextBinParam&);
+TextBinParam(const QCString&);
+TextBinParam & operator = (TextBinParam&);
+TextBinParam & operator = (const QCString&);
+bool operator ==(TextBinParam&);
+bool operator !=(TextBinParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TextBinParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TextBinParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TextBinParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TextBinValue-generated.h b/kabc/vcard/include/generated/TextBinValue-generated.h
new file mode 100644
index 0000000..e9553ac
--- a/dev/null
+++ b/kabc/vcard/include/generated/TextBinValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TextBinValue();
+TextBinValue(const TextBinValue&);
+TextBinValue(const QCString&);
+TextBinValue & operator = (TextBinValue&);
+TextBinValue & operator = (const QCString&);
+bool operator ==(TextBinValue&);
+bool operator !=(TextBinValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TextBinValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TextBinValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TextBinValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TextListValue-generated.h b/kabc/vcard/include/generated/TextListValue-generated.h
new file mode 100644
index 0000000..9f46124
--- a/dev/null
+++ b/kabc/vcard/include/generated/TextListValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TextListValue();
+TextListValue(const TextListValue&);
+TextListValue(const QCString&);
+TextListValue & operator = (TextListValue&);
+TextListValue & operator = (const QCString&);
+bool operator ==(TextListValue&);
+bool operator !=(TextListValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TextListValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TextListValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TextListValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TextNSParam-generated.h b/kabc/vcard/include/generated/TextNSParam-generated.h
new file mode 100644
index 0000000..d7f58ca
--- a/dev/null
+++ b/kabc/vcard/include/generated/TextNSParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TextNSParam();
+TextNSParam(const TextNSParam&);
+TextNSParam(const QCString&);
+TextNSParam & operator = (TextNSParam&);
+TextNSParam & operator = (const QCString&);
+bool operator ==(TextNSParam&);
+bool operator !=(TextNSParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TextNSParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TextNSParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TextNSParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TextParam-generated.h b/kabc/vcard/include/generated/TextParam-generated.h
new file mode 100644
index 0000000..154e1bf
--- a/dev/null
+++ b/kabc/vcard/include/generated/TextParam-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TextParam();
+TextParam(const TextParam&);
+TextParam(const QCString&);
+TextParam & operator = (TextParam&);
+TextParam & operator = (const QCString&);
+bool operator ==(TextParam&);
+bool operator !=(TextParam& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TextParam a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TextParam();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TextParam"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/TextValue-generated.h b/kabc/vcard/include/generated/TextValue-generated.h
new file mode 100644
index 0000000..e1c4dcc
--- a/dev/null
+++ b/kabc/vcard/include/generated/TextValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+TextValue();
+TextValue(const TextValue&);
+TextValue(const QCString&);
+TextValue & operator = (TextValue&);
+TextValue & operator = (const QCString&);
+bool operator ==(TextValue&);
+bool operator !=(TextValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {TextValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~TextValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "TextValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/URIValue-generated.h b/kabc/vcard/include/generated/URIValue-generated.h
new file mode 100644
index 0000000..dbcb5c1
--- a/dev/null
+++ b/kabc/vcard/include/generated/URIValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+URIValue();
+URIValue(const URIValue&);
+URIValue(const QCString&);
+URIValue & operator = (URIValue&);
+URIValue & operator = (const QCString&);
+bool operator ==(URIValue&);
+bool operator !=(URIValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {URIValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~URIValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "URIValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/UTCValue-generated.h b/kabc/vcard/include/generated/UTCValue-generated.h
new file mode 100644
index 0000000..46e447b
--- a/dev/null
+++ b/kabc/vcard/include/generated/UTCValue-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+UTCValue();
+UTCValue(const UTCValue&);
+UTCValue(const QCString&);
+UTCValue & operator = (UTCValue&);
+UTCValue & operator = (const QCString&);
+bool operator ==(UTCValue&);
+bool operator !=(UTCValue& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {UTCValue a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~UTCValue();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "UTCValue"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/VCard-generated.h b/kabc/vcard/include/generated/VCard-generated.h
new file mode 100644
index 0000000..4d7d96d
--- a/dev/null
+++ b/kabc/vcard/include/generated/VCard-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+VCard();
+VCard(const VCard&);
+VCard(const QCString&);
+VCard & operator = (VCard&);
+VCard & operator = (const QCString&);
+bool operator ==(VCard&);
+bool operator !=(VCard& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {VCard a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~VCard();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "VCard"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/VCardEntity-generated.h b/kabc/vcard/include/generated/VCardEntity-generated.h
new file mode 100644
index 0000000..9f2dfbc
--- a/dev/null
+++ b/kabc/vcard/include/generated/VCardEntity-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+VCardEntity();
+VCardEntity(const VCardEntity&);
+VCardEntity(const QCString&);
+VCardEntity & operator = (VCardEntity&);
+VCardEntity & operator = (const QCString&);
+bool operator ==(VCardEntity&);
+bool operator !=(VCardEntity& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {VCardEntity a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~VCardEntity();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "VCardEntity"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/Value-generated.h b/kabc/vcard/include/generated/Value-generated.h
new file mode 100644
index 0000000..7afac34
--- a/dev/null
+++ b/kabc/vcard/include/generated/Value-generated.h
@@ -0,0 +1,23 @@
+// XXX Automatically generated. DO NOT EDIT! XXX //
+
+public:
+Value();
+Value(const Value&);
+Value(const QCString&);
+Value & operator = (Value&);
+Value & operator = (const QCString&);
+bool operator ==(Value&);
+bool operator !=(Value& x) {return !(*this==x);}
+bool operator ==(const QCString& s) {Value a(s);return(*this==a);}
+bool operator != (const QCString& s) {return !(*this == s);}
+
+virtual ~Value();
+void parse() {if(!parsed_) _parse();parsed_=true;assembled_=false;}
+
+void assemble() {if(assembled_) return;parse();_assemble();assembled_=true;}
+
+void _parse();
+void _assemble();
+const char * className() const { return "Value"; }
+
+// End of automatically generated code //
diff --git a/kabc/vcard/include/generated/generate b/kabc/vcard/include/generated/generate
new file mode 100644
index 0000000..926dbf1
--- a/dev/null
+++ b/kabc/vcard/include/generated/generate
@@ -0,0 +1,2 @@
+#!/bin/sh
+cat headerBodies | awk -f generateHeaders.awk
diff --git a/kabc/vcard/include/generated/generateHeaders.awk b/kabc/vcard/include/generated/generateHeaders.awk
new file mode 100644
index 0000000..1053144
--- a/dev/null
+++ b/kabc/vcard/include/generated/generateHeaders.awk
@@ -0,0 +1,40 @@
+#!/bin/awk -f
+
+{
+ outfile = $1 "-generated.h"
+ name = $1
+
+ OFS=""
+
+ print "// XXX Automatically generated. DO NOT EDIT! XXX //\n" > outfile
+
+ if ($2 == "v") { pre = "virtual " } else { pre = "" }
+
+ print "public:" >> outfile
+ print name "();" >> outfile
+ print name "(const " name "&);" >> outfile
+ print name "(const QCString&);" >> outfile
+ print pre name " & operator = (" name "&);" >> outfile
+ print pre name " & operator = (const QCString&);" >> outfile
+ print pre "bool operator ==(" name "&);" >> outfile
+ print pre "bool operator !=(" name "& x) {return !(*this==x);}" \
+ >> outfile
+ print pre "bool operator ==(const QCString& s) {" name " a(s);" \
+ "return(*this==a);} " >> outfile
+ print pre "bool operator != (const QCString& s) {return !(*this == s);}\n" \
+ >> outfile
+ print "virtual ~" name "();" >> outfile
+ print pre "void parse() " \
+ "{if(!parsed_) _parse();parsed_=true;assembled_=false;}\n" \
+ >> outfile
+ print pre "void assemble() " \
+ "{if(assembled_) return;parse();_assemble();assembled_=true;}\n" \
+ >> outfile
+ print pre "void _parse();" >> outfile
+ print pre "void _assemble();" >> outfile
+ print pre "const char * className() const { return \"" name "\"; }" \
+ >> outfile
+
+ print "\n// End of automatically generated code //" >> outfile
+}
+
diff --git a/kabc/vcard/include/generated/headerBodies b/kabc/vcard/include/generated/headerBodies
new file mode 100644
index 0000000..5e77b2b
--- a/dev/null
+++ b/kabc/vcard/include/generated/headerBodies
@@ -0,0 +1,34 @@
+AdrParam Param
+AdrValue Value
+AgentParam Param
+ContentLine Entity
+DateParam Param
+DateValue Value
+EmailParam Param
+GeoValue Value
+Group Entity
+ImageParam Param
+ImageValue Value
+LangValue Value
+NValue Value
+Param Entity
+PhoneNumberValue Value
+SourceParam Param
+TelParam Param
+TextParam Param
+TextNSParam Param
+TextValue Value
+TextBinParam Param
+URIValue Value
+VCard Entity
+VCardEntity Entity
+Value Entity
+SoundValue Value
+AgentValue Value
+TelValue Value
+TextBinValue Value
+OrgValue Value
+UTCValue Value
+ClassValue Value
+FloatValue Value
+TextListValue Value
diff --git a/kabc/vcard/testread.cpp b/kabc/vcard/testread.cpp
new file mode 100644
index 0000000..919c661
--- a/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;
+ }
+}
+
diff --git a/kabc/vcard/testwrite.cpp b/kabc/vcard/testwrite.cpp
new file mode 100644
index 0000000..e4bbe7b
--- a/dev/null
+++ b/kabc/vcard/testwrite.cpp
@@ -0,0 +1,41 @@
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+
+#include <VCard.h>
+
+int main(int argc,char **argv)
+{
+ KAboutData aboutData("testwrite",I18N_NOOP("TestWritevCard"),"0.1");
+ KCmdLineArgs::init(argc,argv,&aboutData);
+
+ KApplication app;
+
+ kdDebug() << "Test Write VCard" << endl;
+
+ using namespace VCARD;
+
+ VCard v;
+
+ ContentLine cl1;
+ cl1.setName(EntityTypeToParamName(EntityName));
+ cl1.setValue(new TextValue("Hans Wurst"));
+ v.add(cl1);
+
+ ContentLine cl2;
+ cl2.setName(EntityTypeToParamName(EntityTelephone));
+ cl2.setValue(new TelValue("12345"));
+ ParamList p;
+ p.append( new TelParam("home") );
+ p.append( new TelParam("fax") );
+ cl2.setParamList( p );
+ v.add(cl2);
+
+ QCString str = v.asString();
+
+ kdDebug() << "--- VCard begin ---" << endl
+ << str
+ << "--- VCard end ---" << endl;
+}
diff --git a/kabc/vcard/vCard-all.cpp b/kabc/vcard/vCard-all.cpp
new file mode 100644
index 0000000..07bbcd2
--- a/dev/null
+++ b/kabc/vcard/vCard-all.cpp
@@ -0,0 +1,37 @@
+#include "AdrParam.cpp"
+#include "AdrValue.cpp"
+#include "AgentParam.cpp"
+#include "AgentValue.cpp"
+#include "ClassValue.cpp"
+#include "ContentLine.cpp"
+#include "DateParam.cpp"
+#include "DateValue.cpp"
+#include "EmailParam.cpp"
+#include "Entity.cpp"
+#include "Enum.cpp"
+#include "FloatValue.cpp"
+#include "GeoValue.cpp"
+#include "ImageParam.cpp"
+#include "ImageValue.cpp"
+#include "ImgValue.cpp"
+#include "LangValue.cpp"
+#include "NValue.cpp"
+#include "OrgValue.cpp"
+#include "Param.cpp"
+#include "PhoneNumberValue.cpp"
+#include "RToken.cpp"
+#include "SoundValue.cpp"
+#include "SourceParam.cpp"
+#include "TelParam.cpp"
+#include "TelValue.cpp"
+#include "TextBinParam.cpp"
+#include "TextBinValue.cpp"
+#include "TextListValue.cpp"
+#include "TextParam.cpp"
+#include "TextValue.cpp"
+#include "URIValue.cpp"
+#include "UTCValue.cpp"
+#include "VCard.cpp"
+#include "VCardEntity.cpp"
+#include "Value.cpp"
+
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp
new file mode 100644
index 0000000..b02aac4
--- a/dev/null
+++ b/kabc/vcard21parser.cpp
@@ -0,0 +1,606 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Mark Westcott <mark@houseoffish.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qmap.h>
+#include <qregexp.h>
+#include <kmdcodec.h>
+
+#include "vcard21parser.h"
+#include "vcardconverter.h"
+
+using namespace KABC;
+
+bool VCardLineX::isValid() const
+{
+ // Invalid: if it is "begin:vcard" or "end:vcard"
+ if ( name == VCARD_BEGIN_N || name == VCARD_END_N )
+ return false;
+
+ if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line
+ return true;
+
+ // This is long but it makes it a bit faster (and saves me from using
+ // a tree which is probably the ideal situation, but a bit memory heavy)
+ switch( name[0] ) {
+ case 'a':
+ if ( name == VCARD_ADR && qualified &&
+ (qualifiers.contains(VCARD_ADR_DOM) ||
+ qualifiers.contains(VCARD_ADR_INTL) ||
+ qualifiers.contains(VCARD_ADR_POSTAL) ||
+ qualifiers.contains(VCARD_ADR_HOME) ||
+ qualifiers.contains(VCARD_ADR_WORK) ||
+ qualifiers.contains(VCARD_ADR_PREF)
+ ) )
+ return true;
+
+ if ( name == VCARD_AGENT )
+ return true;
+ break;
+
+ case 'b':
+ if ( name == VCARD_BDAY )
+ return true;
+ break;
+
+ case 'c':
+ if ( name == VCARD_CATEGORIES )
+ return true;
+ if ( name == VCARD_CLASS && qualified &&
+ (qualifiers.contains(VCARD_CLASS_PUBLIC) ||
+ qualifiers.contains(VCARD_CLASS_PRIVATE) ||
+ qualifiers.contains(VCARD_CLASS_CONFIDENTIAL)
+ ) )
+ return true;
+ break;
+
+ case 'e':
+ if ( name == VCARD_EMAIL && qualified &&
+ (qualifiers.contains(VCARD_EMAIL_INTERNET) ||
+ qualifiers.contains(VCARD_EMAIL_PREF) ||
+ qualifiers.contains(VCARD_EMAIL_X400)
+ ) )
+ return true;
+ break;
+
+ case 'f':
+ if ( name == VCARD_FN )
+ return true;
+ break;
+
+ case 'g':
+ if ( name == VCARD_GEO )
+ return true;
+ break;
+
+ case 'k':
+ if ( name == VCARD_KEY && qualified &&
+ (qualifiers.contains(VCARD_KEY_X509) ||
+ qualifiers.contains(VCARD_KEY_PGP)
+ ) )
+ return true;
+ break;
+
+ case 'l':
+ if ( name == VCARD_LABEL )
+ return true;
+ if ( name == VCARD_LOGO )
+ return true;
+ break;
+
+ case 'm':
+ if ( name == VCARD_MAILER )
+ return true;
+ break;
+
+ case 'n':
+ if ( name == VCARD_N )
+ return true;
+ if ( name == VCARD_NAME )
+ return true;
+ if ( name == VCARD_NICKNAME )
+ return true;
+ if ( name == VCARD_NOTE )
+ return true;
+ break;
+
+ case 'o':
+ if ( name == VCARD_ORG )
+ return true;
+ break;
+
+ case 'p':
+ if ( name == VCARD_PHOTO )
+ return true;
+ if ( name == VCARD_PROFILE )
+ return true;
+ if ( name == VCARD_PRODID )
+ return true;
+ break;
+
+ case 'r':
+ if ( name == VCARD_ROLE )
+ return true;
+ if ( name == VCARD_REV )
+ return true;
+ break;
+
+ case 's':
+ if ( name == VCARD_SOURCE )
+ return true;
+ if ( name == VCARD_SOUND )
+ return true;
+ break;
+
+ case 't':
+ if ( name == VCARD_TEL && qualified &&
+ (qualifiers.contains(VCARD_TEL_HOME) ||
+ qualifiers.contains(VCARD_TEL_WORK) ||
+ qualifiers.contains(VCARD_TEL_PREF) ||
+ qualifiers.contains(VCARD_TEL_VOICE) ||
+ qualifiers.contains(VCARD_TEL_FAX) ||
+ qualifiers.contains(VCARD_TEL_MSG) ||
+ qualifiers.contains(VCARD_TEL_CELL) ||
+ qualifiers.contains(VCARD_TEL_PAGER) ||
+ qualifiers.contains(VCARD_TEL_BBS) ||
+ qualifiers.contains(VCARD_TEL_MODEM) ||
+ qualifiers.contains(VCARD_TEL_CAR) ||
+ qualifiers.contains(VCARD_TEL_ISDN) ||
+ qualifiers.contains(VCARD_TEL_VIDEO) ||
+ qualifiers.contains(VCARD_TEL_PCS)
+ ) )
+ return true;
+ if ( name == VCARD_TZ )
+ return true;
+ if ( name == VCARD_TITLE )
+ return true;
+ break;
+
+ case 'u':
+ if ( name == VCARD_URL )
+ return true;
+ if ( name == VCARD_UID )
+ return true;
+ break;
+
+ case 'v':
+ if ( name == VCARD_VERSION )
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+
+VCard21Parser::VCard21Parser()
+{
+}
+
+VCard21Parser::~VCard21Parser()
+{
+}
+
+void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data)
+{
+ KABC::Addressee mAddressee = readFromString(data);
+ addressbook->insertAddressee(mAddressee);
+}
+
+KABC::Addressee VCard21Parser::readFromString( const QString &data)
+{
+ KABC::Addressee addressee;
+ VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data);
+ QString tmpStr;
+
+ // Check if parsing failed
+ if (mVCard == 0)
+ {
+ kdDebug() << "Parsing failed" << endl;
+ return addressee;
+ }
+ //set the addressees name and formated name
+ QStringList tmpList = mVCard->getValues(VCARD_N);
+ QString formattedName = "";
+ if (tmpList.count() > 0)
+ addressee.setFamilyName(tmpList[0]);
+ if (tmpList.count() > 1)
+ addressee.setGivenName(tmpList[1]);
+ if (tmpList.count() > 2)
+ addressee.setAdditionalName(tmpList[2]);
+ if (tmpList.count() > 3)
+ addressee.setPrefix(tmpList[3]);
+ if (tmpList.count() > 4)
+ addressee.setSuffix(tmpList[4]);
+
+ tmpStr = (mVCard->getValue(VCARD_FN));
+ if (!tmpStr.isEmpty())
+ addressee.setFormattedName(tmpStr);
+
+ //set the addressee's nick name
+ tmpStr = mVCard->getValue(VCARD_NICKNAME);
+ addressee.setNickName(tmpStr);
+ //set the addressee's organisation
+ tmpStr = mVCard->getValue(VCARD_ORG);
+ addressee.setOrganization(tmpStr);
+ //set the addressee's title
+ tmpStr = mVCard->getValue(VCARD_TITLE);
+ addressee.setTitle(tmpStr);
+ //set the addressee's email - we can only deal with two. The preferenced one and one other.
+ tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET);
+ addressee.insertEmail(tmpStr, false);
+ tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF);
+ addressee.insertEmail(tmpStr, true);
+ //set the addressee's url
+ tmpStr = mVCard->getValue(VCARD_URL);
+ if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK);
+ if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME);
+ if (!tmpStr.isEmpty()) {
+ addressee.setUrl(KURL(tmpStr));
+ }
+
+ //set the addressee's birthday
+ tmpStr = mVCard->getValue(VCARD_BDAY);
+ addressee.setBirthday(VCardStringToDate(tmpStr));
+
+ //set the addressee's phone numbers
+ for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) {
+ if ( (*i).name == VCARD_TEL ) {
+ int type = 0;
+ if ( (*i).qualified ) {
+ if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) )
+ type |= PhoneNumber::Home;
+ if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) )
+ type |= PhoneNumber::Work;
+ if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) )
+ type |= PhoneNumber::Pref;
+ // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) )
+ // type |= PhoneNumber::Voice;
+ if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) )
+ type |= PhoneNumber::Fax;
+ if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) )
+ type |= PhoneNumber::Msg;
+ if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) )
+ type |= PhoneNumber::Cell;
+ if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) )
+ type |= PhoneNumber::Pager;
+ if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) )
+ type |= PhoneNumber::Bbs;
+ if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) )
+ type |= PhoneNumber::Modem;
+ if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) )
+ type |= PhoneNumber::Car;
+ if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) )
+ type |= PhoneNumber::Isdn;
+ if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) )
+ type |= PhoneNumber::Video;
+ if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) )
+ type |= PhoneNumber::Pcs;
+ }
+ addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) );
+ }
+ }
+
+ //set the addressee's addresses
+ for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) {
+ if ( (*i).name == VCARD_ADR ) {
+ int type = 0;
+ if ( (*i).qualified ) {
+ if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) )
+ type |= Address::Dom;
+ if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) )
+ type |= Address::Intl;
+ if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) )
+ type |= Address::Postal;
+ if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) )
+ type |= Address::Parcel;
+ if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) )
+ type |= Address::Home;
+ if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) )
+ type |= Address::Work;
+ if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) )
+ type |= Address::Pref;
+ }
+ addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) );
+ }
+ }
+
+ //set the addressee's delivery label
+ tmpStr = mVCard->getValue(VCARD_LABEL);
+ if (!tmpStr.isEmpty()) {
+qDebug("VCard21Parser::readFromString please verify if replace is correct");
+//US tmpStr.replace("\r\n","\n");
+ tmpStr.replace( QRegExp("\r\n"), "\n" );
+ Address tmpAddress;
+ tmpAddress.setLabel(tmpStr);
+ addressee.insertAddress(tmpAddress);
+ }
+
+ //set the addressee's notes
+ tmpStr = mVCard->getValue(VCARD_NOTE);
+qDebug("VCard21Parser::readFromString please verify if correct");
+//US tmpStr.replace("\r\n","\n");
+ tmpStr.replace( QRegExp("\r\n"), "\n" );
+ addressee.setNote(tmpStr);
+
+ //set the addressee's timezone
+ tmpStr = mVCard->getValue(VCARD_TZ);
+ TimeZone tmpZone(tmpStr.toInt());
+ addressee.setTimeZone(tmpZone);
+
+ //set the addressee's geographical position
+ tmpList = mVCard->getValues(VCARD_GEO);
+ if (tmpList.count()==2)
+ {
+ tmpStr = tmpList[0];
+ float glat = tmpStr.toFloat();
+ tmpStr = tmpList[1];
+ float glong = tmpStr.toFloat();
+ Geo tmpGeo(glat,glong);
+ addressee.setGeo(tmpGeo);
+ }
+
+ //set the last revision date
+ tmpStr = mVCard->getValue(VCARD_REV);
+ addressee.setRevision(VCardStringToDate(tmpStr));
+
+ //set the role of the addressee
+ tmpStr = mVCard->getValue(VCARD_ROLE);
+ addressee.setRole(tmpStr);
+
+ return addressee;
+}
+
+
+
+KABC::Address VCard21Parser::readAddressFromQStringList ( const QStringList &data, const int type )
+{
+ KABC::Address mAddress;
+ mAddress.setType( type );
+
+ if ( data.count() > 0 )
+ mAddress.setPostOfficeBox( data[0] );
+ if ( data.count() > 1 )
+ mAddress.setExtended( data[1] );
+ if ( data.count() > 2 )
+ mAddress.setStreet( data[2] );
+ if ( data.count() > 3 )
+ mAddress.setLocality( data[3] );
+ if ( data.count() > 4 )
+ mAddress.setRegion( data[4] );
+ if ( data.count() > 5 )
+ mAddress.setPostalCode( data[5] );
+ if ( data.count() > 6 )
+ mAddress.setCountry( data[6] );
+
+ return mAddress;
+}
+
+
+VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err )
+{
+ int _err = 0;
+ int _state = VC_STATE_BEGIN;
+
+ QValueList<VCardLineX> *_vcdata;
+ QValueList<QString> lines;
+
+ _vcdata = new QValueList<VCardLineX>;
+
+ lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc );
+
+ // for each line in the vCard
+ for ( QStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) {
+ VCardLineX _vcl;
+
+ // take spaces off the end - ugly but necessary hack
+ for ( int g = (*j).length()-1; g > 0 && (*j)[g].isSpace(); --g )
+ (*j)[g] = 0;
+
+ // first token:
+ // verify state, update if necessary
+ if ( _state & VC_STATE_BEGIN) {
+ if ( !qstricmp( (*j).latin1(), VCARD_BEGIN ) ) {
+ _state = VC_STATE_BODY;
+ continue;
+ } else {
+ _err = VC_ERR_NO_BEGIN;
+ break;
+ }
+ } else if ( _state & VC_STATE_BODY ) {
+ if ( !qstricmp( (*j).latin1(), VCARD_END ) ) {
+ _state |= VC_STATE_END;
+ break;
+ }
+
+ // split into two tokens
+ int colon = (*j).find( ':' );
+ if ( colon < 0 ) {
+ _err = VC_ERR_INVALID_LINE;
+ break;
+ }
+
+ QString key = (*j).left( colon );
+ QString value = (*j).mid( colon + 1 );
+
+ // check for qualifiers and
+ // set name, qualified, qualifier(s)
+ QStringList keyTokens = QStringList::split( ';', key );
+ bool qp = false, first_pass = true;
+ bool b64 = false;
+
+ if ( keyTokens.count() > 0 ) {
+ _vcl.qualified = false;
+ _vcl.name = keyTokens[ 0 ].lower();
+
+ for ( QStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z ) {
+ QString zz = (*z).lower();
+ if ( zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE ) {
+ qp = true;
+ } else if ( zz == VCARD_BASE64 ) {
+ b64 = true;
+ } else if ( !first_pass ) {
+ _vcl.qualified = true;
+ _vcl.qualifiers.append( zz );
+ }
+ first_pass = false;
+ }
+ } else {
+ _err = VC_ERR_INVALID_LINE;
+ }
+
+ if ( _err != 0 )
+ break;
+
+ if ( _vcl.name == VCARD_VERSION )
+ _state |= VC_STATE_HAVE_VERSION;
+
+ if ( _vcl.name == VCARD_N || _vcl.name == VCARD_FN )
+ _state |= VC_STATE_HAVE_N;
+
+ // second token:
+ // split into tokens by ;
+ // add to parameters vector
+ if ( b64 ) {
+ if ( value.at( value.length() - 1 ) != '=' )
+ do {
+ value += *( ++j );
+ } while ( (*j).at( (*j).length() - 1 ) != '=' );
+ } else {
+ if ( qp ) { // join any split lines
+ while ( value.at( value.length() - 1 ) == '=' ) {
+ value.remove( value.length() - 1, 1 );
+ value.append(*( ++j ));
+ }
+ }
+ _vcl.parameters = QStringList::split( ';', value, true );
+ if ( qp ) { // decode the quoted printable
+ for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z )
+ *z = KCodecs::quotedPrintableDecode( (*z).latin1() );
+ }
+ }
+ } else {
+ _err = VC_ERR_INTERNAL;
+ break;
+ }
+
+ // validate VCardLineX
+ if ( !_vcl.isValid() ) {
+ _err = VC_ERR_INVALID_LINE;
+ break;
+ }
+
+ // add to vector
+ _vcdata->append( _vcl );
+ }
+
+ // errors to check at the last minute (exit state related)
+ if ( _err == 0 ) {
+ if ( !( _state & VC_STATE_END ) ) // we have to have an end!!
+ _err = VC_ERR_NO_END;
+
+ if ( !( _state & VC_STATE_HAVE_N ) || // we have to have the mandatories!
+ !( _state & VC_STATE_HAVE_VERSION ) )
+ _err = VC_ERR_MISSING_MANDATORY;
+ }
+
+ // set the error message if we can, and only return an object
+ // if the vCard was valid.
+ if ( err )
+ *err = _err;
+
+ if ( _err != 0 ) {
+ delete _vcdata;
+ return 0;
+ }
+
+ return new VCard21ParserImpl( _vcdata );
+}
+
+VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd)
+{
+}
+
+
+QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifier)
+{
+ QString failed;
+ const QString lowname = name.lower();
+ const QString lowqualifier = qualifier.lower();
+
+ for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) {
+ if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) {
+ if ((*i).parameters.count() > 0)
+ return (*i).parameters[0];
+ else return failed;
+ }
+ }
+ return failed;
+}
+
+
+QString VCard21ParserImpl::getValue(const QString& name)
+{
+ QString failed;
+ const QString lowname = name.lower();
+
+ for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) {
+ if ((*i).name == lowname && !(*i).qualified) {
+ if ((*i).parameters.count() > 0)
+ return (*i).parameters[0];
+ else return failed;
+ }
+ }
+ return failed;
+}
+
+
+QStringList VCard21ParserImpl::getValues(const QString& name)
+{
+ const QString lowname = name.lower();
+ for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) {
+ if ((*i).name == lowname && !(*i).qualified)
+ return (*i).parameters;
+ }
+ // failed.
+ return QStringList();
+}
+
+QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qualifier)
+{
+ const QString lowname = name.lower();
+ const QString lowqualifier = qualifier.lower();
+ for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) {
+ if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier))
+ return (*i).parameters;
+ }
+ // failed.
+ return QStringList();
+}
+
+
diff --git a/kabc/vcard21parser.h b/kabc/vcard21parser.h
new file mode 100644
index 0000000..24b0eb2
--- a/dev/null
+++ b/kabc/vcard21parser.h
@@ -0,0 +1,225 @@
+/*
+ This file is part of libkabc.
+
+ Copyright (c) 2002 Mark Westcott <mark@houseoffish.org>
+ Copyright (c) 2000 George Staikos <staikos@kde.org>
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_VCARD21FORMAT_H
+#define KABC_VCARD21FORMAT_H
+
+#include <qdatetime.h>
+#include <kdebug.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <kurl.h>
+#include <qvaluelist.h>
+
+#include "addressee.h"
+#include "addressbook.h"
+#include "phonenumber.h"
+
+
+#define VCARD_BEGIN "begin:vcard"
+#define VCARD_END "end:vcard"
+#define VCARD_BEGIN_N "begin"
+#define VCARD_END_N "end"
+#define VCARD_VERSION "version"
+
+#define VCARD_FN "fn"
+#define VCARD_N "n"
+
+// optional
+#define VCARD_NAME "name"
+#define VCARD_NICKNAME "nickname"
+#define VCARD_PHOTO "photo"
+#define VCARD_BDAY "bday"
+#define VCARD_ADR "adr"
+
+// types
+#define VCARD_ADR_DOM "dom"
+#define VCARD_ADR_INTL "intl"
+#define VCARD_ADR_POSTAL "postal"
+#define VCARD_ADR_PARCEL "parcel"
+#define VCARD_ADR_HOME "home"
+#define VCARD_ADR_WORK "work"
+#define VCARD_ADR_PREF "pref"
+// values
+#define VCARD_ADR_POBOX "PO Box"
+#define VCARD_ADR_EXTADR "Extended Address"
+#define VCARD_ADR_STREET "Street"
+#define VCARD_ADR_LOCALITY "Locality"
+#define VCARD_ADR_REGION "Region"
+#define VCARD_ADR_POSTCODE "Postal Code"
+#define VCARD_ADR_COUNTRY "Country Name"
+#define VCARD_LABEL "label"
+#define VCARD_PROFILE "profile"
+#define VCARD_SOURCE "source"
+#define VCARD_TEL "tel"
+// types
+#define VCARD_TEL_HOME "home"
+#define VCARD_TEL_WORK "work"
+#define VCARD_TEL_PREF "pref"
+#define VCARD_TEL_VOICE "voice"
+#define VCARD_TEL_FAX "fax"
+#define VCARD_TEL_MSG "msg"
+#define VCARD_TEL_CELL "cell"
+#define VCARD_TEL_PAGER "pager"
+#define VCARD_TEL_BBS "bbs"
+#define VCARD_TEL_MODEM "modem"
+#define VCARD_TEL_CAR "car"
+#define VCARD_TEL_ISDN "isdn"
+#define VCARD_TEL_VIDEO "video"
+#define VCARD_TEL_PCS "pcs"
+#define VCARD_EMAIL "email"
+// types
+#define VCARD_EMAIL_PREF "pref"
+#define VCARD_EMAIL_INTERNET "internet"
+#define VCARD_EMAIL_X400 "x400"
+#define VCARD_TZ "tz"
+#define VCARD_GEO "geo"
+#define VCARD_MAILER "mailer"
+#define VCARD_TITLE "title"
+#define VCARD_ROLE "role"
+#define VCARD_LOGO "logo"
+#define VCARD_AGENT "agent"
+#define VCARD_ORG "org"
+#define VCARD_CATEGORIES "categories"
+#define VCARD_NOTE "note"
+#define VCARD_PRODID "prodid"
+#define VCARD_REV "rev"
+#define VCARD_SOUND "sound"
+#define VCARD_UID "uid"
+#define VCARD_URL "url"
+#define VCARD_CLASS "class"
+#define VCARD_CLASS_PUBLIC "public"
+#define VCARD_CLASS_PRIVATE "private"
+#define VCARD_CLASS_CONFIDENTIAL "confidential"
+#define VCARD_KEY "key"
+// types
+#define VCARD_KEY_X509 "x509"
+#define VCARD_KEY_PGP "pgp"
+
+#define VCARD_QUOTED_PRINTABLE "quoted-printable"
+// this one is a temporary hack until we support TYPE=VALUE
+#define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable"
+#define VCARD_BASE64 "base64"
+
+#define VC_STATE_BEGIN 1
+#define VC_STATE_BODY 2
+#define VC_STATE_END 4
+#define VC_STATE_HAVE_N 8
+#define VC_STATE_HAVE_VERSION 16
+
+#define VC_ERR_NO_BEGIN 1
+#define VC_ERR_NO_END 2
+#define VC_ERR_INVALID_LINE 3
+#define VC_ERR_INTERNAL 4
+#define VC_ERR_INVALID_NAME 5
+#define VC_ERR_MISSING_MANDATORY 6
+
+namespace KABC {
+
+class AddressBook;
+
+class VCard21Parser
+{
+public:
+
+ /**
+ * Constructor.
+ */
+ VCard21Parser();
+
+ /**
+ * Destructor.
+ */
+ virtual ~VCard21Parser();
+
+ /**
+ * Parses a string in vcard2.1 format and saves the single addressees
+ * to the address book.
+ *
+ * @param ab The address book.
+ * @param str The vcard string.
+ */
+ void readFromString( KABC::AddressBook *ab, const QString &str );
+
+ /**
+ * FIXME: we need a writeToString method
+ * QString writeToString (KABC::AddressBook *);
+ */
+
+ /**
+ * Parses a string in vcard2.1 format and returns the inherent addressee.
+ */
+ KABC::Addressee readFromString( const QString &data);
+
+ /**
+ * Helper method to store a address.
+ *
+ * @param data A string list, that is filled with 'street', 'house number' ...
+ * @param type The type of the returned address.
+ */
+ static KABC::Address readAddressFromQStringList (const QStringList &data, const int type);
+};
+
+}
+
+/**
+ * @short Helper class
+ */
+class VCardLineX
+{
+public:
+ QString name;
+ bool qualified;
+ QValueList<QString> qualifiers;
+ QValueList<QString> parameters;
+ bool isValid() const;
+};
+
+/**
+ * @short Helper class
+ */
+class VCard21ParserImpl
+{
+ friend class VCardLineX;
+
+public:
+ VCard21ParserImpl() { };
+ virtual ~VCard21ParserImpl() { };
+ static VCard21ParserImpl *parseVCard(const QString& vc, int *err = NULL);
+ QString getValue(const QString& name, const QString& qualifier);
+ QString getValue(const QString& name);
+ QStringList getValues(const QString& name, const QString& qualifier);
+ QStringList getValues(const QString& name);
+
+ QValueList<VCardLineX> *_vcdata;
+
+private:
+ VCard21ParserImpl (QValueList<VCardLineX> *_vcd);
+};
+
+#endif
diff --git a/kabc/vcardconverter.cpp b/kabc/vcardconverter.cpp
new file mode 100644
index 0000000..266cdf9
--- a/dev/null
+++ b/kabc/vcardconverter.cpp
@@ -0,0 +1,115 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+//US
+#include "kglobal.h"
+
+#include "vcard21parser.h"
+#include "vcardformatimpl.h"
+
+#include "vcardconverter.h"
+
+using namespace KABC;
+
+struct VCardConverter::VCardConverterData
+{
+ VCard21Parser vcard21parser;
+ VCardFormatImpl vcard30parser;
+};
+
+VCardConverter::VCardConverter()
+ : d( new VCardConverterData )
+{
+}
+
+VCardConverter::~VCardConverter()
+{
+ delete d;
+ d = 0;
+}
+
+bool VCardConverter::vCardToAddressee( const QString &str, Addressee &addr, Version version )
+{
+ if ( version == v2_1 ) {
+ addr = d->vcard21parser.readFromString( str );
+ return true;
+ }
+
+ if ( version == v3_0 )
+ return d->vcard30parser.readFromString( str, addr );
+
+ return false;
+}
+
+bool VCardConverter::addresseeToVCard( const Addressee &addr, QString &str, Version version )
+{
+ if ( version == v2_1 )
+ return false;
+
+ if ( version == v3_0 )
+ return d->vcard30parser.writeToString( addr, str );
+
+ return false;
+}
+
+
+/* Helper functions */
+
+QString KABC::dateToVCardString( const QDateTime &dateTime )
+{
+qDebug("vcardconverter.cpp : KABC::dateToVCardString transformation does not work yet");
+ return KGlobal::locale()->formatDate(dateTime.date(), true);
+//US return dateTime.toString("yyyyMMddThhmmssZ");
+}
+
+QString KABC::dateToVCardString( const QDate &date )
+{
+qDebug("vcardconverter.cpp : KABC::dateToVCardString transformation does not work yet");
+ return KGlobal::locale()->formatDate(date, true);
+//US return date.toString("yyyyMMdd");
+}
+
+QDateTime KABC::VCardStringToDate( const QString &dateString )
+{
+ QDate date;
+ QTime time;
+ QString d( dateString );
+
+//US I hope this is correct
+//US d = d.remove('-').remove(':');
+ d = d.replace( QRegExp("-"), "" );
+ d = d.replace( QRegExp(":"), "" );
+
+
+ if (d.length()>=8)
+ date = QDate( d.mid(0,4).toUInt(), d.mid(4,2).toUInt(), d.mid(6,2).toUInt() );
+ if (d.length()>9 && d[8].upper()=='T')
+ time = QTime( d.mid(9,2).toUInt(), d.mid(11,2).toUInt(), d.mid(13,2).toUInt() );
+
+ return QDateTime( date, time );
+}
+
diff --git a/kabc/vcardconverter.h b/kabc/vcardconverter.h
new file mode 100644
index 0000000..52259fc
--- a/dev/null
+++ b/kabc/vcardconverter.h
@@ -0,0 +1,120 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_VCARDCONVERTER_H
+#define KABC_VCARDCONVERTER_H
+
+#include <qstring.h>
+
+#include "addressee.h"
+
+namespace KABC {
+
+/**
+ * Class to convert a vcard string to a addressee and vice versa.
+ * At the moment there exists read support for vCard2.1 and vCard3.0
+ * and write support for vCard3.0
+ */
+class VCardConverter
+{
+public:
+
+ /**
+ * @li v2_1 - VCard format version 2.1
+ * @li v3_0 - VCard format version 3.0
+ */
+ enum Version
+ {
+ v2_1,
+ v3_0
+ };
+
+ /**
+ * Constructor.
+ */
+ VCardConverter();
+
+ /**
+ * Destructor.
+ */
+ ~VCardConverter();
+
+ /**
+ * Converts a vcard string to an addressee.
+ *
+ * @param str The vcard string.
+ * @param addr The addressee.
+ * @param version The version of the vcard string.
+ */
+ bool vCardToAddressee( const QString &str, Addressee &addr, Version version = v3_0 );
+
+ /**
+ * Converts an addressee to a vcard string.
+ *
+ * @param addr The addressee.
+ * @param str The vcard string.
+ * @param version The version of the vcard string.
+ */
+ bool addresseeToVCard( const Addressee &addr, QString &str, Version version = v3_0 );
+
+private:
+ struct VCardConverterData;
+ VCardConverterData *d;
+};
+
+
+/**
+ Helper functions
+ */
+
+/**
+ * Converts a QDateTime to a date string as it is used in VCard and LDIF files.
+ * The return value is in the form "yyyyMMddThhmmssZ" (e.g. "20031201T120000Z")
+ * @param dateTime date and time to be converted
+ * @since 3.2
+ */
+QString dateToVCardString( const QDateTime &dateTime );
+
+/**
+ * Converts a QDate to a short date string as it is used in VCard and LDIF files.
+ * The return value is in the form "yyyyMMdd" (e.g. "20031201")
+ * @param date date to be converted
+ * @since 3.2
+ */
+QString dateToVCardString( const QDate &date );
+
+/**
+ * Converts a date string as it is used in VCard and LDIF files to a QDateTime value.
+ * If the date string does not contain a time value, it will be returned as 00:00:00.
+ * (e.g. "20031201T120000" will return a QDateTime for 2003-12-01 at 12:00)
+ * @param dateString string representing the date and time.
+ * @since 3.2
+ */
+QDateTime VCardStringToDate( const QString &dateString );
+
+}
+#endif
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
new file mode 100644
index 0000000..f90f813
--- a/dev/null
+++ b/kabc/vcardformatimpl.cpp
@@ -0,0 +1,1023 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#include <qfile.h>
+#include <qregexp.h>
+
+#include <kdebug.h>
+#include <kmdcodec.h>
+#include <kstandarddirs.h>
+#include <ktempfile.h>
+
+#include <VCard.h>
+
+#include "addressbook.h"
+#include "vcardformatimpl.h"
+
+using namespace KABC;
+using namespace VCARD;
+
+bool VCardFormatImpl::load( Addressee &addressee, QFile *file )
+{
+ kdDebug(5700) << "VCardFormat::load()" << endl;
+
+ QByteArray fdata = file->readAll();
+ QCString data(fdata.data(), fdata.size()+1);
+
+ VCardEntity e( data );
+
+ VCardListIterator it( e.cardList() );
+
+ if ( it.current() ) {
+ VCard v(*it.current());
+ loadAddressee( addressee, v );
+ return true;
+ }
+
+ return false;
+}
+
+bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
+{
+ kdDebug(5700) << "VCardFormat::loadAll()" << endl;
+
+ QByteArray fdata = file->readAll();
+ QCString data(fdata.data(), fdata.size()+1);
+
+ VCardEntity e( data );
+
+ VCardListIterator it( e.cardList() );
+
+ for (; it.current(); ++it) {
+ VCard v(*it.current());
+ Addressee addressee;
+ loadAddressee( addressee, v );
+ addressee.setResource( resource );
+ addressBook->insertAddressee( addressee );
+ }
+
+ return true;
+}
+
+void VCardFormatImpl::save( const Addressee &addressee, QFile *file )
+{
+ VCardEntity vcards;
+ VCardList vcardlist;
+ vcardlist.setAutoDelete( true );
+
+ VCard *v = new VCard;
+
+ saveAddressee( addressee, v, false );
+
+ vcardlist.append( v );
+ vcards.setCardList( vcardlist );
+
+ QCString vcardData = vcards.asString();
+ file->writeBlock( (const char*)vcardData, vcardData.length() );
+}
+
+void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file )
+{
+ VCardEntity vcards;
+ VCardList vcardlist;
+ vcardlist.setAutoDelete( true );
+
+ AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it ) {
+ if ( (*it).resource() == resource ) {
+ VCard *v = new VCard;
+ saveAddressee( (*it), v, false );
+ (*it).setChanged( false );
+ vcardlist.append( v );
+ }
+ }
+
+ vcards.setCardList( vcardlist );
+
+ QCString vcardData = vcards.asString();
+ file->writeBlock( (const char*)vcardData, vcardData.length() );
+}
+
+bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard &v )
+{
+ QPtrList<ContentLine> contentLines = v.contentLineList();
+ ContentLine *cl;
+
+ for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
+ QCString n = cl->name();
+ if ( n.left( 2 ) == "X-" ) {
+ n = n.mid( 2 );
+ int posDash = n.find( "-" );
+ addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ),
+ QString::fromUtf8( n.mid( posDash + 1 ) ),
+ QString::fromUtf8( cl->value()->asString() ) );
+ continue;
+ }
+
+ EntityType type = cl->entityType();
+ switch( type ) {
+
+ case EntityUID:
+ addressee.setUid( readTextValue( cl ) );
+ break;
+
+ case EntityEmail:
+ addressee.insertEmail( readTextValue( cl ) );
+ break;
+
+ case EntityName:
+ addressee.setName( readTextValue( cl ) );
+ break;
+
+ case EntityFullName:
+ addressee.setFormattedName( readTextValue( cl ) );
+ break;
+
+ case EntityURL:
+ addressee.setUrl( KURL( readTextValue( cl ) ) );
+ break;
+
+ case EntityNickname:
+ addressee.setNickName( readTextValue( cl ) );
+ break;
+
+ case EntityLabel:
+ // not yet supported by kabc
+ break;
+
+ case EntityMailer:
+ addressee.setMailer( readTextValue( cl ) );
+ break;
+
+ case EntityTitle:
+ addressee.setTitle( readTextValue( cl ) );
+ break;
+
+ case EntityRole:
+ addressee.setRole( readTextValue( cl ) );
+ break;
+
+ case EntityOrganisation:
+ addressee.setOrganization( readTextValue( cl ) );
+ break;
+
+ case EntityNote:
+ addressee.setNote( readTextValue( cl ) );
+ break;
+
+ case EntityProductID:
+ addressee.setProductId( readTextValue( cl ) );
+ break;
+
+ case EntitySortString:
+ addressee.setSortString( readTextValue( cl ) );
+ break;
+
+ case EntityN:
+ readNValue( cl, addressee );
+ break;
+
+ case EntityAddress:
+ addressee.insertAddress( readAddressValue( cl ) );
+ break;
+
+ case EntityTelephone:
+ addressee.insertPhoneNumber( readTelephoneValue( cl ) );
+ break;
+
+ case EntityCategories:
+ addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) );
+ break;
+
+ case EntityBirthday:
+ addressee.setBirthday( readDateValue( cl ) );
+ break;
+
+ case EntityRevision:
+ addressee.setRevision( readDateTimeValue( cl ) );
+ break;
+
+ case EntityGeo:
+ addressee.setGeo( readGeoValue( cl ) );
+ break;
+
+ case EntityTimeZone:
+ addressee.setTimeZone( readUTCValue( cl ) );
+ break;
+
+ case EntityVersion:
+ break;
+
+ case EntityClass:
+ addressee.setSecrecy( readClassValue( cl ) );
+ break;
+
+ case EntityKey:
+ addressee.insertKey( readKeyValue( cl ) );
+ break;
+
+ case EntityPhoto:
+ addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
+ break;
+
+ case EntityLogo:
+ addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
+ break;
+
+ case EntityAgent:
+ addressee.setAgent( readAgentValue( cl ) );
+ break;
+
+ case EntitySound:
+ addressee.setSound( readSoundValue( cl, addressee ) );
+ break;
+
+ default:
+ kdDebug(5700) << "VCardFormat::load(): Unsupported entity: "
+ << int( type ) << ": " << cl->asString() << endl;
+ break;
+ }
+ }
+
+ for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
+ EntityType type = cl->entityType();
+ if ( type == EntityLabel ) {
+ int type = readAddressParam( cl );
+ Address address = addressee.address( type );
+ if ( address.isEmpty() )
+ address.setType( type );
+
+ address.setLabel( QString::fromUtf8( cl->value()->asString() ) );
+ addressee.insertAddress( address );
+ }
+ }
+
+ return true;
+}
+
+void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern )
+{
+ ContentLine cl;
+ QString value;
+
+ addTextValue( v, EntityName, addressee.name() );
+ addTextValue( v, EntityUID, addressee.uid() );
+ addTextValue( v, EntityFullName, addressee.formattedName() );
+
+ QStringList emails = addressee.emails();
+ QStringList::ConstIterator it4;
+ for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) {
+ addTextValue( v, EntityEmail, *it4 );
+ }
+
+ QStringList customs = addressee.customs();
+ QStringList::ConstIterator it5;
+ for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) {
+ addCustomValue( v, *it5 );
+ }
+
+ addTextValue( v, EntityURL, addressee.url().url() );
+
+ addNValue( v, addressee );
+
+ addTextValue( v, EntityNickname, addressee.nickName() );
+ addTextValue( v, EntityMailer, addressee.mailer() );
+ addTextValue( v, EntityTitle, addressee.title() );
+ addTextValue( v, EntityRole, addressee.role() );
+ addTextValue( v, EntityOrganisation, addressee.organization() );
+ addTextValue( v, EntityNote, addressee.note() );
+ addTextValue( v, EntityProductID, addressee.productId() );
+ addTextValue( v, EntitySortString, addressee.sortString() );
+
+ Address::List addresses = addressee.addresses();
+ Address::List::ConstIterator it3;
+ for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) {
+ addAddressValue( v, *it3 );
+ addLabelValue( v, *it3 );
+ }
+
+ PhoneNumber::List phoneNumbers = addressee.phoneNumbers();
+ PhoneNumber::List::ConstIterator it2;
+ for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) {
+ addTelephoneValue( v, *it2 );
+ }
+
+ Key::List keys = addressee.keys();
+ Key::List::ConstIterator it6;
+ for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) {
+ addKeyValue( v, *it6 );
+ }
+
+ addTextValue( v, EntityCategories, addressee.categories().join(",") );
+
+ addDateValue( v, EntityBirthday, addressee.birthday().date() );
+ addDateTimeValue( v, EntityRevision, addressee.revision() );
+ addGeoValue( v, addressee.geo() );
+ addUTCValue( v, addressee.timeZone() );
+
+ addClassValue( v, addressee.secrecy() );
+
+ addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern );
+ addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern );
+
+ addAgentValue( v, addressee.agent() );
+
+ addSoundValue( v, addressee.sound(), addressee, intern );
+}
+
+void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt )
+{
+ if ( txt.isEmpty() ) return;
+
+ ContentLine cl;
+ cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() );
+ QString value = txt.mid( txt.find( ":" ) + 1 );
+ if ( value.isEmpty() )
+ return;
+ cl.setValue( new TextValue( value.utf8() ) );
+ v->add(cl);
+}
+
+void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt )
+{
+ if ( txt.isEmpty() ) return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( type ) );
+ cl.setValue( new TextValue( txt.utf8() ) );
+ v->add(cl);
+}
+
+void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type,
+ const QDate &date )
+{
+ if ( !date.isValid() ) return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( type ) );
+
+ DateValue *v = new DateValue( date );
+ cl.setValue( v );
+ vcard->add(cl);
+}
+
+void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type,
+ const QDateTime &dateTime )
+{
+ if ( !dateTime.isValid() ) return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( type ) );
+
+ DateValue *v = new DateValue( dateTime );
+ cl.setValue( v );
+ vcard->add(cl);
+}
+
+void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a )
+{
+ if ( a.isEmpty() )
+ return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityAddress ) );
+
+ AdrValue *v = new AdrValue;
+ v->setPOBox( a.postOfficeBox().utf8() );
+ v->setExtAddress( a.extended().utf8() );
+ v->setStreet( a.street().utf8() );
+ v->setLocality( a.locality().utf8() );
+ v->setRegion( a.region().utf8() );
+ v->setPostCode( a.postalCode().utf8() );
+ v->setCountryName( a.country().utf8() );
+ cl.setValue( v );
+
+ addAddressParam( &cl, a.type() );
+
+ vcard->add( cl );
+}
+
+void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a )
+{
+ if ( a.label().isEmpty() ) return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityLabel ) );
+ cl.setValue( new TextValue( a.label().utf8() ) );
+
+ addAddressParam( &cl, a.type() );
+
+ vcard->add( cl );
+}
+
+void VCardFormatImpl::addAddressParam( ContentLine *cl, int type )
+{
+ ParamList params;
+ if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) );
+ if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) );
+ if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) );
+ if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) );
+ if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) );
+ if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) );
+ if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) );
+ cl->setParamList( params );
+}
+
+void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo )
+{
+ if ( !geo.isValid() ) return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityGeo ) );
+
+ GeoValue *v = new GeoValue;
+ v->setLatitude( geo.latitude() );
+ v->setLongitude( geo.longitude() );
+
+ cl.setValue( v );
+ vcard->add(cl);
+}
+
+void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz )
+{
+ if ( !tz.isValid() ) return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityTimeZone ) );
+
+ UTCValue *v = new UTCValue;
+
+ v->setPositive( tz.offset() >= 0 );
+ v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
+ v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
+
+ cl.setValue( v );
+ vcard->add(cl);
+}
+
+void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy )
+{
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityClass ) );
+
+ ClassValue *v = new ClassValue;
+ switch ( secrecy.type() ) {
+ case Secrecy::Public:
+ v->setType( (int)ClassValue::Public );
+ break;
+ case Secrecy::Private:
+ v->setType( (int)ClassValue::Private );
+ break;
+ case Secrecy::Confidential:
+ v->setType( (int)ClassValue::Confidential );
+ break;
+ }
+
+ cl.setValue( v );
+ vcard->add(cl);
+}
+
+
+Address VCardFormatImpl::readAddressValue( ContentLine *cl )
+{
+ Address a;
+ AdrValue *v = (AdrValue *)cl->value();
+ a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) );
+ a.setExtended( QString::fromUtf8( v->extAddress() ) );
+ a.setStreet( QString::fromUtf8( v->street() ) );
+ a.setLocality( QString::fromUtf8( v->locality() ) );
+ a.setRegion( QString::fromUtf8( v->region() ) );
+ a.setPostalCode( QString::fromUtf8( v->postCode() ) );
+ a.setCountry( QString::fromUtf8( v->countryName() ) );
+
+ a.setType( readAddressParam( cl ) );
+
+ return a;
+}
+
+int VCardFormatImpl::readAddressParam( ContentLine *cl )
+{
+ int type = 0;
+ ParamList params = cl->paramList();
+ ParamListIterator it( params );
+ for( ; it.current(); ++it ) {
+ if ( (*it)->name() == "TYPE" ) {
+ if ( (*it)->value() == "dom" ) type |= Address::Dom;
+ else if ( (*it)->value() == "intl" ) type |= Address::Intl;
+ else if ( (*it)->value() == "parcel" ) type |= Address::Parcel;
+ else if ( (*it)->value() == "postal" ) type |= Address::Postal;
+ else if ( (*it)->value() == "work" ) type |= Address::Work;
+ else if ( (*it)->value() == "home" ) type |= Address::Home;
+ else if ( (*it)->value() == "pref" ) type |= Address::Pref;
+ }
+ }
+ return type;
+}
+
+void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a )
+{
+ ContentLine cl;
+ cl.setName(EntityTypeToParamName( EntityN ) );
+ NValue *v = new NValue;
+ v->setFamily( a.familyName().utf8() );
+ v->setGiven( a.givenName().utf8() );
+ v->setMiddle( a.additionalName().utf8() );
+ v->setPrefix( a.prefix().utf8() );
+ v->setSuffix( a.suffix().utf8() );
+
+ cl.setValue( v );
+ vcard->add(cl);
+}
+
+void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a )
+{
+ NValue *v = (NValue *)cl->value();
+ a.setFamilyName( QString::fromUtf8( v->family() ) );
+ a.setGivenName( QString::fromUtf8( v->given() ) );
+ a.setAdditionalName( QString::fromUtf8( v->middle() ) );
+ a.setPrefix( QString::fromUtf8( v->prefix() ) );
+ a.setSuffix( QString::fromUtf8( v->suffix() ) );
+}
+
+void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p )
+{
+ if ( p.number().isEmpty() )
+ return;
+
+ ContentLine cl;
+ cl.setName(EntityTypeToParamName(EntityTelephone));
+ cl.setValue(new TelValue( p.number().utf8() ));
+
+ ParamList params;
+ if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) );
+ if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) );
+ if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) );
+ if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) );
+ if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) );
+ if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) );
+ if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) );
+ if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) );
+ if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) );
+ if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) );
+ if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) );
+ if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) );
+ if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) );
+ if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) );
+ cl.setParamList( params );
+
+ v->add(cl);
+}
+
+PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl )
+{
+ PhoneNumber p;
+ TelValue *value = (TelValue *)cl->value();
+ p.setNumber( QString::fromUtf8( value->asString() ) );
+
+ int type = 0;
+ ParamList params = cl->paramList();
+ ParamListIterator it( params );
+ for( ; it.current(); ++it ) {
+ if ( (*it)->name() == "TYPE" ) {
+ if ( (*it)->value() == "home" ) type |= PhoneNumber::Home;
+ else if ( (*it)->value() == "work" ) type |= PhoneNumber::Work;
+ else if ( (*it)->value() == "msg" ) type |= PhoneNumber::Msg;
+ else if ( (*it)->value() == "pref" ) type |= PhoneNumber::Pref;
+ else if ( (*it)->value() == "voice" ) type |= PhoneNumber::Voice;
+ else if ( (*it)->value() == "fax" ) type |= PhoneNumber::Fax;
+ else if ( (*it)->value() == "cell" ) type |= PhoneNumber::Cell;
+ else if ( (*it)->value() == "video" ) type |= PhoneNumber::Video;
+ else if ( (*it)->value() == "bbs" ) type |= PhoneNumber::Bbs;
+ else if ( (*it)->value() == "modem" ) type |= PhoneNumber::Modem;
+ else if ( (*it)->value() == "car" ) type |= PhoneNumber::Car;
+ else if ( (*it)->value() == "isdn" ) type |= PhoneNumber::Isdn;
+ else if ( (*it)->value() == "pcs" ) type |= PhoneNumber::Pcs;
+ else if ( (*it)->value() == "pager" ) type |= PhoneNumber::Pager;
+ }
+ }
+ p.setType( type );
+
+ return p;
+}
+
+QString VCardFormatImpl::readTextValue( ContentLine *cl )
+{
+ VCARD::Value *value = cl->value();
+ if ( value ) {
+ return QString::fromUtf8( value->asString() );
+ } else {
+ kdDebug(5700) << "No value: " << cl->asString() << endl;
+ return QString::null;
+ }
+}
+
+QDate VCardFormatImpl::readDateValue( ContentLine *cl )
+{
+ DateValue *dateValue = (DateValue *)cl->value();
+ if ( dateValue )
+ return dateValue->qdate();
+ else
+ return QDate();
+}
+
+QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl )
+{
+ DateValue *dateValue = (DateValue *)cl->value();
+ if ( dateValue )
+ return dateValue->qdt();
+ else
+ return QDateTime();
+}
+
+Geo VCardFormatImpl::readGeoValue( ContentLine *cl )
+{
+ GeoValue *geoValue = (GeoValue *)cl->value();
+ if ( geoValue ) {
+ Geo geo( geoValue->latitude(), geoValue->longitude() );
+ return geo;
+ } else
+ return Geo();
+}
+
+TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl )
+{
+ UTCValue *utcValue = (UTCValue *)cl->value();
+ if ( utcValue ) {
+ TimeZone tz;
+ tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1));
+ return tz;
+ } else
+ return TimeZone();
+}
+
+Secrecy VCardFormatImpl::readClassValue( ContentLine *cl )
+{
+ ClassValue *classValue = (ClassValue *)cl->value();
+ if ( classValue ) {
+ Secrecy secrecy;
+ switch ( classValue->type() ) {
+ case ClassValue::Public:
+ secrecy.setType( Secrecy::Public );
+ break;
+ case ClassValue::Private:
+ secrecy.setType( Secrecy::Private );
+ break;
+ case ClassValue::Confidential:
+ secrecy.setType( Secrecy::Confidential );
+ break;
+ }
+
+ return secrecy;
+ } else
+ return Secrecy();
+}
+
+void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key )
+{
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityKey ) );
+
+ ParamList params;
+ if ( key.isBinary() ) {
+ cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) );
+ params.append( new Param( "ENCODING", "b" ) );
+ } else {
+ cl.setValue( new TextValue( key.textData().utf8() ) );
+ }
+
+ switch ( key.type() ) {
+ case Key::X509:
+ params.append( new Param( "TYPE", "X509" ) );
+ break;
+ case Key::PGP:
+ params.append( new Param( "TYPE", "PGP" ) );
+ break;
+ case Key::Custom:
+ params.append( new Param( "TYPE", key.customTypeString().utf8() ) );
+ break;
+ }
+
+ cl.setParamList( params );
+ vcard->add( cl );
+}
+
+Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl )
+{
+ Key key;
+ bool isBinary = false;
+ TextValue *v = (TextValue *)cl->value();
+
+ ParamList params = cl->paramList();
+ ParamListIterator it( params );
+ for( ; it.current(); ++it ) {
+ if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
+ isBinary = true;
+ if ( (*it)->name() == "TYPE" ) {
+ if ( (*it)->value().isEmpty() )
+ continue;
+ if ( (*it)->value() == "X509" )
+ key.setType( Key::X509 );
+ else if ( (*it)->value() == "PGP" )
+ key.setType( Key::PGP );
+ else {
+ key.setType( Key::Custom );
+ key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) );
+ }
+ }
+ }
+
+
+ if ( isBinary ) {
+ QByteArray data;
+ KCodecs::base64Decode( v->asString().stripWhiteSpace(), data );
+ key.setBinaryData( data );
+ } else {
+ key.setTextData( QString::fromUtf8( v->asString() ) );
+ }
+
+ return key;
+}
+
+
+void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent )
+{
+ if ( agent.isIntern() && !agent.addressee() )
+ return;
+
+ if ( !agent.isIntern() && agent.url().isEmpty() )
+ return;
+
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntityAgent ) );
+
+ ParamList params;
+ if ( agent.isIntern() ) {
+ QString vstr;
+ Addressee *addr = agent.addressee();
+ if ( addr ) {
+ writeToString( (*addr), vstr );
+
+ qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
+/*US
+ vstr.replace( ":", "\\:" );
+ vstr.replace( ",", "\\," );
+ vstr.replace( ";", "\\;" );
+ vstr.replace( "\r\n", "\\n" );
+*/
+ vstr.replace( QRegExp(":"), "\\:" );
+ vstr.replace( QRegExp(","), "\\," );
+ vstr.replace( QRegExp(";"), "\\;" );
+ vstr.replace( QRegExp("\r\n"), "\\n" );
+
+ cl.setValue( new TextValue( vstr.utf8() ) );
+ } else
+ return;
+ } else {
+ cl.setValue( new TextValue( agent.url().utf8() ) );
+ params.append( new Param( "VALUE", "uri" ) );
+ }
+
+ cl.setParamList( params );
+ vcard->add( cl );
+}
+
+Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
+{
+ Agent agent;
+ bool isIntern = true;
+ TextValue *v = (TextValue *)cl->value();
+
+ ParamList params = cl->paramList();
+ ParamListIterator it( params );
+ for( ; it.current(); ++it ) {
+ if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" )
+ isIntern = false;
+ }
+
+ if ( isIntern ) {
+ QString vstr = QString::fromUtf8( v->asString() );
+ qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
+/*US
+ vstr.replace( "\\n", "\r\n" );
+ vstr.replace( "\\:", ":" );
+ vstr.replace( "\\,", "," );
+ vstr.replace( "\\;", ";" );
+*/
+ vstr.replace( QRegExp("\\n"), "\r\n" );
+ vstr.replace( QRegExp("\\:"), ":" );
+ vstr.replace( QRegExp("\\,"), "," );
+ vstr.replace( QRegExp("\\;"), ";" );
+
+ Addressee *addr = new Addressee;
+ readFromString( vstr, *addr );
+ agent.setAddressee( addr );
+ } else {
+ agent.setUrl( QString::fromUtf8( v->asString() ) );
+ }
+
+ return agent;
+}
+
+void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern )
+{
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( type ) );
+
+ if ( pic.isIntern() && pic.data().isNull() )
+ return;
+
+ if ( !pic.isIntern() && pic.url().isEmpty() )
+ return;
+
+ ParamList params;
+ if ( pic.isIntern() ) {
+ QImage img = pic.data();
+ if ( intern ) { // only for vCard export we really write the data inline
+ QByteArray data;
+ QDataStream s( data, IO_WriteOnly );
+ s.setVersion( 4 ); // to produce valid png files
+ s << img;
+ cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
+
+ } else { // save picture in cache
+ QString dir;
+ if ( type == EntityPhoto )
+ dir = "photos";
+ if ( type == EntityLogo )
+ dir = "logos";
+
+ img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() );
+ cl.setValue( new TextValue( "<dummy>" ) );
+ }
+ params.append( new Param( "ENCODING", "b" ) );
+ if ( !pic.type().isEmpty() )
+ params.append( new Param( "TYPE", pic.type().utf8() ) );
+ } else {
+
+ cl.setValue( new TextValue( pic.url().utf8() ) );
+ params.append( new Param( "VALUE", "uri" ) );
+ }
+
+ cl.setParamList( params );
+ vcard->add( cl );
+}
+
+Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr )
+{
+ Picture pic;
+ bool isInline = false;
+ QString picType;
+ TextValue *v = (TextValue *)cl->value();
+
+ ParamList params = cl->paramList();
+ ParamListIterator it( params );
+ for( ; it.current(); ++it ) {
+ if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
+ isInline = true;
+ if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() )
+ picType = QString::fromUtf8( (*it)->value() );
+ }
+
+ if ( isInline ) {
+ QImage img;
+ if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache
+ QString dir;
+ if ( type == EntityPhoto )
+ dir = "photos";
+ if ( type == EntityLogo )
+ dir = "logos";
+
+ img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) );
+ } else {
+ QByteArray data;
+ KCodecs::base64Decode( v->asString(), data );
+ img.loadFromData( data );
+ }
+ pic.setData( img );
+ pic.setType( picType );
+ } else {
+ pic.setUrl( QString::fromUtf8( v->asString() ) );
+ }
+
+ return pic;
+}
+
+void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern )
+{
+ ContentLine cl;
+ cl.setName( EntityTypeToParamName( EntitySound ) );
+
+ if ( sound.isIntern() && sound.data().isNull() )
+ return;
+
+ if ( !sound.isIntern() && sound.url().isEmpty() )
+ return;
+
+ ParamList params;
+ if ( sound.isIntern() ) {
+ QByteArray data = sound.data();
+ if ( intern ) { // only for vCard export we really write the data inline
+ cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
+ } else { // save sound in cache
+ QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) );
+ if ( file.open( IO_WriteOnly ) ) {
+ file.writeBlock( data );
+ }
+ cl.setValue( new TextValue( "<dummy>" ) );
+ }
+ params.append( new Param( "ENCODING", "b" ) );
+ } else {
+ cl.setValue( new TextValue( sound.url().utf8() ) );
+ params.append( new Param( "VALUE", "uri" ) );
+ }
+
+ cl.setParamList( params );
+ vcard->add( cl );
+}
+
+Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr )
+{
+ Sound sound;
+ bool isInline = false;
+ TextValue *v = (TextValue *)cl->value();
+
+ ParamList params = cl->paramList();
+ ParamListIterator it( params );
+ for( ; it.current(); ++it ) {
+ if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
+ isInline = true;
+ }
+
+ if ( isInline ) {
+ QByteArray data;
+ if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache
+ QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) );
+ if ( file.open( IO_ReadOnly ) ) {
+ data = file.readAll();
+ file.close();
+ }
+ } else {
+ KCodecs::base64Decode( v->asString(), data );
+ }
+ sound.setData( data );
+ } else {
+ sound.setUrl( QString::fromUtf8( v->asString() ) );
+ }
+
+ return sound;
+}
+
+bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee )
+{
+ VCardEntity e( vcard.utf8() );
+ VCardListIterator it( e.cardList() );
+
+ if ( it.current() ) {
+ VCard v(*it.current());
+ loadAddressee( addressee, v );
+ return true;
+ }
+
+ return false;
+}
+
+bool VCardFormatImpl::writeToString( const Addressee &addressee, QString &vcard )
+{
+ VCardEntity vcards;
+ VCardList vcardlist;
+ vcardlist.setAutoDelete( true );
+
+ VCard *v = new VCard;
+
+ saveAddressee( addressee, v, true );
+
+ vcardlist.append( v );
+ vcards.setCardList( vcardlist );
+ vcard = QString::fromUtf8( vcards.asString() );
+
+ return true;
+}
diff --git a/kabc/vcardformatimpl.h b/kabc/vcardformatimpl.h
new file mode 100644
index 0000000..2dd68d9
--- a/dev/null
+++ b/kabc/vcardformatimpl.h
@@ -0,0 +1,112 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
+#ifndef KABC_VCARDFORMATIMPL_H
+#define KABC_VCARDFORMATIMPL_H
+
+#include <qstring.h>
+#include <qfile.h>
+
+#include "address.h"
+#include "addressee.h"
+
+#include <VCard.h>
+
+namespace KABC {
+
+class AddressBook;
+
+/**
+ @short Implementation of vCard backend for address book.
+
+ This class implements reading and writing of address book information using
+ the vCard format. It requires the vCard lib from kdepim.
+*/
+class VCardFormatImpl
+{
+ public:
+ bool load( Addressee &, QFile *file );
+ bool loadAll( AddressBook *, Resource *, QFile *file );
+ void save( const Addressee &, QFile *file );
+ void saveAll( AddressBook *, Resource *, QFile *file );
+
+ bool readFromString( const QString &vcard, Addressee &addr );
+ bool writeToString( const Addressee &addressee, QString &vcard );
+
+ protected:
+ bool loadAddressee( Addressee &, VCARD::VCard & );
+ void saveAddressee( const Addressee &, VCARD::VCard *, bool intern );
+
+ void addTextValue (VCARD::VCard *, VCARD::EntityType, const QString & );
+ QString readTextValue( VCARD::ContentLine * );
+
+ void addDateValue( VCARD::VCard *, VCARD::EntityType, const QDate & );
+ QDate readDateValue( VCARD::ContentLine * );
+
+ void addDateTimeValue( VCARD::VCard *, VCARD::EntityType, const QDateTime & );
+ QDateTime readDateTimeValue( VCARD::ContentLine * );
+
+ void addAddressValue( VCARD::VCard *, const Address & );
+ Address readAddressValue( VCARD::ContentLine * );
+
+ void addLabelValue( VCARD::VCard *, const Address & );
+
+ void addTelephoneValue( VCARD::VCard *, const PhoneNumber & );
+ PhoneNumber readTelephoneValue( VCARD::ContentLine * );
+
+ void addNValue( VCARD::VCard *, const Addressee & );
+ void readNValue( VCARD::ContentLine *, Addressee & );
+
+ void addCustomValue( VCARD::VCard *, const QString & );
+
+ void addAddressParam( VCARD::ContentLine *, int );
+ int readAddressParam( VCARD::ContentLine * );
+
+ void addGeoValue( VCARD::VCard *, const Geo & );
+ Geo readGeoValue( VCARD::ContentLine * );
+
+ void addUTCValue( VCARD::VCard *, const TimeZone & );
+ TimeZone readUTCValue( VCARD::ContentLine * );
+
+ void addClassValue( VCARD::VCard *, const Secrecy & );
+ Secrecy readClassValue( VCARD::ContentLine * );
+
+ void addKeyValue( VCARD::VCard *, const Key & );
+ Key readKeyValue( VCARD::ContentLine * );
+
+ void addPictureValue( VCARD::VCard *, VCARD::EntityType, const Picture &, const Addressee &, bool );
+ Picture readPictureValue( VCARD::ContentLine *, VCARD::EntityType, const Addressee &addr );
+
+ void addSoundValue( VCARD::VCard *, const Sound &, const Addressee &, bool );
+ Sound readSoundValue( VCARD::ContentLine *, const Addressee &addr );
+
+ void addAgentValue( VCARD::VCard *, const Agent & );
+ Agent readAgentValue( VCARD::ContentLine * );
+};
+
+}
+#endif
diff --git a/kabc/vcardformatplugin.cpp b/kabc/vcardformatplugin.cpp
new file mode 100644
index 0000000..3cba59a
--- a/dev/null
+++ b/kabc/vcardformatplugin.cpp
@@ -0,0 +1,66 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "vcardformatplugin.h"
+#include "vcardformatimpl.h"
+
+using namespace KABC;
+
+VCardFormatPlugin::VCardFormatPlugin()
+{
+ mImpl = new VCardFormatImpl;
+}
+
+VCardFormatPlugin::~VCardFormatPlugin()
+{
+ delete mImpl;
+}
+
+bool VCardFormatPlugin::load( Addressee &addressee, QFile *file )
+{
+ return mImpl->load( addressee, file );
+}
+
+bool VCardFormatPlugin::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
+{
+ return mImpl->loadAll( addressBook, resource, file );
+}
+
+void VCardFormatPlugin::save( const Addressee &addressee, QFile *file )
+{
+ mImpl->save( addressee, file );
+}
+
+void VCardFormatPlugin::saveAll( AddressBook *addressBook, Resource *resource, QFile *file )
+{
+ mImpl->saveAll( addressBook, resource, file );
+}
+
+bool VCardFormatPlugin::checkFormat( QFile *file ) const
+{
+ QString line;
+
+ file->readLine( line, 1024 );
+ line = line.stripWhiteSpace();
+ if ( line == "BEGIN:VCARD" )
+ return true;
+ else
+ return false;
+}
diff --git a/kabc/vcardformatplugin.h b/kabc/vcardformatplugin.h
new file mode 100644
index 0000000..dc2b45d
--- a/dev/null
+++ b/kabc/vcardformatplugin.h
@@ -0,0 +1,56 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_VCARDFORMATPLUGIN_H
+#define KABC_VCARDFORMATPLUGIN_H
+
+#include "formatplugin.h"
+
+namespace KABC {
+
+class AddressBook;
+class Addressee;
+class VCardFormatImpl;
+
+/**
+ @short Interface of vCard backend for address book.
+
+ This class implements the file format interface of address book entries for
+ the vCard format.
+*/
+class VCardFormatPlugin : public FormatPlugin
+{
+ public:
+ VCardFormatPlugin();
+ virtual ~VCardFormatPlugin();
+
+ bool load( Addressee &, QFile *file );
+ bool loadAll( AddressBook *, Resource *, QFile *file );
+ void save( const Addressee &, QFile *file );
+ void saveAll( AddressBook *, Resource *, QFile *file );
+
+ bool checkFormat( QFile *file ) const;
+
+ private:
+ VCardFormatImpl *mImpl;
+};
+
+}
+#endif
diff --git a/kabc/vcardparser/vcard.cpp b/kabc/vcardparser/vcard.cpp
new file mode 100644
index 0000000..da97ec2
--- a/dev/null
+++ b/kabc/vcardparser/vcard.cpp
@@ -0,0 +1,144 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "vcard.h"
+
+using namespace KABC;
+
+VCard::VCard()
+ : mLineMap( 0 )
+{
+}
+
+VCard::VCard( const VCard& vcard )
+ : mLineMap( 0 )
+{
+ if ( vcard.mLineMap ) {
+ if ( !mLineMap )
+ mLineMap = new QMap<QString, QValueList<VCardLine> >;
+
+ *mLineMap = *(vcard.mLineMap);
+ } else {
+ delete mLineMap;
+ mLineMap = 0;
+ }
+}
+
+VCard::~VCard()
+{
+ delete mLineMap;
+ mLineMap = 0;
+}
+
+VCard& VCard::operator=( const VCard& vcard )
+{
+ if ( &vcard == this )
+ return *this;
+
+ if ( vcard.mLineMap ) {
+ if ( !mLineMap )
+ mLineMap = new QMap<QString, QValueList<VCardLine> >;
+
+ *mLineMap = *(vcard.mLineMap);
+ } else {
+ delete mLineMap;
+ mLineMap = 0;
+ }
+
+ return *this;
+}
+
+void VCard::clear()
+{
+ if ( mLineMap )
+ mLineMap->clear();
+}
+
+QStringList VCard::identifiers() const
+{
+ if ( !mLineMap )
+ return QStringList();
+ else {
+//US method QMap::keys() not available yet. SO collect the data manually
+//US return mLineMap->keys();
+
+ QStringList result;
+
+ QMap< QString, VCardLine::List >::ConstIterator it;
+ for( it = mLineMap->begin(); it != mLineMap->end(); ++it ) {
+ result << it.key().latin1();
+ }
+ return result;
+ }
+}
+
+void VCard::addLine( const VCardLine& line )
+{
+ if ( !mLineMap )
+ mLineMap = new QMap<QString, QValueList<VCardLine> >;
+
+ (*mLineMap)[ line.identifier() ].append( line );
+}
+
+VCardLine::List VCard::lines( const QString& identifier )
+{
+ if ( !mLineMap )
+ return VCardLine::List();
+ else
+ return (*mLineMap)[ identifier ];
+}
+
+VCardLine VCard::line( const QString& identifier )
+{
+ if ( !mLineMap )
+ return VCardLine();
+ else
+ return (*mLineMap)[ identifier ][ 0 ];
+}
+
+void VCard::setVersion( Version version )
+{
+ if ( !mLineMap )
+ mLineMap = new QMap<QString, QValueList<VCardLine> >;
+ else {
+//US mLineMap->erase( "VERSION" );
+ mLineMap->remove( "VERSION" );
+ }
+ VCardLine line;
+ line.setIdentifier( "VERSION" );
+ if ( version == v2_1 )
+ line.setIdentifier( "2.1" );
+ if ( version == v3_0 )
+ line.setIdentifier( "3.0" );
+
+ (*mLineMap)[ "VERSION" ].append( line );
+}
+
+VCard::Version VCard::version() const
+{
+ if ( !mLineMap )
+ return v3_0;
+
+ VCardLine line = (*mLineMap)[ "VERSION" ][ 0 ];
+ if ( line.value() == "2.1" )
+ return v2_1;
+ else
+ return v3_0;
+}
diff --git a/kabc/vcardparser/vcard.h b/kabc/vcardparser/vcard.h
new file mode 100644
index 0000000..ce672b5
--- a/dev/null
+++ b/kabc/vcardparser/vcard.h
@@ -0,0 +1,90 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef VCARD_H
+#define VCARD_H
+
+#include "vcardline.h"
+#include <qmap.h>
+#include <qstringlist.h>
+#include <qvaluelist.h>
+
+namespace KABC {
+
+class VCard
+{
+ public:
+ typedef QValueList<VCard> List;
+
+ enum Version { v2_1, v3_0 };
+
+ VCard();
+ VCard( const VCard& );
+
+ ~VCard();
+
+ VCard& operator=( const VCard& );
+
+ /**
+ * Removes all lines from the vCard.
+ */
+ void clear();
+
+ /**
+ * Returns a list of all identifiers that exists in the
+ * vCard.
+ */
+ QStringList identifiers() const;
+
+ /**
+ * Adds a VCardLine to the VCard
+ */
+ void addLine( const VCardLine& line );
+
+ /**
+ * Returns all lines of the vcard with a special identifier.
+ */
+ VCardLine::List lines( const QString& identifier );
+
+ /**
+ * Returns only the first line of the vcard with a special identifier.
+ */
+ VCardLine line( const QString& identifier );
+
+ /**
+ * Set the version of the vCard.
+ */
+ void setVersion( Version version );
+
+ /**
+ * Returns the version of this vCard.
+ */
+ Version version() const;
+
+ private:
+ QMap< QString, VCardLine::List > *mLineMap;
+
+ class VCardPrivate;
+ VCardPrivate *d;
+};
+
+}
+
+#endif
diff --git a/kabc/vcardparser/vcardline.cpp b/kabc/vcardparser/vcardline.cpp
new file mode 100644
index 0000000..84638f8
--- a/dev/null
+++ b/kabc/vcardparser/vcardline.cpp
@@ -0,0 +1,148 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "vcardline.h"
+
+using namespace KABC;
+
+VCardLine::VCardLine()
+ : mParamMap( 0 )
+{
+}
+
+VCardLine::VCardLine( const QString &identifier )
+ : mParamMap( 0 )
+{
+ mIdentifier = identifier;
+}
+
+VCardLine::VCardLine( const QString &identifier, const QVariant &value )
+ : mParamMap( 0 )
+{
+ mIdentifier = identifier;
+ mValue = value;
+}
+
+VCardLine::VCardLine( const VCardLine& line )
+ : mParamMap( 0 )
+{
+ if ( line.mParamMap ) {
+ if ( !mParamMap )
+ mParamMap = new QMap<QString, QStringList>;
+
+ *mParamMap = *(line.mParamMap);
+ } else {
+ delete mParamMap;
+ mParamMap = 0;
+ }
+
+ mValue = line.mValue;
+ mIdentifier = line.mIdentifier;
+}
+
+VCardLine::~VCardLine()
+{
+ delete mParamMap;
+ mParamMap = 0;
+}
+
+VCardLine& VCardLine::operator=( const VCardLine& line )
+{
+ if ( &line == this )
+ return *this;
+
+ if ( line.mParamMap ) {
+ if ( !mParamMap )
+ mParamMap = new QMap<QString, QStringList>;
+
+ *mParamMap = *(line.mParamMap);
+ } else {
+ delete mParamMap;
+ mParamMap = 0;
+ }
+
+ mValue = line.mValue;
+ mIdentifier = line.mIdentifier;
+
+ return *this;
+}
+
+void VCardLine::setIdentifier( const QString& identifier )
+{
+ mIdentifier = identifier;
+}
+
+QString VCardLine::identifier() const
+{
+ return mIdentifier;
+}
+void VCardLine::setValue( const QVariant& value )
+{
+ mValue = value;
+}
+
+QVariant VCardLine::value() const
+{
+ return mValue;
+}
+
+QStringList VCardLine::parameterList() const
+{
+ if ( !mParamMap )
+ return QStringList();
+ else {
+//US method QMap::keys() not available yet. SO collect the data manually
+//US return mParamMap->keys();
+
+ QStringList result;
+
+ QMap<QString, QStringList>::ConstIterator it;
+ for( it = mParamMap->begin(); it != mParamMap->end(); ++it ) {
+ result << it.key().latin1();
+ }
+ return result;
+ }
+}
+
+void VCardLine::addParameter( const QString& param, const QString& value )
+{
+ if ( !mParamMap )
+ mParamMap = new QMap<QString, QStringList>;
+
+ QStringList &list = (*mParamMap)[ param ];
+ if ( list.find( value ) == list.end() ) // not included yet
+ list.append( value );
+}
+
+QStringList VCardLine::parameters( const QString& param ) const
+{
+ if ( !mParamMap )
+ return QStringList();
+ else
+ return (*mParamMap)[ param ];
+}
+
+QString VCardLine::parameter( const QString& param ) const
+{
+ if ( !mParamMap )
+ return QString::null;
+ else
+ return (*mParamMap)[ param ][ 0 ];
+}
diff --git a/kabc/vcardparser/vcardline.h b/kabc/vcardparser/vcardline.h
new file mode 100644
index 0000000..78b61f8
--- a/dev/null
+++ b/kabc/vcardparser/vcardline.h
@@ -0,0 +1,99 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef VCARDLINE_H
+#define VCARDLINE_H
+
+#include <qstringlist.h>
+#include <qvaluelist.h>
+#include <qvariant.h>
+#include <qmap.h>
+#include <qstring.h>
+
+namespace KABC {
+
+class VCardLine
+{
+ public:
+ typedef QValueList<VCardLine> List;
+
+ VCardLine();
+ VCardLine( const QString &identifier );
+ VCardLine( const QString &identifier, const QVariant &value );
+ VCardLine( const VCardLine& );
+
+ ~VCardLine();
+
+ VCardLine& operator=( const VCardLine& );
+
+ /**
+ * Sets the identifier of this line e.g. UID, FN, CLASS
+ */
+ void setIdentifier( const QString& identifier );
+
+ /**
+ * Returns the identifier of this line.
+ */
+ QString identifier() const;
+
+ /**
+ * Sets the value of of this line.
+ */
+ void setValue( const QVariant& value );
+
+ /**
+ * Returns the value of this line.
+ */
+ QVariant value() const;
+
+ /**
+ * Returns all parameters.
+ */
+ QStringList parameterList() const;
+
+ /**
+ * Add a new parameter to the line.
+ */
+ void addParameter( const QString& param, const QString& value );
+
+ /**
+ * Returns the values of a special parameter.
+ * You can get a list of all parameters with @ref paramList().
+ */
+ QStringList parameters( const QString& param ) const;
+
+ /**
+ * Returns only the first value of a special parameter.
+ * You can get a list of all parameters with @ref paramList().
+ */
+ QString parameter( const QString& param ) const;
+
+ private:
+ QMap< QString, QStringList > *mParamMap;
+ QString mIdentifier;
+ QVariant mValue;
+
+ class VCardLinePrivate;
+ VCardLinePrivate *d;
+};
+
+}
+
+#endif
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp
new file mode 100644
index 0000000..9ea084d
--- a/dev/null
+++ b/kabc/vcardparser/vcardparser.cpp
@@ -0,0 +1,233 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <qregexp.h>
+
+#include <kmdcodec.h>
+
+#include "vcardparser.h"
+
+#define FOLD_WIDTH 75
+
+using namespace KABC;
+
+VCardParser::VCardParser()
+{
+}
+
+VCardParser::~VCardParser()
+{
+}
+
+VCard::List VCardParser::parseVCards( const QString& text )
+{
+ VCard currentVCard;
+ VCard::List vCardList;
+ QString currentLine;
+
+ QStringList lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), text );
+ QStringList::Iterator it;
+
+ bool inVCard = false;
+ for ( it = lines.begin(); it != lines.end(); ++it ) {
+
+ if ( (*it).isEmpty() ) // empty line
+ continue;
+
+ if ( (*it)[ 0 ] == ' ' || (*it)[ 0 ] == '\t' ) { // folded line => append to previous
+ currentLine += (*it).remove( 0, 1 );
+ continue;
+ } else {
+ if ( inVCard && !currentLine.isEmpty() ) { // now parse the line
+ int colon = currentLine.find( ':' );
+ if ( colon == -1 ) { // invalid line
+ currentLine = (*it);
+ continue;
+ }
+
+ VCardLine vCardLine;
+ QString key = currentLine.left( colon ).stripWhiteSpace();
+ QString value = currentLine.mid( colon + 1 );
+
+ QStringList params = QStringList::split( ';', key );
+ vCardLine.setIdentifier( params[0] );
+ if ( params.count() > 1 ) { // find all parameters
+ for ( uint i = 1; i < params.count(); ++i ) {
+ QStringList pair = QStringList::split( '=', params[i] );
+//US if ( pair.size() == 1 ) {
+ if ( pair.count() == 1 ) {
+ pair.prepend( "type" );
+ }
+ if ( pair[1].contains( ',' ) ) { // parameter in type=x,y,z format
+ QStringList args = QStringList::split( ',', pair[ 1 ] );
+ for ( uint j = 0; j < args.count(); ++j )
+ vCardLine.addParameter( pair[0].lower(), args[j] );
+ } else
+ vCardLine.addParameter( pair[0].lower(), pair[1] );
+ }
+ }
+
+ params = vCardLine.parameterList();
+ if ( params.contains( "encoding" ) ) { // have to decode the data
+#if 0
+ QByteArray input, output;
+ input = value.local8Bit();
+ if ( vCardLine.parameter( "encoding" ).lower() == "b" )
+ KCodecs::base64Decode( input, output );
+ else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" )
+ KCodecs::quotedPrintableDecode( input, output );
+
+ //qDebug("VCardParser::parseVCards has to be verified");
+ //US I am not sure if this is correct
+ //US vCardLine.setValue( output );
+ QCString cs(output);
+ qDebug("len1 %d len2 %d ",input.size(), output.size( ));
+#endif
+ QCString cs = value.local8Bit();
+ qDebug("****************************************** ");
+ qDebug("************* WARNING ******************** ");
+ qDebug("****************************************** ");
+ qDebug("Make sure, the decoding is done after");
+ qDebug("QVariant conversion!");
+ qDebug("Insert Line DECODING OKAY, where this is implemented");
+ // use for decoding the above code!
+ vCardLine.setValue( cs );
+ } else {
+
+ //qDebug("VCardParser::parseVCards has to be verified");
+//US vCardLine.setValue( value.replace( "\\n", "\n" ) );
+ vCardLine.setValue( value.replace( QRegExp("\\n"), "\n" ) );
+ }
+
+ currentVCard.addLine( vCardLine );
+ }
+ // we do not save the start and end tag as vcardline
+ if ( (*it).lower().startsWith( "begin:vcard" ) ) {
+ inVCard = true;
+ //qDebug("VCardParser::parseVCards has to be verified");
+//US currentLine.setLength( 0 );
+ currentLine = "";
+ currentVCard.clear(); // flush vcard
+ continue;
+ }
+
+ if ( (*it).lower().startsWith( "end:vcard" ) ) {
+ inVCard = false;
+ vCardList.append( currentVCard );
+ //qDebug("VCardParser::parseVCards has to be verified");
+//US currentLine.setLength( 0 );
+ currentLine = "";
+ currentVCard.clear(); // flush vcard
+ continue;
+ }
+
+ currentLine = (*it);
+ }
+ }
+
+ return vCardList;
+}
+
+QString VCardParser::createVCards( const VCard::List& list )
+{
+ QString text;
+ QString textLine;
+ QString encodingType;
+ QStringList idents;
+ QStringList params;
+ QStringList values;
+ QStringList::ConstIterator identIt;
+ QStringList::Iterator paramIt;
+ QStringList::Iterator valueIt;
+
+ VCardLine::List lines;
+ VCardLine::List::Iterator lineIt;
+ VCard::List::ConstIterator cardIt;
+
+ bool hasEncoding;
+
+
+ // iterate over the cards
+ for ( cardIt = list.begin(); cardIt != list.end(); ++cardIt ) {
+ text.append( "BEGIN:VCARD\r\n" );
+
+ idents = (*cardIt).identifiers();
+ for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) {
+ VCard card = (*cardIt);
+ lines = card.lines( (*identIt) );
+
+ // iterate over the lines
+ for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
+ if ( !(*lineIt).value().asString().isEmpty() ) {
+ textLine = (*lineIt).identifier();
+
+ params = (*lineIt).parameterList();
+ hasEncoding = false;
+ if ( params.count() > 0 ) { // we have parameters
+ for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) {
+ if ( (*paramIt) == "encoding" ) {
+ hasEncoding = true;
+ encodingType = (*lineIt).parameter( "encoding" ).lower();
+ }
+
+ values = (*lineIt).parameters( *paramIt );
+ for ( valueIt = values.begin(); valueIt != values.end(); ++valueIt ) {
+ textLine.append( ";" + (*paramIt).upper() );
+ if ( !(*valueIt).isEmpty() )
+ textLine.append( "=" + (*valueIt) );
+ }
+ }
+ }
+
+ if ( hasEncoding ) { // have to encode the data
+ QByteArray input, output;
+
+ qDebug("VCardParser::createVCards has to be verified");
+//US input = (*lineIt).value().toByteArray();
+
+//US I am not sure if this is correct
+ QCString cs ((*lineIt).value().toCString());
+ input = cs;
+
+ if ( encodingType == "b" )
+ KCodecs::base64Encode( input, output );
+ else if ( encodingType == "quoted-printable" )
+ KCodecs::quotedPrintableEncode( input, output );
+ textLine.append( ":" + QString( output ) );
+ } else {
+ qDebug("VCardParser::createVCards has to be verified");
+//US textLine.append( ":" + (*lineIt).value().asString().replace( "\n", "\\n" ) );
+ textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) );
+ }
+ if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line
+ for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i )
+ text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" );
+ } else
+ text.append( textLine + "\r\n" );
+ }
+ }
+ }
+
+ text.append( "END:VCARD\r\n" );
+ text.append( "\r\n" );
+ }
+
+ return text;
+}
diff --git a/kabc/vcardparser/vcardparser.h b/kabc/vcardparser/vcardparser.h
new file mode 100644
index 0000000..ae185ef
--- a/dev/null
+++ b/kabc/vcardparser/vcardparser.h
@@ -0,0 +1,40 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef VCARDPARSER_H
+#define VCARDPARSER_H
+
+#include "vcard.h"
+
+namespace KABC {
+
+class VCardParser
+{
+ public:
+ VCardParser();
+ ~VCardParser();
+
+ static VCard::List parseVCards( const QString& text );
+ static QString createVCards( const VCard::List& list );
+};
+
+}
+
+#endif
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
new file mode 100644
index 0000000..01c5b3e
--- a/dev/null
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -0,0 +1,883 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <qdatastream.h>
+#include <qstring.h>
+#include <qregexp.h>
+#include <kmdcodec.h>
+
+#include "agent.h"
+#include "key.h"
+#include "picture.h"
+#include "secrecy.h"
+#include "sound.h"
+
+#include "vcardtool.h"
+
+using namespace KABC;
+
+VCardTool::VCardTool()
+{
+ mAddressTypeMap.insert( "dom", Address::Dom );
+ mAddressTypeMap.insert( "intl", Address::Intl );
+ mAddressTypeMap.insert( "postal", Address::Postal );
+ mAddressTypeMap.insert( "parcel", Address::Parcel );
+ mAddressTypeMap.insert( "home", Address::Home );
+ mAddressTypeMap.insert( "work", Address::Work );
+ mAddressTypeMap.insert( "pref", Address::Pref );
+
+ mPhoneTypeMap.insert( "HOME", PhoneNumber::Home );
+ mPhoneTypeMap.insert( "WORK", PhoneNumber::Work );
+ mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg );
+ mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref );
+ mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice );
+ mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax );
+ mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell );
+ mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video );
+ mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs );
+ mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem );
+ mPhoneTypeMap.insert( "CAR", PhoneNumber::Car );
+ mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn );
+ mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs );
+ mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager );
+}
+
+VCardTool::~VCardTool()
+{
+}
+
+QString VCardTool::createVCards( Addressee::List list, VCard::Version version )
+{
+ VCard::List vCardList;
+
+ Addressee::List::Iterator addrIt;
+ for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) {
+ VCard card;
+ QStringList::ConstIterator strIt;
+
+ // ADR + LABEL
+ Address::List addresses = (*addrIt).addresses();
+ for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) {
+ QStringList address;
+
+/*US
+ address.append( (*it).postOfficeBox().replace( ';', "\\;" ) );
+ address.append( (*it).extended().replace( ';', "\\;" ) );
+ address.append( (*it).street().replace( ';', "\\;" ) );
+ address.append( (*it).locality().replace( ';', "\\;" ) );
+ address.append( (*it).region().replace( ';', "\\;" ) );
+ address.append( (*it).postalCode().replace( ';', "\\;" ) );
+ address.append( (*it).country().replace( ';', "\\;" ) );
+*/
+//US using the old implementation instead
+ //qDebug("VCardTool::createVCards has to be verified");
+ address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) );
+ address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) );
+ address.append( (*it).street().replace( QRegExp(";"), "\\;" ) );
+ address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) );
+ address.append( (*it).region().replace( QRegExp(";"), "\\;" ) );
+ address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) );
+ address.append( (*it).country().replace( QRegExp(";"), "\\;" ) );
+
+ VCardLine adrLine( "ADR", address.join( ";" ) );
+ VCardLine labelLine( "LABEL", (*it).label() );
+
+ bool hasLabel = !(*it).label().isEmpty();
+ QMap<QString, int>::Iterator typeIt;
+ for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) {
+ if ( typeIt.data() & (*it).type() ) {
+ adrLine.addParameter( "TYPE", typeIt.key() );
+ if ( hasLabel )
+ labelLine.addParameter( "TYPE", typeIt.key() );
+ }
+ }
+
+ card.addLine( adrLine );
+ if ( hasLabel )
+ card.addLine( labelLine );
+ }
+
+ // AGENT
+ card.addLine( createAgent( version, (*addrIt).agent() ) );
+
+ // BDAY
+ card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) );
+
+ // CATEGORIES
+ if ( version == VCard::v3_0 ) {
+ QStringList categories = (*addrIt).categories();
+ QStringList::Iterator catIt;
+ for ( catIt = categories.begin(); catIt != categories.end(); ++catIt )
+ {
+//US using the old implementation instead
+ // qDebug("VCardTool::createVCards has to be verified");
+//US (*catIt).replace( ',', "\\," );
+ (*catIt).replace( QRegExp(","), "\\," );
+ }
+ card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) );
+ }
+
+ // CLASS
+ if ( version == VCard::v3_0 ) {
+ card.addLine( createSecrecy( (*addrIt).secrecy() ) );
+ }
+
+ // EMAIL
+ QStringList emails = (*addrIt).emails();
+ bool pref = true;
+ for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) {
+ VCardLine line( "EMAIL", *strIt );
+ if ( pref == true ) {
+ line.addParameter( "TYPE", "PREF" );
+ pref = false;
+ }
+ card.addLine( line );
+ }
+
+ // FN
+ card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) );
+
+ // GEO
+ Geo geo = (*addrIt).geo();
+ if ( geo.isValid() ) {
+ QString str;
+ str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() );
+ card.addLine( VCardLine( "GEO", str ) );
+ }
+
+ // KEY
+ Key::List keys = (*addrIt).keys();
+ Key::List::ConstIterator keyIt;
+ for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt )
+ card.addLine( createKey( *keyIt ) );
+
+ // LOGO
+ card.addLine( createPicture( "LOGO", (*addrIt).logo() ) );
+
+ // MAILER
+ card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) );
+
+ // N
+ QStringList name;
+//US using the old implementation instead
+ //qDebug("VCardTool::createVCards has to be verified");
+/*US
+ name.append( (*addrIt).familyName().replace( ';', "\\;" ) );
+ name.append( (*addrIt).givenName().replace( ';', "\\;" ) );
+ name.append( (*addrIt).additionalName().replace( ';', "\\;" ) );
+ name.append( (*addrIt).prefix().replace( ';', "\\;" ) );
+ name.append( (*addrIt).suffix().replace( ';', "\\;" ) );
+*/
+ name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) );
+ name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) );
+ name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) );
+ name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) );
+ name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) );
+
+ if ( !name.join( "" ).isEmpty() )
+ card.addLine( VCardLine( "N", name.join( ";" ) ) );
+
+ // NICKNAME
+ if ( version == VCard::v3_0 )
+ card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) );
+
+ // NOTE
+ card.addLine( VCardLine( "NOTE", (*addrIt).note() ) );
+
+ // ORG
+ card.addLine( VCardLine( "ORG", (*addrIt).organization() ) );
+
+ // PHOTO
+ card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) );
+
+ // PROID
+ if ( version == VCard::v3_0 )
+ card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) );
+
+ // REV
+ card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) );
+
+ // ROLE
+ card.addLine( VCardLine( "ROLE", (*addrIt).role() ) );
+
+ // SORT-STRING
+ if ( version == VCard::v3_0 )
+ card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) );
+
+ // SOUND
+ card.addLine( createSound( (*addrIt).sound() ) );
+
+ // TEL
+ PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers();
+ PhoneNumber::List::ConstIterator phoneIt;
+ for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
+ VCardLine line( "TEL", (*phoneIt).number() );
+
+ QMap<QString, int>::Iterator typeIt;
+ for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) {
+ if ( typeIt.data() & (*phoneIt).type() )
+ line.addParameter( "TYPE", typeIt.key() );
+ }
+
+ card.addLine( line );
+ }
+
+ // TITLE
+ card.addLine( VCardLine( "TITLE", (*addrIt).title() ) );
+
+ // TZ
+ TimeZone timeZone = (*addrIt).timeZone();
+ if ( timeZone.isValid() ) {
+ QString str;
+
+ int neg = 1;
+ if ( timeZone.offset() < 0 )
+ neg = -1;
+
+ str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ),
+ ( timeZone.offset() / 60 ) * neg,
+ ( timeZone.offset() % 60 ) * neg );
+
+ card.addLine( VCardLine( "TZ", str ) );
+ }
+
+ // UID
+ card.addLine( VCardLine( "UID", (*addrIt).uid() ) );
+
+ // URL
+ card.addLine( VCardLine( "URL", (*addrIt).url().url() ) );
+
+ // VERSION
+ if ( version == VCard::v2_1 )
+ card.addLine( VCardLine( "VERSION", "2.1" ) );
+ if ( version == VCard::v3_0 )
+ card.addLine( VCardLine( "VERSION", "3.0" ) );
+
+ // X-
+ QStringList customs = (*addrIt).customs();
+ for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) {
+ QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) );
+ QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 );
+ if ( value.isEmpty() )
+ continue;
+
+ card.addLine( VCardLine( identifier, value ) );
+ }
+
+ vCardList.append( card );
+ }
+
+ return VCardParser::createVCards( vCardList );
+}
+
+Addressee::List VCardTool::parseVCards( const QString& vcard )
+{
+ QChar semicolonSep( ';' );
+ QChar commaSep( ',' );
+ QString identifier;
+
+ Addressee::List addrList;
+ VCard::List vCardList = VCardParser::parseVCards( vcard );
+ VCard::List::Iterator cardIt;
+ for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) {
+ Addressee addr;
+ QStringList idents = (*cardIt).identifiers();
+ QStringList::ConstIterator identIt;
+ for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) {
+ VCard card = (*cardIt);
+ VCardLine::List lines = card.lines( (*identIt) );
+ VCardLine::List::Iterator lineIt;
+
+ // iterate over the lines
+ for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
+ QStringList params = (*lineIt).parameterList();
+
+ identifier = (*lineIt).identifier().lower();
+ // ADR
+ if ( identifier == "adr" ) {
+ Address address;
+ QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() );
+ if ( addrParts.count() > 0 )
+ address.setPostOfficeBox( addrParts[ 0 ] );
+ if ( addrParts.count() > 1 )
+ address.setExtended( addrParts[ 1 ] );
+ if ( addrParts.count() > 2 )
+ address.setStreet( addrParts[ 2 ].replace ( QRegExp("\\\\n") , "\n") );
+ if ( addrParts.count() > 3 )
+ address.setLocality( addrParts[ 3 ] );
+ if ( addrParts.count() > 4 )
+ address.setRegion( addrParts[ 4 ] );
+ if ( addrParts.count() > 5 )
+ address.setPostalCode( addrParts[ 5 ] );
+ if ( addrParts.count() > 6 )
+ address.setCountry( addrParts[ 6 ] );
+
+ int type = 0;
+
+ QStringList types = (*lineIt).parameters( "type" );
+ for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it )
+ type += mAddressTypeMap[ (*it).lower() ];
+
+ if ( !type )
+ type = Address::Home; // default
+
+ address.setType( type );
+ addr.insertAddress( address );
+ }
+
+ // AGENT
+ if ( identifier == "agent" )
+ addr.setAgent( parseAgent( *lineIt ) );
+
+ // BDAY
+ if ( identifier == "bday" )
+ addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) );
+
+ // CATEGORIES
+ if ( identifier == "categories" ) {
+ QStringList categories = splitString( commaSep, (*lineIt).value().asString() );
+ addr.setCategories( categories );
+ }
+
+ // CLASS
+ if ( identifier == "class" )
+ addr.setSecrecy( parseSecrecy( *lineIt ) );
+
+ // EMAIL
+ if ( identifier == "email" ) {
+ QStringList types = (*lineIt).parameters( "type" );
+ addr.insertEmail( (*lineIt).value().asString(), types.contains( "PREF" ) );
+ }
+
+ // FN
+ if ( identifier == "fn" )
+ addr.setFormattedName( (*lineIt).value().asString() );
+
+ // GEO
+ if ( identifier == "geo" ) {
+ Geo geo;
+
+ QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true );
+ geo.setLatitude( geoParts[ 0 ].toFloat() );
+ geo.setLongitude( geoParts[ 1 ].toFloat() );
+
+ addr.setGeo( geo );
+ }
+
+ // KEY
+ if ( identifier == "key" )
+ addr.insertKey( parseKey( *lineIt ) );
+
+ // LABEL
+ if ( identifier == "label" ) {
+ int type = 0;
+
+ QStringList types = (*lineIt).parameters( "type" );
+ for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it )
+ type += mAddressTypeMap[ (*it).lower() ];
+
+ if ( !type )
+ type = Address::Home;
+
+ KABC::Address::List addressList = addr.addresses();
+ KABC::Address::List::Iterator it;
+ for ( it = addressList.begin(); it != addressList.end(); ++it ) {
+ if ( (*it).type() == type ) {
+ (*it).setLabel( (*lineIt).value().asString() );
+ addr.insertAddress( *it );
+ }
+ }
+ }
+
+ // LOGO
+ if ( identifier == "logo" )
+ addr.setLogo( parsePicture( *lineIt ) );
+
+ // MAILER
+ if ( identifier == "mailer" )
+ addr.setMailer( (*lineIt).value().asString() );
+
+ // N
+ if ( identifier == "n" ) {
+ QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() );
+ if ( nameParts.count() > 0 )
+ addr.setFamilyName( nameParts[ 0 ] );
+ if ( nameParts.count() > 1 )
+ addr.setGivenName( nameParts[ 1 ] );
+ if ( nameParts.count() > 2 )
+ addr.setAdditionalName( nameParts[ 2 ] );
+ if ( nameParts.count() > 3 )
+ addr.setPrefix( nameParts[ 3 ] );
+ if ( nameParts.count() > 4 )
+ addr.setSuffix( nameParts[ 4 ] );
+ }
+
+ // NICKNAME
+ if ( identifier == "nickname" )
+ addr.setNickName( (*lineIt).value().asString() );
+
+ // NOTE
+ if ( identifier == "note" ) {
+// #ifdef DESKTOP_VERSION
+// addr.setNote( (*lineIt).value().asString() );
+// #else
+ QString note = (*lineIt).value().asString();
+ if ( ! note.isEmpty() )
+ addr.setNote( note.replace ( QRegExp("\\\\n") , "\n") );
+ else
+ addr.setNote( note );
+ //#endif
+ }
+
+ // ORGANIZATION
+ if ( identifier == "org" )
+ addr.setOrganization( (*lineIt).value().asString() );
+
+ // PHOTO
+ if ( identifier == "photo" )
+ addr.setPhoto( parsePicture( *lineIt ) );
+
+ // PROID
+ if ( identifier == "prodid" )
+ addr.setProductId( (*lineIt).value().asString() );
+
+ // REV
+ if ( identifier == "rev" )
+ addr.setRevision( parseDateTime( (*lineIt).value().asString() ) );
+
+ // ROLE
+ if ( identifier == "role" )
+ addr.setRole( (*lineIt).value().asString() );
+
+ // SORT-STRING
+ if ( identifier == "sort-string" )
+ addr.setSortString( (*lineIt).value().asString() );
+
+ // SOUND
+ if ( identifier == "sound" )
+ addr.setSound( parseSound( *lineIt ) );
+
+ // TEL
+ if ( identifier == "tel" ) {
+ PhoneNumber phone;
+ phone.setNumber( (*lineIt).value().asString() );
+
+ int type = 0;
+
+ QStringList types = (*lineIt).parameters( "type" );
+ for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it )
+ type += mPhoneTypeMap[(*it).upper()];
+
+ if ( !type )
+ type = PhoneNumber::Home; // default
+
+ phone.setType( type );
+
+ addr.insertPhoneNumber( phone );
+ }
+
+ // TITLE
+ if ( identifier == "title" )
+ addr.setTitle( (*lineIt).value().asString() );
+
+ // TZ
+ if ( identifier == "tz" ) {
+ TimeZone tz;
+ QString date = (*lineIt).value().asString();
+
+ int hours = date.mid( 1, 2).toInt();
+ int minutes = date.mid( 4, 2 ).toInt();
+ int offset = ( hours * 60 ) + minutes;
+ offset = offset * ( date[ 0 ] == '+' ? 1 : -1 );
+
+ tz.setOffset( offset );
+ addr.setTimeZone( tz );
+ }
+
+ // UID
+ if ( identifier == "uid" )
+ addr.setUid( (*lineIt).value().asString() );
+
+ // URL
+ if ( identifier == "url" )
+ addr.setUrl( (*lineIt).value().asString() );
+
+ // X-
+ if ( identifier.startsWith( "x-" ) ) {
+ QString key = (*lineIt).identifier().mid( 2 );
+ int dash = key.find( "-" );
+ addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).value().asString() );
+ }
+ }
+ }
+
+ addrList.append( addr );
+ }
+
+ return addrList;
+}
+
+QDateTime VCardTool::parseDateTime( const QString &str )
+{
+ QDateTime dateTime;
+
+ if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd)
+ dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(),
+ str.mid( 6, 2 ).toInt() ) );
+
+ if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss
+ dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(),
+ str.mid( 17, 2 ).toInt() ) );
+
+ } else { // is extended format yyyy-mm-dd
+ dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(),
+ str.mid( 8, 2 ).toInt() ) );
+
+ if ( str.find( 'T' ) ) // has time information yyyy-mm-ddThh:mm:ss
+ dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(),
+ str.mid( 17, 2 ).toInt() ) );
+ }
+
+ return dateTime;
+}
+
+QString VCardTool::createDateTime( const QDateTime &dateTime )
+{
+ QString str;
+
+ if ( dateTime.date().isValid() ) {
+ str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(),
+ dateTime.date().day() );
+ if ( dateTime.time().isValid() ) {
+ QString tmp;
+ tmp.sprintf( "T%02d:%02d:%02dZ", dateTime.time().hour(), dateTime.time().minute(),
+ dateTime.time().second() );
+ str += tmp;
+ }
+ }
+
+ return str;
+}
+
+Picture VCardTool::parsePicture( const VCardLine &line )
+{
+ Picture pic;
+
+ QStringList params = line.parameterList();
+ if ( params.contains( "encoding" ) ) {
+ QCString cs(line.value().asCString());
+ QByteArray input, output;
+ input = line.value().asCString();
+ if ( line.parameter( "encoding" ).lower() == "b" )
+ KCodecs::base64Decode( input, output );
+ else if ( line.parameter( "encoding" ).lower() == "quoted-printable" )
+ KCodecs::quotedPrintableDecode( input, output );
+
+ qDebug("********** DECODING OKAY ************** (picture)");
+ pic.setData( QImage(output) );
+
+ }
+ else if ( params.contains( "value" ) ) {
+ if ( line.parameter( "value" ).lower() == "uri" )
+ pic.setUrl( line.value().asString() );
+ }
+
+ if ( params.contains( "type" ) )
+ pic.setType( line.parameter( "type" ) );
+
+ return pic;
+}
+
+VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic )
+{
+ // LR fixed
+ VCardLine line( identifier );
+
+ if ( pic.isIntern() ) {
+ if ( !pic.data().isNull() ) {
+#if 0
+ QByteArray input;
+ QDataStream s( input, IO_WriteOnly );
+ s.setVersion( 4 );
+ s << pic.data();
+ line.setValue( input );
+#else
+ QCString input;
+ QDataStream s( input, IO_WriteOnly );
+ s.setVersion( 4 );
+ s << pic.data();
+ //QCString cs(line.value().asCString());
+ //QImage qi(cs);
+ line.setValue( input );
+#endif
+
+ line.addParameter( "encoding", "b" );
+ line.addParameter( "type", "image/png" );
+ }
+ } else if ( !pic.url().isEmpty() ) {
+ line.setValue( pic.url() );
+ line.addParameter( "value", "URI" );
+ }
+
+ return line;
+}
+
+Sound VCardTool::parseSound( const VCardLine &line )
+{
+ Sound snd;
+
+ QStringList params = line.parameterList();
+ if ( params.contains( "encoding" ) ) {
+ qDebug("VCardTool::parseSound has to be verified");
+//US snd.setData( line.value().asByteArray() );
+//US I am not sure if this is correct
+ QCString cs(line.value().asCString());
+ snd.setData( cs );
+ }
+ else if ( params.contains( "value" ) ) {
+ if ( line.parameter( "value" ).lower() == "uri" )
+ snd.setUrl( line.value().asString() );
+ }
+
+/* TODO: support sound types
+ if ( params.contains( "type" ) )
+ snd.setType( line.parameter( "type" ) );
+*/
+
+ return snd;
+}
+
+VCardLine VCardTool::createSound( const Sound &snd )
+{
+ VCardLine line( "SOUND" );
+
+ if ( snd.isIntern() ) {
+ if ( !snd.data().isEmpty() ) {
+ qDebug("VCardTool::createSound has to be verified");
+//US line.setValue( snd.data() );
+
+//US I am not sure if this is correct
+ QCString cs(snd.data());
+ line.setValue( cs );
+
+
+ line.addParameter( "encoding", "b" );
+ // TODO: need to store sound type!!!
+ }
+ } else if ( !snd.url().isEmpty() ) {
+ line.setValue( snd.url() );
+ line.addParameter( "value", "URI" );
+ }
+
+ return line;
+}
+
+Key VCardTool::parseKey( const VCardLine &line )
+{
+ Key key;
+
+ QStringList params = line.parameterList();
+ if ( params.contains( "encoding" ) ) {
+ qDebug("VCardTool::parseKey has to be verified");
+//US key.setBinaryData( line.value().asByteArray() );
+
+//US I am not sure if this is correct
+ QCString cs( line.value().asCString() );
+ key.setBinaryData( cs );
+ }
+ else
+ key.setTextData( line.value().asString() );
+
+ if ( params.contains( "type" ) ) {
+ if ( line.parameter( "type" ).lower() == "x509" )
+ key.setType( Key::X509 );
+ else if ( line.parameter( "type" ).lower() == "pgp" )
+ key.setType( Key::PGP );
+ else {
+ key.setType( Key::Custom );
+ key.setCustomTypeString( line.parameter( "type" ) );
+ }
+ }
+
+ return key;
+}
+
+VCardLine VCardTool::createKey( const Key &key )
+{
+ VCardLine line( "KEY" );
+
+ if ( key.isBinary() ) {
+ if ( !key.binaryData().isEmpty() ) {
+ qDebug("VCardTool::createKey has to be verified");
+//US line.setValue( key.binaryData() );
+//US I am not sure if this is correct
+ QCString cs(key.binaryData());
+ line.setValue( cs );
+
+
+ line.addParameter( "encoding", "b" );
+ }
+ } else if ( !key.textData().isEmpty() )
+ line.setValue( key.textData() );
+
+ if ( key.type() == Key::X509 )
+ line.addParameter( "type", "X509" );
+ else if ( key.type() == Key::PGP )
+ line.addParameter( "type", "PGP" );
+ else if ( key.type() == Key::Custom )
+ line.addParameter( "type", key.customTypeString() );
+
+ return line;
+}
+
+Secrecy VCardTool::parseSecrecy( const VCardLine &line )
+{
+ Secrecy secrecy;
+
+ if ( line.value().asString().lower() == "public" )
+ secrecy.setType( Secrecy::Public );
+ if ( line.value().asString().lower() == "private" )
+ secrecy.setType( Secrecy::Private );
+ if ( line.value().asString().lower() == "confidential" )
+ secrecy.setType( Secrecy::Confidential );
+
+ return secrecy;
+}
+
+VCardLine VCardTool::createSecrecy( const Secrecy &secrecy )
+{
+ VCardLine line( "CLASS" );
+
+ int type = secrecy.type();
+
+ if ( type == Secrecy::Public )
+ line.setValue( "PUBLIC" );
+ else if ( type == Secrecy::Private )
+ line.setValue( "PRIVATE" );
+ else if ( type == Secrecy::Confidential )
+ line.setValue( "CONFIDENTIAL" );
+
+ return line;
+}
+
+Agent VCardTool::parseAgent( const VCardLine &line )
+{
+ Agent agent;
+
+ QStringList params = line.parameterList();
+ if ( params.contains( "value" ) ) {
+ if ( line.parameter( "value" ).lower() == "uri" )
+ agent.setUrl( line.value().asString() );
+ } else {
+ QString str = line.value().asString();
+
+//US using the old implementation instead
+ qDebug("VCardTool::parseAgent has to be verified");
+/*US
+ str.replace( "\\n", "\r\n" );
+ str.replace( "\\N", "\r\n" );
+ str.replace( "\\;", ";" );
+ str.replace( "\\:", ":" );
+ str.replace( "\\,", "," );
+*/
+ str.replace( QRegExp("\\n") , "\r\n" );
+ str.replace( QRegExp("\\N") , "\r\n" );
+ str.replace( QRegExp("\\;") , ";" );
+ str.replace( QRegExp("\\:") , ":" );
+ str.replace( QRegExp("\\,") , "," );
+
+ Addressee::List list = parseVCards( str );
+ if ( list.count() > 0 ) {
+ Addressee *addr = new Addressee;
+ *addr = list[ 0 ];
+ agent.setAddressee( addr );
+ }
+ }
+
+ return agent;
+}
+
+VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent )
+{
+ VCardLine line( "AGENT" );
+
+ if ( agent.isIntern() ) {
+ if ( agent.addressee() != 0 ) {
+ Addressee::List list;
+ list.append( *agent.addressee() );
+
+ QString str = createVCards( list, version );
+
+//US using the old implementation instead
+ qDebug("VCardTool::createAgent has to be verified");
+/*US
+ str.replace( "\r\n", "\\n" );
+ str.replace( ";", "\\;" );
+ str.replace( ":", "\\:" );
+ str.replace( ",", "\\," );
+*/
+ str.replace( QRegExp("\r\n"), "\\n" );
+ str.replace( QRegExp(";"), "\\;" );
+ str.replace( QRegExp(":"), "\\:" );
+ str.replace( QRegExp(","), "\\," );
+ line.setValue( str );
+ }
+ } else if ( !agent.url().isEmpty() ) {
+ line.setValue( agent.url() );
+ line.addParameter( "value", "URI" );
+ }
+
+ return line;
+}
+
+QStringList VCardTool::splitString( const QChar &sep, const QString &str )
+{
+ QStringList list;
+ QString value( str );
+
+ int start = 0;
+ int pos = value.find( sep, start );
+
+ while ( pos != -1 ) {
+ if ( value[ pos - 1 ] != '\\' ) {
+ if ( pos > start && pos <= (int)value.length() )
+ list << value.mid( start, pos - start );
+ else
+ list << QString::null;
+
+ start = pos + 1;
+ pos = value.find( sep, start );
+ } else {
+ if ( pos != 0 ) {
+ value.replace( pos - 1, 2, sep );
+ pos = value.find( sep, pos );
+ } else
+ pos = value.find( sep, pos + 1 );
+ }
+ }
+
+ int l = value.length() - 1;
+ if ( value.mid( start, l - start + 1 ).length() > 0 )
+ list << value.mid( start, l - start + 1 );
+ else
+ list << QString::null;
+
+ return list;
+}
diff --git a/kabc/vcardparser/vcardtool.h b/kabc/vcardparser/vcardtool.h
new file mode 100644
index 0000000..40a3b82
--- a/dev/null
+++ b/kabc/vcardparser/vcardtool.h
@@ -0,0 +1,88 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef KABC_VCARDTOOL_H
+#define KABC_VCARDTOOL_H
+
+#include "addressee.h"
+#include "vcardparser.h"
+
+class QDateTime;
+
+namespace KABC {
+
+class Agent;
+class Key;
+class Picture;
+class Secrecy;
+class Sound;
+
+class VCardTool
+{
+ public:
+ VCardTool();
+ ~VCardTool();
+
+ /**
+ Creates a string that contains the addressees from the list in
+ the vCard format.
+ */
+ QString createVCards( Addressee::List list, VCard::Version version = VCard::v3_0 );
+
+ /**
+ Parses the string and returns a list of addressee objects.
+ */
+ Addressee::List parseVCards( const QString& vcard );
+
+ private:
+ /**
+ Split a string and replaces escaped separators on the fly with
+ unescaped ones.
+ */
+ QStringList splitString( const QChar &sep, const QString &value );
+
+ QDateTime parseDateTime( const QString &str );
+ QString createDateTime( const QDateTime &dateTime );
+
+ Picture parsePicture( const VCardLine &line );
+ VCardLine createPicture( const QString &identifier, const Picture &pic );
+
+ Sound parseSound( const VCardLine &line );
+ VCardLine createSound( const Sound &snd );
+
+ Key parseKey( const VCardLine &line );
+ VCardLine createKey( const Key &key );
+
+ Secrecy parseSecrecy( const VCardLine &line );
+ VCardLine createSecrecy( const Secrecy &secrecy );
+
+ Agent parseAgent( const VCardLine &line );
+ VCardLine createAgent( VCard::Version version, const Agent &agent );
+
+ QMap<QString, int> mAddressTypeMap;
+ QMap<QString, int> mPhoneTypeMap;
+
+ class VCardToolPrivate;
+ VCardToolPrivate *d;
+};
+
+}
+
+#endif