[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepimlibs] kabc: Do no auto-generate the code of the Addressee class
From: Tobias Koenig <tokoe () kde ! org>
Date: 2013-03-03 18:06:24
Message-ID: 20130303180624.84E75A604F () git ! kde ! org
[Download RAW message or body]
Git commit c75473ef870e054b48a38051769095146334bc2a by Tobias Koenig.
Committed on 03/03/2013 at 19:03.
Pushed by tokoe into branch 'master'.
Do no auto-generate the code of the Addressee class
We haven't changed the Addressee class for a long time,
so the overhead of using a script to generate it isn't
justified anymore.
M +3 -20 kabc/CMakeLists.txt
M +0 -1 kabc/Mainpage.dox
M +0 -2 kabc/Messages.sh
A +2032 -0 kabc/addressee.cpp [License: GENERATED FILE] *
A +992 -0 kabc/addressee.h [License: LGPL (v2+)]
A +632 -0 kabc/field.cpp [License: LGPL (v2+)]
D +0 -1136 kabc/scripts/addressee.src.cpp
D +0 -500 kabc/scripts/addressee.src.h
D +0 -32 kabc/scripts/createisomap.pl
D +0 -5 kabc/scripts/doxygen-preprocess-addressee.sh
D +0 -83 kabc/scripts/entrylist
D +0 -395 kabc/scripts/field.src.cpp
D +0 -224 kabc/scripts/makeaddressee
The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.
http://commits.kde.org/kdepimlibs/c75473ef870e054b48a38051769095146334bc2a
diff --git a/kabc/CMakeLists.txt b/kabc/CMakeLists.txt
index 5b82caa..b3907c6 100644
--- a/kabc/CMakeLists.txt
+++ b/kabc/CMakeLists.txt
@@ -30,33 +30,16 @@ if(NOT KDEPIM_NO_KRESOURCES)
add_subdirectory(plugins)
endif()
add_subdirectory(tests)
-file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts)
-
-add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/field.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/addressee.h
- ${CMAKE_CURRENT_BINARY_DIR}/addressee.cpp
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts
- COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/makeaddressee
- DEPENDS
- scripts/makeaddressee
- scripts/addressee.src.cpp
- scripts/addressee.src.h
- scripts/entrylist
- scripts/field.src.cpp
-)
########### next target ###############
set(kabc_LIB_SRCS
address.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/addressee.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/addressee.h
- ${CMAKE_CURRENT_BINARY_DIR}/field.cpp
+ addressee.cpp
contactgroup.cpp
contactgrouptool.cpp
errorhandler.cpp
+ field.cpp
geo.cpp
key.cpp
ldapdn.cpp
@@ -125,7 +108,7 @@ install(FILES countrytransl.map DESTINATION \
${DATA_INSTALL_DIR}/kabc) install(FILES
kabc_export.h
address.h
- ${CMAKE_CURRENT_BINARY_DIR}/addressee.h
+ addressee.h
addresseedialog.h
addresseelist.h
contactgroup.h
diff --git a/kabc/Mainpage.dox b/kabc/Mainpage.dox
index 6ee8d00..587f24e 100644
--- a/kabc/Mainpage.dox
+++ b/kabc/Mainpage.dox
@@ -31,5 +31,4 @@ KPilot etc. It is meant as replacement for libkab (in kdebase/kab).
<b>LICENCE: LGPL</b>
*/
// DOXYGEN_REFERENCES = kdecore kdeui kresources
-// DOXYGEN_EXCLUDE = scripts
// DOXYGEN_TOOLTIP = "An API for the KDE Addressbook."
diff --git a/kabc/Messages.sh b/kabc/Messages.sh
index b09261a..6e8db52 100644
--- a/kabc/Messages.sh
+++ b/kabc/Messages.sh
@@ -1,4 +1,2 @@
#! /usr/bin/env bash
-cd scripts && perl ./makeaddressee && cd ..
$XGETTEXT *.cpp -o $podir/kabc.pot
-rm -f addressee.cpp addressee.h field.cpp
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
new file mode 100644
index 0000000..8b79325
--- /dev/null
+++ b/kabc/addressee.cpp
@@ -0,0 +1,2032 @@
+/*** Warning! This file has been generated by the script makeaddressee ***/
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+ Copyright (c) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
+ Copyright (c) 2005 Ingo Kloecker <kloecker@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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <QtCore/QList>
+#include <QtCore/QRegExp>
+#include <QtCore/QSharedData>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <klocalizedstring.h>
+#include <krandom.h>
+
+#include "addresseehelper.h"
+#include "field.h"
+#ifndef KDEPIM_NO_KRESOURCES
+#include "resource.h"
+#endif
+#include "sortmode.h"
+
+#include "addressee.h"
+
+using namespace KABC;
+
+static bool matchBinaryPattern( int value, int pattern );
+
+template <class L>
+static bool listEquals( const QList<L>&, const QList<L>& );
+static bool listEquals( const QStringList&, const QStringList& );
+static bool emailsEquals( const QStringList&, const QStringList& );
+
+class Addressee::Private : public QSharedData
+{
+ public:
+ Private()
+ : mUid( KRandom::randomString( 10 ) ),
+#ifndef KDEPIM_NO_KRESOURCES
+ mResource( 0 ),
+#endif
+ mEmpty( true ), mChanged( false )
+ {
+ }
+
+ Private( const Private &other )
+ : QSharedData( other )
+#ifndef KDEPIM_NO_KRESOURCES
+ ,mResource( 0 )
+#endif
+ {
+ mUid = other.mUid;
+ mName = other.mName;
+ mFormattedName = other.mFormattedName;
+ mFamilyName = other.mFamilyName;
+ mGivenName = other.mGivenName;
+ mAdditionalName = other.mAdditionalName;
+ mPrefix = other.mPrefix;
+ mSuffix = other.mSuffix;
+ mNickName = other.mNickName;
+ mBirthday = other.mBirthday;
+ mMailer = other.mMailer;
+ mTimeZone = other.mTimeZone;
+ mGeo = other.mGeo;
+ mTitle = other.mTitle;
+ mRole = other.mRole;
+ mOrganization = other.mOrganization;
+ mDepartment = other.mDepartment;
+ mNote = other.mNote;
+ mProductId = other.mProductId;
+ mRevision = other.mRevision;
+ mSortString = other.mSortString;
+ mUrl = other.mUrl;
+ mSecrecy = other.mSecrecy;
+ mLogo = other.mLogo;
+ mPhoto = other.mPhoto;
+ mSound = other.mSound;
+
+ mPhoneNumbers = other.mPhoneNumbers;
+ mAddresses = other.mAddresses;
+ mKeys = other.mKeys;
+ mEmails = other.mEmails;
+ mCategories = other.mCategories;
+ mCustom = other.mCustom;
+
+#ifndef KDEPIM_NO_KRESOURCES
+ mResource = other.mResource;
+#endif
+ mEmpty = other.mEmpty;
+ mChanged = other.mChanged;
+ }
+
+ ~Private()
+ {
+ }
+
+ QString mUid;
+ QString mName;
+ QString mFormattedName;
+ QString mFamilyName;
+ QString mGivenName;
+ QString mAdditionalName;
+ QString mPrefix;
+ QString mSuffix;
+ QString mNickName;
+ QDateTime mBirthday;
+ QString mMailer;
+ TimeZone mTimeZone;
+ Geo mGeo;
+ QString mTitle;
+ QString mRole;
+ QString mOrganization;
+ QString mDepartment;
+ QString mNote;
+ QString mProductId;
+ QDateTime mRevision;
+ QString mSortString;
+ KUrl mUrl;
+ Secrecy mSecrecy;
+ Picture mLogo;
+ Picture mPhoto;
+ Sound mSound;
+
+ PhoneNumber::List mPhoneNumbers;
+ Address::List mAddresses;
+ Key::List mKeys;
+ QStringList mEmails;
+ QStringList mCategories;
+ QStringList mCustom;
+
+#ifndef KDEPIM_NO_KRESOURCES
+ Resource *mResource;
+#endif
+
+ bool mEmpty :1;
+ bool mChanged :1;
+
+ static KABC::SortMode *mSortMode;
+};
+
+KABC::SortMode *Addressee::Private::mSortMode = 0;
+
+Addressee::Addressee()
+ : d( new Private )
+{
+}
+
+Addressee::~Addressee()
+{
+}
+
+Addressee::Addressee( const Addressee &other )
+ : d( other.d )
+{
+}
+
+Addressee& Addressee::operator=( const Addressee &other )
+{
+ if ( this != &other )
+ d = other.d;
+
+ return *this;
+}
+
+bool Addressee::operator==( const Addressee &addressee ) const
+{
+ if ( d->mUid != addressee.d->mUid ) {
+ kDebug() << "uid differs";
+ return false;
+ }
+
+ if ( d->mName != addressee.d->mName &&
+ !( d->mName.isEmpty() && addressee.d->mName.isEmpty() ) ) {
+ kDebug(5700) << "name differs";
+ return false;
+ }
+
+ if ( d->mFormattedName != addressee.d->mFormattedName &&
+ !( d->mFormattedName.isEmpty() && addressee.d->mFormattedName.isEmpty() ) ) {
+ kDebug(5700) << "formattedName differs";
+ return false;
+ }
+
+ if ( d->mFamilyName != addressee.d->mFamilyName &&
+ !( d->mFamilyName.isEmpty() && addressee.d->mFamilyName.isEmpty() ) ) {
+ kDebug(5700) << "familyName differs";
+ return false;
+ }
+
+ if ( d->mGivenName != addressee.d->mGivenName &&
+ !( d->mGivenName.isEmpty() && addressee.d->mGivenName.isEmpty() ) ) {
+ kDebug(5700) << "givenName differs";
+ return false;
+ }
+
+ if ( d->mAdditionalName != addressee.d->mAdditionalName &&
+ !( d->mAdditionalName.isEmpty() && addressee.d->mAdditionalName.isEmpty() ) ) {
+ kDebug(5700) << "additionalName differs";
+ return false;
+ }
+
+ if ( d->mPrefix != addressee.d->mPrefix &&
+ !( d->mPrefix.isEmpty() && addressee.d->mPrefix.isEmpty() ) ) {
+ kDebug(5700) << "prefix differs";
+ return false;
+ }
+
+ if ( d->mSuffix != addressee.d->mSuffix &&
+ !( d->mSuffix.isEmpty() && addressee.d->mSuffix.isEmpty() ) ) {
+ kDebug(5700) << "suffix differs";
+ return false;
+ }
+
+ if ( d->mNickName != addressee.d->mNickName &&
+ !( d->mNickName.isEmpty() && addressee.d->mNickName.isEmpty() ) ) {
+ kDebug(5700) << "nickName differs";
+ return false;
+ }
+
+ if ( d->mBirthday != addressee.d->mBirthday ) {
+ kDebug(5700) << "birthday differs";
+ return false;
+ }
+
+ if ( d->mMailer != addressee.d->mMailer &&
+ !( d->mMailer.isEmpty() && addressee.d->mMailer.isEmpty() ) ) {
+ kDebug(5700) << "mailer differs";
+ return false;
+ }
+
+ if ( d->mTimeZone != addressee.d->mTimeZone ) {
+ kDebug(5700) << "timeZone differs";
+ return false;
+ }
+
+ if ( d->mGeo != addressee.d->mGeo ) {
+ kDebug(5700) << "geo differs";
+ return false;
+ }
+
+ if ( d->mTitle != addressee.d->mTitle &&
+ !( d->mTitle.isEmpty() && addressee.d->mTitle.isEmpty() ) ) {
+ kDebug(5700) << "title differs";
+ return false;
+ }
+
+ if ( d->mRole != addressee.d->mRole &&
+ !( d->mRole.isEmpty() && addressee.d->mRole.isEmpty() ) ) {
+ kDebug(5700) << "role differs";
+ return false;
+ }
+
+ if ( d->mOrganization != addressee.d->mOrganization &&
+ !( d->mOrganization.isEmpty() && addressee.d->mOrganization.isEmpty() ) ) {
+ kDebug(5700) << "organization differs";
+ return false;
+ }
+
+ if ( d->mDepartment != addressee.d->mDepartment &&
+ !( d->mDepartment.isEmpty() && addressee.d->mDepartment.isEmpty() ) ) {
+ kDebug(5700) << "department differs";
+ return false;
+ }
+
+ if ( d->mNote != addressee.d->mNote &&
+ !( d->mNote.isEmpty() && addressee.d->mNote.isEmpty() ) ) {
+ kDebug(5700) << "note differs";
+ return false;
+ }
+
+ if ( d->mProductId != addressee.d->mProductId &&
+ !( d->mProductId.isEmpty() && addressee.d->mProductId.isEmpty() ) ) {
+ kDebug(5700) << "productId differs";
+ return false;
+ }
+
+ if ( d->mSortString != addressee.d->mSortString &&
+ !( d->mSortString.isEmpty() && addressee.d->mSortString.isEmpty() ) ) {
+ kDebug(5700) << "sortString differs";
+ return false;
+ }
+
+ if ( d->mSecrecy != addressee.d->mSecrecy ) {
+ kDebug(5700) << "secrecy differs";
+ return false;
+ }
+
+ if ( d->mLogo != addressee.d->mLogo ) {
+ kDebug(5700) << "logo differs";
+ return false;
+ }
+
+ if ( d->mPhoto != addressee.d->mPhoto ) {
+ kDebug(5700) << "photo differs";
+ return false;
+ }
+
+ if ( d->mSound != addressee.d->mSound ) {
+ kDebug(5700) << "sound differs";
+ return false;
+ }
+
+ if ( ( d->mUrl.isValid() || addressee.d->mUrl.isValid() ) &&
+ ( d->mUrl != addressee.d->mUrl ) ) {
+ kDebug() << "url differs";
+ return false;
+ }
+
+ if ( !listEquals( d->mPhoneNumbers, addressee.d->mPhoneNumbers ) ) {
+ kDebug() << "phoneNumbers differs";
+ return false;
+ }
+
+ if ( !listEquals( d->mAddresses, addressee.d->mAddresses ) ) {
+ kDebug() << "addresses differs";
+ return false;
+ }
+
+ if ( !listEquals( d->mKeys, addressee.d->mKeys ) ) {
+ kDebug() << "keys differs";
+ return false;
+ }
+
+ if ( !emailsEquals( d->mEmails, addressee.d->mEmails ) ) {
+ kDebug() << "emails differs";
+ return false;
+ }
+
+ if ( !listEquals( d->mCategories, addressee.d->mCategories ) ) {
+ kDebug() << "categories differs";
+ return false;
+ }
+
+ if ( !listEquals( d->mCustom, addressee.d->mCustom ) ) {
+ kDebug() << "custom differs";
+ return false;
+ }
+
+ return true;
+}
+
+bool Addressee::operator!=( const Addressee &a ) const
+{
+ return !( a == *this );
+}
+
+bool Addressee::isEmpty() const
+{
+ return d->mEmpty;
+}
+
+void Addressee::setUid( const QString &id )
+{
+ if ( id == d->mUid )
+ return;
+
+ d->mEmpty = false;
+ d->mUid = id;
+}
+
+QString Addressee::uid() const
+{
+ return d->mUid;
+}
+
+QString Addressee::uidLabel()
+{
+ return i18n( "Unique Identifier" );
+}
+
+void Addressee::setName( const QString &name )
+{
+ if ( name == d->mName )
+ return;
+
+ d->mEmpty = false;
+ d->mName = name;
+}
+
+QString Addressee::name() const
+{
+ return d->mName;
+}
+
+QString Addressee::nameLabel()
+{
+ return i18n( "Name" );
+}
+
+
+void Addressee::setFormattedName( const QString &formattedName )
+{
+ if ( formattedName == d->mFormattedName )
+ return;
+
+ d->mEmpty = false;
+ d->mFormattedName = formattedName;
+}
+
+QString Addressee::formattedName() const
+{
+ return d->mFormattedName;
+}
+
+QString Addressee::formattedNameLabel()
+{
+ return i18n( "Formatted Name" );
+}
+
+
+void Addressee::setFamilyName( const QString &familyName )
+{
+ if ( familyName == d->mFamilyName )
+ return;
+
+ d->mEmpty = false;
+ d->mFamilyName = familyName;
+}
+
+QString Addressee::familyName() const
+{
+ return d->mFamilyName;
+}
+
+QString Addressee::familyNameLabel()
+{
+ return i18n( "Family Name" );
+}
+
+
+void Addressee::setGivenName( const QString &givenName )
+{
+ if ( givenName == d->mGivenName )
+ return;
+
+ d->mEmpty = false;
+ d->mGivenName = givenName;
+}
+
+QString Addressee::givenName() const
+{
+ return d->mGivenName;
+}
+
+QString Addressee::givenNameLabel()
+{
+ return i18n( "Given Name" );
+}
+
+
+void Addressee::setAdditionalName( const QString &additionalName )
+{
+ if ( additionalName == d->mAdditionalName )
+ return;
+
+ d->mEmpty = false;
+ d->mAdditionalName = additionalName;
+}
+
+QString Addressee::additionalName() const
+{
+ return d->mAdditionalName;
+}
+
+QString Addressee::additionalNameLabel()
+{
+ return i18n( "Additional Names" );
+}
+
+
+void Addressee::setPrefix( const QString &prefix )
+{
+ if ( prefix == d->mPrefix )
+ return;
+
+ d->mEmpty = false;
+ d->mPrefix = prefix;
+}
+
+QString Addressee::prefix() const
+{
+ return d->mPrefix;
+}
+
+QString Addressee::prefixLabel()
+{
+ return i18n( "Honorific Prefixes" );
+}
+
+
+void Addressee::setSuffix( const QString &suffix )
+{
+ if ( suffix == d->mSuffix )
+ return;
+
+ d->mEmpty = false;
+ d->mSuffix = suffix;
+}
+
+QString Addressee::suffix() const
+{
+ return d->mSuffix;
+}
+
+QString Addressee::suffixLabel()
+{
+ return i18n( "Honorific Suffixes" );
+}
+
+
+void Addressee::setNickName( const QString &nickName )
+{
+ if ( nickName == d->mNickName )
+ return;
+
+ d->mEmpty = false;
+ d->mNickName = nickName;
+}
+
+QString Addressee::nickName() const
+{
+ return d->mNickName;
+}
+
+QString Addressee::nickNameLabel()
+{
+ return i18n( "Nick Name" );
+}
+
+
+void Addressee::setBirthday( const QDateTime &birthday )
+{
+ if ( birthday == d->mBirthday )
+ return;
+
+ d->mEmpty = false;
+ d->mBirthday = birthday;
+}
+
+QDateTime Addressee::birthday() const
+{
+ return d->mBirthday;
+}
+
+QString Addressee::birthdayLabel()
+{
+ return i18n( "Birthday" );
+}
+
+
+QString Addressee::homeAddressStreetLabel()
+{
+ return i18n( "Home Address Street" );
+}
+
+
+QString Addressee::homeAddressPostOfficeBoxLabel()
+{
+ return i18n( "Home Address Post Office Box" );
+}
+
+
+QString Addressee::homeAddressLocalityLabel()
+{
+ return i18n( "Home Address City" );
+}
+
+
+QString Addressee::homeAddressRegionLabel()
+{
+ return i18n( "Home Address State" );
+}
+
+
+QString Addressee::homeAddressPostalCodeLabel()
+{
+ return i18n( "Home Address Zip 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::businessAddressPostOfficeBoxLabel()
+{
+ return i18n( "Business Address Post Office Box" );
+}
+
+
+QString Addressee::businessAddressLocalityLabel()
+{
+ return i18n( "Business Address City" );
+}
+
+
+QString Addressee::businessAddressRegionLabel()
+{
+ return i18n( "Business Address State" );
+}
+
+
+QString Addressee::businessAddressPostalCodeLabel()
+{
+ return i18n( "Business Address Zip 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 == d->mMailer )
+ return;
+
+ d->mEmpty = false;
+ d->mMailer = mailer;
+}
+
+QString Addressee::mailer() const
+{
+ return d->mMailer;
+}
+
+QString Addressee::mailerLabel()
+{
+ return i18n( "Mail Client" );
+}
+
+
+void Addressee::setTimeZone( const TimeZone &timeZone )
+{
+ if ( timeZone == d->mTimeZone )
+ return;
+
+ d->mEmpty = false;
+ d->mTimeZone = timeZone;
+}
+
+TimeZone Addressee::timeZone() const
+{
+ return d->mTimeZone;
+}
+
+QString Addressee::timeZoneLabel()
+{
+ return i18n( "Time Zone" );
+}
+
+
+void Addressee::setGeo( const Geo &geo )
+{
+ if ( geo == d->mGeo )
+ return;
+
+ d->mEmpty = false;
+ d->mGeo = geo;
+}
+
+Geo Addressee::geo() const
+{
+ return d->mGeo;
+}
+
+QString Addressee::geoLabel()
+{
+ return i18n( "Geographic Position" );
+}
+
+
+void Addressee::setTitle( const QString &title )
+{
+ if ( title == d->mTitle )
+ return;
+
+ d->mEmpty = false;
+ d->mTitle = title;
+}
+
+QString Addressee::title() const
+{
+ return d->mTitle;
+}
+
+QString Addressee::titleLabel()
+{
+ return i18nc( "a person's title", "Title" );
+}
+
+
+void Addressee::setRole( const QString &role )
+{
+ if ( role == d->mRole )
+ return;
+
+ d->mEmpty = false;
+ d->mRole = role;
+}
+
+QString Addressee::role() const
+{
+ return d->mRole;
+}
+
+QString Addressee::roleLabel()
+{
+ return i18nc( "of a person in an organization", "Role" );
+}
+
+
+void Addressee::setOrganization( const QString &organization )
+{
+ if ( organization == d->mOrganization )
+ return;
+
+ d->mEmpty = false;
+ d->mOrganization = organization;
+}
+
+QString Addressee::organization() const
+{
+ return d->mOrganization;
+}
+
+QString Addressee::organizationLabel()
+{
+ return i18n( "Organization" );
+}
+
+
+void Addressee::setDepartment( const QString &department )
+{
+ if ( department == d->mDepartment )
+ return;
+
+ d->mEmpty = false;
+ d->mDepartment = department;
+}
+
+QString Addressee::department() const
+{
+ return d->mDepartment;
+}
+
+QString Addressee::departmentLabel()
+{
+ return i18n( "Department" );
+}
+
+
+void Addressee::setNote( const QString ¬e )
+{
+ if ( note == d->mNote )
+ return;
+
+ d->mEmpty = false;
+ d->mNote = note;
+}
+
+QString Addressee::note() const
+{
+ return d->mNote;
+}
+
+QString Addressee::noteLabel()
+{
+ return i18n( "Note" );
+}
+
+
+void Addressee::setProductId( const QString &productId )
+{
+ if ( productId == d->mProductId )
+ return;
+
+ d->mEmpty = false;
+ d->mProductId = productId;
+}
+
+QString Addressee::productId() const
+{
+ return d->mProductId;
+}
+
+QString Addressee::productIdLabel()
+{
+ return i18n( "Product Identifier" );
+}
+
+
+void Addressee::setRevision( const QDateTime &revision )
+{
+ if ( revision == d->mRevision )
+ return;
+
+ d->mEmpty = false;
+ d->mRevision = revision;
+}
+
+QDateTime Addressee::revision() const
+{
+ return d->mRevision;
+}
+
+QString Addressee::revisionLabel()
+{
+ return i18n( "Revision Date" );
+}
+
+
+void Addressee::setSortString( const QString &sortString )
+{
+ if ( sortString == d->mSortString )
+ return;
+
+ d->mEmpty = false;
+ d->mSortString = sortString;
+}
+
+QString Addressee::sortString() const
+{
+ return d->mSortString;
+}
+
+QString Addressee::sortStringLabel()
+{
+ return i18n( "Sort String" );
+}
+
+
+void Addressee::setUrl( const KUrl &url )
+{
+ if ( url == d->mUrl )
+ return;
+
+ d->mEmpty = false;
+ d->mUrl = url;
+}
+
+KUrl Addressee::url() const
+{
+ return d->mUrl;
+}
+
+QString Addressee::urlLabel()
+{
+ return i18n( "Homepage" );
+}
+
+
+void Addressee::setSecrecy( const Secrecy &secrecy )
+{
+ if ( secrecy == d->mSecrecy )
+ return;
+
+ d->mEmpty = false;
+ d->mSecrecy = secrecy;
+}
+
+Secrecy Addressee::secrecy() const
+{
+ return d->mSecrecy;
+}
+
+QString Addressee::secrecyLabel()
+{
+ return i18n( "Security Class" );
+}
+
+
+void Addressee::setLogo( const Picture &logo )
+{
+ if ( logo == d->mLogo )
+ return;
+
+ d->mEmpty = false;
+ d->mLogo = logo;
+}
+
+Picture Addressee::logo() const
+{
+ return d->mLogo;
+}
+
+QString Addressee::logoLabel()
+{
+ return i18n( "Logo" );
+}
+
+
+void Addressee::setPhoto( const Picture &photo )
+{
+ if ( photo == d->mPhoto )
+ return;
+
+ d->mEmpty = false;
+ d->mPhoto = photo;
+}
+
+Picture Addressee::photo() const
+{
+ return d->mPhoto;
+}
+
+QString Addressee::photoLabel()
+{
+ return i18n( "Photo" );
+}
+
+
+void Addressee::setSound( const Sound &sound )
+{
+ if ( sound == d->mSound )
+ return;
+
+ d->mEmpty = false;
+ d->mSound = sound;
+}
+
+Sound Addressee::sound() const
+{
+ return d->mSound;
+}
+
+QString Addressee::soundLabel()
+{
+ return i18n( "Sound" );
+}
+
+
+void Addressee::setNameFromString( const QString &s )
+{
+ QString str = s;
+ //remove enclosing quotes from string
+ if ( str.length() > 1 &&
+ s[ 0 ] == QLatin1Char( '"' ) &&
+ s[ s.length() - 1 ] == QLatin1Char( '"' ) ) {
+ str = s.mid( 1, s.length() - 2 );
+ }
+
+ setFormattedName( str );
+ setName( str );
+
+ // clear all name parts
+ setPrefix( QString() );
+ setGivenName( QString() );
+ setAdditionalName( QString() );
+ setFamilyName( QString() );
+ setSuffix( QString() );
+
+ if ( str.isEmpty() )
+ return;
+
+ static QString spaceStr = QString::fromLatin1( " " );
+ static QString emptyStr = QString::fromLatin1( "" );
+ AddresseeHelper *helper = AddresseeHelper::self();
+
+ int i = str.indexOf( QLatin1Char( ',' ) );
+ if ( i < 0 ) {
+ QStringList parts = str.split( spaceStr );
+ int leftOffset = 0;
+ int rightOffset = parts.count() - 1;
+
+ QString suffix;
+ while ( rightOffset >= 0 ) {
+ if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
+ suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : \
spaceStr ) ); + rightOffset--;
+ } else
+ break;
+ }
+ setSuffix( suffix );
+
+ if ( rightOffset < 0 )
+ return;
+
+ if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 \
].toLower() ) ) { + setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ \
rightOffset ] ); + rightOffset--;
+ } else {
+ if ( helper->tradeAsFamilyName() )
+ setFamilyName( parts[ rightOffset ] );
+ else
+ setGivenName( parts[ rightOffset ] );
+ }
+
+ QString prefix;
+ while ( leftOffset < rightOffset ) {
+ if ( helper->containsTitle( parts[ leftOffset ] ) ) {
+ prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ \
leftOffset ] ); + leftOffset++;
+ } else
+ break;
+ }
+ setPrefix( prefix );
+
+ if ( leftOffset < rightOffset ) {
+ setGivenName( parts[ leftOffset ] );
+ leftOffset++;
+ }
+
+ QString additionalName;
+ while ( leftOffset < rightOffset ) {
+ additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + \
parts[ leftOffset ] ); + leftOffset++;
+ }
+ setAdditionalName( additionalName );
+ } else {
+ QString part1 = str.left( i );
+ QString part2 = str.mid( i + 1 );
+
+ QStringList parts = part1.split( spaceStr );
+ int leftOffset = 0;
+ int rightOffset = parts.count() - 1;
+
+ if ( parts.count() > 0 ) {
+
+ QString suffix;
+ while ( rightOffset >= 0 ) {
+ if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
+ suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : \
spaceStr ) ); + rightOffset--;
+ } else
+ break;
+ }
+ setSuffix( suffix );
+
+ if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 \
].toLower() ) ) { + setFamilyName( parts[ rightOffset - 1 ] + spaceStr + \
parts[ rightOffset ] ); + rightOffset--;
+ } else
+ setFamilyName( parts[ rightOffset ] );
+
+ QString prefix;
+ while ( leftOffset < rightOffset ) {
+ if ( helper->containsTitle( parts[ leftOffset ] ) ) {
+ prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ \
leftOffset ] ); + leftOffset++;
+ } else
+ break;
+ }
+ } else {
+ setPrefix( QString() );
+ setFamilyName( QString() );
+ setSuffix( QString() );
+ }
+
+ parts = part2.split( spaceStr );
+
+ leftOffset = 0;
+ rightOffset = parts.count();
+
+ if ( parts.count() > 0 ) {
+
+ QString prefix;
+ while ( leftOffset < rightOffset ) {
+ if ( helper->containsTitle( parts[ leftOffset ] ) ) {
+ prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ \
leftOffset ] ); + leftOffset++;
+ } else
+ break;
+ }
+ setPrefix( prefix );
+
+ if ( leftOffset < rightOffset ) {
+ setGivenName( parts[ leftOffset ] );
+ leftOffset++;
+ }
+
+ QString additionalName;
+ while ( leftOffset < rightOffset ) {
+ additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + \
parts[ leftOffset ] ); + leftOffset++;
+ }
+ setAdditionalName( additionalName );
+ } else {
+ setGivenName( QString() );
+ setAdditionalName( QString() );
+ }
+ }
+}
+
+QString Addressee::realName() const
+{
+ QString n( formattedName() );
+ if ( !n.isEmpty() )
+ return n;
+
+ n = assembledName();
+ if ( !n.isEmpty() )
+ return n;
+
+ n = name();
+ if ( !n.isEmpty() )
+ return n;
+
+ return organization();
+}
+
+QString Addressee::assembledName() const
+{
+ const QString name = prefix() + QLatin1Char( ' ' ) +
+ givenName() + QLatin1Char( ' ' ) +
+ additionalName() + QLatin1Char( ' ' ) +
+ familyName() + QLatin1Char( ' ' ) +
+ suffix();
+
+ return name.simplified();
+}
+
+QString Addressee::fullEmail( const QString &email ) const
+{
+ QString e;
+ if ( email.isNull() ) {
+ e = preferredEmail();
+ } else {
+ e = email;
+ }
+ if ( e.isEmpty() ) return QString();
+
+ QString text;
+ if ( realName().isEmpty() )
+ text = e;
+ else {
+ QRegExp needQuotes( QLatin1String( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ) );
+ if ( realName().indexOf( needQuotes ) != -1 ) {
+ QString name = realName();
+ name.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) );
+ text = QLatin1String( "\"" ) + name + QLatin1String( "\" <" ) + e + \
QLatin1Char( '>' ); + } else
+ text = realName() + QLatin1String( " <" ) + e + QLatin1Char( '>' );
+ }
+
+ return text;
+}
+
+void Addressee::insertEmail( const QString &email, bool preferred )
+{
+ if ( email.simplified().isEmpty() )
+ return;
+
+ if ( d->mEmails.contains( email ) ) {
+ if ( !preferred || d->mEmails.first() == email )
+ return;
+
+ d->mEmails.removeAll( email );
+ d->mEmails.prepend( email );
+ } else {
+ d->mEmpty = false;
+ if ( preferred ) {
+ d->mEmails.prepend( email );
+ } else {
+ d->mEmails.append( email );
+ }
+ }
+}
+
+void Addressee::removeEmail( const QString &email )
+{
+ if ( d->mEmails.contains( email ) ) {
+ d->mEmails.removeAll( email );
+ }
+}
+
+QString Addressee::preferredEmail() const
+{
+ if ( d->mEmails.count() == 0 )
+ return QString();
+ else
+ return d->mEmails.first();
+}
+
+QStringList Addressee::emails() const
+{
+ return d->mEmails;
+}
+
+void Addressee::setEmails( const QStringList& emails )
+{
+ d->mEmails = emails;
+}
+void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
+{
+ d->mEmpty = false;
+
+ PhoneNumber::List::Iterator it;
+ for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
+ if ( ( *it ).id() == phoneNumber.id() ) {
+ *it = phoneNumber;
+ return;
+ }
+ }
+ if ( !phoneNumber.number().simplified().isEmpty() )
+ d->mPhoneNumbers.append( phoneNumber );
+}
+
+void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
+{
+ PhoneNumber::List::Iterator it;
+ for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
+ if ( ( *it ).id() == phoneNumber.id() ) {
+ d->mPhoneNumbers.erase( it );
+ return;
+ }
+ }
+}
+
+PhoneNumber Addressee::phoneNumber( PhoneNumber::Type type ) const
+{
+ PhoneNumber phoneNumber( QString(), type );
+ PhoneNumber::List::ConstIterator it;
+ for ( it = d->mPhoneNumbers.constBegin(); it != d->mPhoneNumbers.constEnd(); ++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 d->mPhoneNumbers;
+}
+
+PhoneNumber::List Addressee::phoneNumbers( PhoneNumber::Type type ) const
+{
+ PhoneNumber::List list;
+
+ PhoneNumber::List::ConstIterator it;
+ PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
+ for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
+ if ( matchBinaryPattern( ( *it ).type(), type ) ) {
+ list.append( *it );
+ }
+ }
+ return list;
+}
+
+PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
+{
+ PhoneNumber::List::ConstIterator it;
+ PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
+ for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
+ if ( ( *it ).id() == id ) {
+ return *it;
+ }
+ }
+ return PhoneNumber();
+}
+
+void Addressee::insertKey( const Key &key )
+{
+ d->mEmpty = false;
+
+ Key::List::Iterator it;
+ for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
+ if ( ( *it ).id() == key.id() ) {
+ *it = key;
+ return;
+ }
+ }
+ d->mKeys.append( key );
+}
+
+void Addressee::removeKey( const Key &key )
+{
+ Key::List::Iterator it;
+ for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
+ if ( ( *it ).id() == key.id() ) {
+ d->mKeys.removeAll( key );
+ return;
+ }
+ }
+}
+
+Key Addressee::key( Key::Type type, QString customTypeString ) const
+{
+ Key::List::ConstIterator it;
+ Key::List::ConstIterator end( d->mKeys.constEnd() );
+ for ( it = d->mKeys.constBegin(); it != 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 )
+{
+ d->mKeys = list;
+}
+
+Key::List Addressee::keys() const
+{
+ return d->mKeys;
+}
+
+Key::List Addressee::keys( Key::Type type, QString customTypeString ) const
+{
+ Key::List list;
+
+ Key::List::ConstIterator it;
+ Key::List::ConstIterator end( d->mKeys.constEnd() );
+ for ( it = d->mKeys.constBegin(); it != 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;
+ Key::List::ConstIterator end( d->mKeys.constEnd() );
+ for ( it = d->mKeys.constBegin(); it != end; ++it ) {
+ if ( ( *it ).id() == id ) {
+ return *it;
+ }
+ }
+ return Key();
+}
+
+QString Addressee::toString() const
+{
+ QString str;
+
+ str += QLatin1String( "Addressee {\n" );
+ str += QString::fromLatin1( " Uid: %1\n" ).arg( uid() );
+
+ str += QString::fromLatin1( " Name: %1\n" ).arg( name() );
+ str += QString::fromLatin1( " FormattedName: %1\n" ).arg( formattedName() );
+ str += QString::fromLatin1( " FamilyName: %1\n" ).arg( familyName() );
+ str += QString::fromLatin1( " GivenName: %1\n" ).arg( givenName() );
+ str += QString::fromLatin1( " AdditionalName: %1\n" ).arg( additionalName() );
+ str += QString::fromLatin1( " Prefix: %1\n" ).arg( prefix() );
+ str += QString::fromLatin1( " Suffix: %1\n" ).arg( suffix() );
+ str += QString::fromLatin1( " NickName: %1\n" ).arg( nickName() );
+ str += QString::fromLatin1( " Birthday: %1\n" ).arg( birthday().toString() );
+ str += QString::fromLatin1( " Mailer: %1\n" ).arg( mailer() );
+ str += QString::fromLatin1( " TimeZone: %1\n" ).arg( timeZone().toString() );
+ str += QString::fromLatin1( " Geo: %1\n" ).arg( geo().toString() );
+ str += QString::fromLatin1( " Title: %1\n" ).arg( title() );
+ str += QString::fromLatin1( " Role: %1\n" ).arg( role() );
+ str += QString::fromLatin1( " Organization: %1\n" ).arg( organization() );
+ str += QString::fromLatin1( " Department: %1\n" ).arg( department() );
+ str += QString::fromLatin1( " Note: %1\n" ).arg( note() );
+ str += QString::fromLatin1( " ProductId: %1\n" ).arg( productId() );
+ str += QString::fromLatin1( " Revision: %1\n" ).arg( revision().toString() );
+ str += QString::fromLatin1( " SortString: %1\n" ).arg( sortString() );
+ str += QString::fromLatin1( " Url: %1\n" ).arg( url().url() );
+ str += QString::fromLatin1( " Secrecy: %1\n" ).arg( secrecy().toString() );
+ str += QString::fromLatin1( " Logo: %1\n" ).arg( logo().toString() );
+ str += QString::fromLatin1( " Photo: %1\n" ).arg( photo().toString() );
+ str += QString::fromLatin1( " Sound: %1\n" ).arg( sound().toString() );
+
+ str += QLatin1String( " Emails {\n" );
+ const QStringList e = emails();
+ QStringList::ConstIterator it;
+ for ( it = e.begin(); it != e.end(); ++it ) {
+ str += QString::fromLatin1( " %1\n" ).arg( *it );
+ }
+ str += QLatin1String( " }\n" );
+
+ str += QLatin1String( " PhoneNumbers {\n" );
+ const PhoneNumber::List p = phoneNumbers();
+ PhoneNumber::List::ConstIterator it2;
+ for ( it2 = p.begin(); it2 != p.end(); ++it2 ) {
+ str += ( *it2 ).toString();
+ }
+ str += QLatin1String( " }\n" );
+
+ str += QLatin1String( " Addresses {\n" );
+ const Address::List a = addresses();
+ Address::List::ConstIterator it3;
+ for ( it3 = a.begin(); it3 != a.end(); ++it3 ) {
+ str += ( *it3 ).toString();
+ }
+ str += QLatin1String( " }\n" );
+
+ str += QLatin1String( " Keys {\n" );
+ const Key::List k = keys();
+ Key::List::ConstIterator it4;
+ for ( it4 = k.begin(); it4 != k.end(); ++it4 ) {
+ str += ( *it4 ).toString();
+ }
+ str += QLatin1String( " }\n" );
+
+ str += QLatin1String( "}\n" );
+
+ return str;
+}
+
+
+void Addressee::insertAddress( const Address &address )
+{
+ if ( address.isEmpty() )
+ return;
+
+ d->mEmpty = false;
+
+ Address::List::Iterator it;
+ for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
+ if ( ( *it ).id() == address.id() ) {
+ *it = address;
+ return;
+ }
+ }
+
+ d->mAddresses.append( address );
+}
+
+void Addressee::removeAddress( const Address &address )
+{
+ Address::List::Iterator it;
+ for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
+ if ( ( *it ).id() == address.id() ) {
+ d->mAddresses.erase( it );
+ return;
+ }
+ }
+}
+
+Address Addressee::address( Address::Type type ) const
+{
+ Address address( type );
+ Address::List::ConstIterator it;
+ Address::List::ConstIterator end( d->mAddresses.constEnd() );
+ for ( it = d->mAddresses.constBegin(); it != 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 d->mAddresses;
+}
+
+Address::List Addressee::addresses( Address::Type type ) const
+{
+ Address::List list;
+
+ Address::List::ConstIterator it;
+ Address::List::ConstIterator end( d->mAddresses.constEnd() );
+ for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
+ if ( matchBinaryPattern( ( *it ).type(), type ) ) {
+ list.append( *it );
+ }
+ }
+
+ return list;
+}
+
+Address Addressee::findAddress( const QString &id ) const
+{
+ Address::List::ConstIterator it;
+ Address::List::ConstIterator end( d->mAddresses.constEnd() );
+ for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
+ if ( ( *it ).id() == id ) {
+ return *it;
+ }
+ }
+ return Address();
+}
+
+void Addressee::insertCategory( const QString &c )
+{
+ d->mEmpty = false;
+
+ if ( d->mCategories.contains( c ) )
+ return;
+
+ d->mCategories.append( c );
+}
+
+void Addressee::removeCategory( const QString &category )
+{
+ if ( d->mCategories.contains( category ) ) {
+ d->mCategories.removeAll( category );
+ }
+}
+
+bool Addressee::hasCategory( const QString &category ) const
+{
+ return d->mCategories.contains( category );
+}
+
+void Addressee::setCategories( const QStringList &c )
+{
+ d->mEmpty = false;
+
+ d->mCategories = c;
+}
+
+QStringList Addressee::categories() const
+{
+ return d->mCategories;
+}
+
+void Addressee::insertCustom( const QString &app, const QString &name,
+ const QString &value )
+{
+ if ( value.isEmpty() || name.isEmpty() || app.isEmpty() ) {
+ return;
+ }
+
+ d->mEmpty = false;
+
+ QString qualifiedName = app + QLatin1Char( '-' ) + name + QLatin1Char( ':' );
+
+ QStringList::Iterator it;
+ QStringList::Iterator end( d->mCustom.end() );
+ for ( it = d->mCustom.begin(); it != end; ++it ) {
+ if ( ( *it ).startsWith( qualifiedName ) ) {
+ ( *it ) = qualifiedName + value;
+ return;
+ }
+ }
+
+ d->mCustom.append( qualifiedName + value );
+}
+
+void Addressee::removeCustom( const QString &app, const QString &name )
+{
+ const QString qualifiedName = app + QLatin1Char( '-' ) + name + QLatin1Char( ':' \
); +
+ QStringList::Iterator it;
+ for ( it = d->mCustom.begin(); it != d->mCustom.end(); ++it ) {
+ if ( ( *it ).startsWith( qualifiedName ) ) {
+ d->mCustom.erase( it );
+ return;
+ }
+ }
+}
+
+QString Addressee::custom( const QString &app, const QString &name ) const
+{
+ QString qualifiedName = app + QLatin1Char( '-' ) + name + QLatin1Char( ':' );
+ QString value;
+
+ QStringList::ConstIterator it;
+ QStringList::ConstIterator end( d->mCustom.constEnd() );
+ for ( it = d->mCustom.constBegin(); it != end; ++it ) {
+ if ( ( *it ).startsWith( qualifiedName ) ) {
+ value = ( *it ).mid( ( *it ).indexOf( QLatin1Char( ':' ) ) + 1 );
+ break;
+ }
+ }
+
+ return value;
+}
+
+void Addressee::setCustoms( const QStringList &l )
+{
+ d->mEmpty = false;
+ d->mCustom = l;
+}
+
+QStringList Addressee::customs() const
+{
+ return d->mCustom;
+}
+
+void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
+ QString &email )
+{
+ // This is a simplified version of KPIM::splitAddress().
+
+ fullName.clear();
+ email.clear();
+ if ( rawEmail.isEmpty() )
+ return; // KPIM::AddressEmpty;
+
+ // The code works on 8-bit strings, so convert the input to UTF-8.
+ QByteArray address = rawEmail.toUtf8();
+
+ QByteArray displayName;
+ QByteArray addrSpec;
+ QByteArray comment;
+
+ // The following is a primitive parser for a mailbox-list (cf. RFC 2822).
+ // The purpose is to extract a displayable string from the mailboxes.
+ // Comments in the addr-spec are not handled. No error checking is done.
+
+ enum { TopLevel, InComment, InAngleAddress } context = TopLevel;
+ bool inQuotedString = false;
+ int commentLevel = 0;
+ bool stop = false;
+
+ for ( char* p = address.data(); *p && !stop; ++p ) {
+ switch ( context ) {
+ case TopLevel : {
+ switch ( *p ) {
+ case '"' : inQuotedString = !inQuotedString;
+ displayName += *p;
+ break;
+ case '(' : if ( !inQuotedString ) {
+ context = InComment;
+ commentLevel = 1;
+ }
+ else
+ displayName += *p;
+ break;
+ case '<' : if ( !inQuotedString ) {
+ context = InAngleAddress;
+ }
+ else
+ displayName += *p;
+ break;
+ case '\\' : // quoted character
+ displayName += *p;
+ ++p; // skip the '\'
+ if ( *p )
+ displayName += *p;
+ else
+ //return KPIM::UnexpectedEnd;
+ goto ABORT_PARSING;
+ break;
+ case ',' : if ( !inQuotedString ) {
+ //if ( allowMultipleAddresses )
+ // stop = true;
+ //else
+ // return KPIM::UnexpectedComma;
+ goto ABORT_PARSING;
+ }
+ else
+ displayName += *p;
+ break;
+ default : displayName += *p;
+ }
+ break;
+ }
+ case InComment : {
+ switch ( *p ) {
+ case '(' : ++commentLevel;
+ comment += *p;
+ break;
+ case ')' : --commentLevel;
+ if ( commentLevel == 0 ) {
+ context = TopLevel;
+ comment += ' '; // separate the text of several comments
+ }
+ else
+ comment += *p;
+ break;
+ case '\\' : // quoted character
+ comment += *p;
+ ++p; // skip the '\'
+ if ( *p )
+ comment += *p;
+ else
+ //return KPIM::UnexpectedEnd;
+ goto ABORT_PARSING;
+ break;
+ default : comment += *p;
+ }
+ break;
+ }
+ case InAngleAddress : {
+ switch ( *p ) {
+ case '"' : inQuotedString = !inQuotedString;
+ addrSpec += *p;
+ break;
+ case '>' : if ( !inQuotedString ) {
+ context = TopLevel;
+ }
+ else
+ addrSpec += *p;
+ break;
+ case '\\' : // quoted character
+ addrSpec += *p;
+ ++p; // skip the '\'
+ if ( *p )
+ addrSpec += *p;
+ else
+ //return KPIM::UnexpectedEnd;
+ goto ABORT_PARSING;
+ break;
+ default : addrSpec += *p;
+ }
+ break;
+ }
+ } // switch ( context )
+ }
+
+ABORT_PARSING:
+ displayName = displayName.trimmed();
+ comment = comment.trimmed();
+ addrSpec = addrSpec.trimmed();
+
+ fullName = QString::fromUtf8( displayName );
+ email = QString::fromUtf8( addrSpec );
+
+ // check for errors
+ if ( inQuotedString )
+ return; // KPIM::UnbalancedQuote;
+ if ( context == InComment )
+ return; // KPIM::UnbalancedParens;
+ if ( context == InAngleAddress )
+ return; // KPIM::UnclosedAngleAddr;
+
+ if ( addrSpec.isEmpty() ) {
+ if ( displayName.isEmpty() )
+ return; // KPIM::NoAddressSpec;
+ else {
+ //addrSpec = displayName;
+ //displayName.truncate( 0 );
+ // Address of the form "foo@bar" or "foo@bar (Name)".
+ email = fullName;
+ fullName = QString::fromUtf8( comment );
+ }
+ }
+
+ email = email.toLower();
+ // Check that we do not have any extra characters on the end of the
+ // strings
+ unsigned int len = fullName.length();
+ if ( fullName[ 0 ] == QLatin1Char( '"' ) && fullName[ len - 1 ] == QLatin1Char( \
'"' ) ) { + fullName = fullName.mid( 1, len - 2 );
+ }
+}
+
+#ifndef KDEPIM_NO_KRESOURCES
+void Addressee::setResource( Resource *resource )
+{
+ d->mResource = resource;
+}
+
+Resource *Addressee::resource() const
+{
+ return d->mResource;
+}
+#endif
+
+void Addressee::setChanged( bool value )
+{
+ d->mChanged = value;
+}
+
+bool Addressee::changed() const
+{
+ return d->mChanged;
+}
+
+void Addressee::setSortMode( KABC::SortMode *mode )
+{
+ Private::mSortMode = mode;
+}
+
+bool Addressee::operator< ( const Addressee &addr ) const
+{
+ if ( !Private::mSortMode )
+ return false;
+ else
+ return Private::mSortMode->lesser( *this, addr );
+}
+
+QString Addressee::mimeType()
+{
+ return QLatin1String( "text/directory" );
+}
+
+QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
+{
+ s << a.d->mUid;
+
+ s << a.d->mName;
+ s << a.d->mFormattedName;
+ s << a.d->mFamilyName;
+ s << a.d->mGivenName;
+ s << a.d->mAdditionalName;
+ s << a.d->mPrefix;
+ s << a.d->mSuffix;
+ s << a.d->mNickName;
+ s << a.d->mBirthday;
+ s << a.d->mMailer;
+ s << a.d->mTimeZone;
+ s << a.d->mGeo;
+ s << a.d->mTitle;
+ s << a.d->mRole;
+ s << a.d->mOrganization;
+ s << a.d->mDepartment;
+ s << a.d->mNote;
+ s << a.d->mProductId;
+ s << a.d->mRevision;
+ s << a.d->mSortString;
+ s << a.d->mUrl;
+ s << a.d->mSecrecy;
+ s << a.d->mLogo;
+ s << a.d->mPhoto;
+ s << a.d->mSound;
+ s << a.d->mPhoneNumbers;
+ s << a.d->mAddresses;
+ s << a.d->mEmails;
+ s << a.d->mCategories;
+ s << a.d->mCustom;
+ s << a.d->mKeys;
+ return s;
+}
+
+QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
+{
+ s >> a.d->mUid;
+
+ s >> a.d->mName;
+ s >> a.d->mFormattedName;
+ s >> a.d->mFamilyName;
+ s >> a.d->mGivenName;
+ s >> a.d->mAdditionalName;
+ s >> a.d->mPrefix;
+ s >> a.d->mSuffix;
+ s >> a.d->mNickName;
+ s >> a.d->mBirthday;
+ s >> a.d->mMailer;
+ s >> a.d->mTimeZone;
+ s >> a.d->mGeo;
+ s >> a.d->mTitle;
+ s >> a.d->mRole;
+ s >> a.d->mOrganization;
+ s >> a.d->mDepartment;
+ s >> a.d->mNote;
+ s >> a.d->mProductId;
+ s >> a.d->mRevision;
+ s >> a.d->mSortString;
+ s >> a.d->mUrl;
+ s >> a.d->mSecrecy;
+ s >> a.d->mLogo;
+ s >> a.d->mPhoto;
+ s >> a.d->mSound;
+ s >> a.d->mPhoneNumbers;
+ s >> a.d->mAddresses;
+ s >> a.d->mEmails;
+ s >> a.d->mCategories;
+ s >> a.d->mCustom;
+ s >> a.d->mKeys;
+
+ a.d->mEmpty = 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 ) );
+}
+
+template <class L>
+bool listEquals( const QList<L> &list, const QList<L> &pattern )
+{
+ if ( list.count() != pattern.count() )
+ return false;
+ const int numberOfElement( list.count() );
+ for ( int i = 0; i < numberOfElement; ++i ) {
+ if ( !pattern.contains( list[ i ] ) ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool listEquals( const QStringList &list, const QStringList &pattern )
+{
+ if ( list.count() != pattern.count() )
+ return false;
+
+ const int numberOfElement( list.count() );
+ for ( int i = 0; i < numberOfElement; ++i ) {
+ if ( !pattern.contains( list[ i ] ) ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool emailsEquals( const QStringList &list, const QStringList &pattern )
+{
+ if ( list.count() != pattern.count() )
+ return false;
+
+ if ( list.isEmpty() )
+ return true;
+
+ if ( list.first() != pattern.first() )
+ return false;
+
+ QStringList::ConstIterator it;
+ QStringList::ConstIterator end( list.constEnd() );
+ for ( it = list.constBegin(); it != end; ++it ) {
+ if ( !pattern.contains( *it ) ) {
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/kabc/addressee.h b/kabc/addressee.h
new file mode 100644
index 0000000..b184bc1
--- /dev/null
+++ b/kabc/addressee.h
@@ -0,0 +1,992 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+ 2013 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KABC_ADDRESSEE_H
+#define KABC_ADDRESSEE_H
+
+#include <QtCore/QDateTime>
+#include <QtCore/QStringList>
+#include <QtCore/QSharedDataPointer>
+
+#include <kurl.h>
+
+#include "kabc/address.h"
+#include "kabc/geo.h"
+#include "kabc/key.h"
+#include "kabc/phonenumber.h"
+#include "kabc/picture.h"
+#include "kabc/secrecy.h"
+#include "kabc/sound.h"
+#include "kabc/timezone.h"
+#include "kabc/addresseelist.h" // for typedef QList<Addressee> List;
+
+namespace KABC {
+
+#ifndef KDEPIM_NO_KRESOURCES
+class Resource;
+#endif
+class SortMode;
+
+/**
+ @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 KABC_EXPORT Addressee
+{
+ friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Addressee & );
+ friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Addressee & );
+
+ public:
+ /**
+ A list of addressee objects
+ */
+ typedef AddresseeList List;
+ /**
+ A map from unique identifier to addressee.
+
+ @see uid()
+ */
+ typedef QMap<QString, Addressee> Map;
+
+ /**
+ Construct an empty address book entry.
+ */
+ Addressee();
+
+ /**
+ Destroys the address book entry.
+ */
+ ~Addressee();
+
+ /**
+ Copy constructor.
+ */
+ Addressee( const Addressee & );
+
+ /**
+ Assignment operator.
+
+ @return a reference to @c this
+ */
+ Addressee &operator=( const Addressee & );
+
+ /**
+ Equality operator.
+
+ @return @c true if @c this and the given addressee are equal,
+ otherwise @c false
+ */
+ bool operator==( const Addressee & ) const;
+
+ /**
+ Not-equal operator.
+
+ @return @c true if @c this and the given addressee are not equal,
+ otherwise @c false
+ */
+ bool operator!=( const Addressee & ) const;
+
+ /**
+ Return, if the address book entry is empty.
+ */
+ bool isEmpty() const;
+
+ /**
+ Set unique identifier.
+
+ @param uid the KABC 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 homeAddressPostOfficeBox field.
+ */
+ static QString homeAddressPostOfficeBoxLabel();
+
+ /**
+ 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 businessAddressPostOfficeBox field.
+ */
+ static QString businessAddressPostOfficeBoxLabel();
+
+ /**
+ 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 department.
+ */
+ void setDepartment( const QString &department );
+
+ /**
+ Return department.
+ */
+ QString department() const;
+
+ /**
+ Return translated label for department field.
+ */
+ static QString departmentLabel();
+
+ /**
+ Set note.
+ */
+ void setNote( const QString ¬e );
+
+ /**
+ 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 homepage.
+ */
+ void setUrl( const KUrl &url );
+
+ /**
+ Return homepage.
+ */
+ 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 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() the preferred email address is used.
+ */
+ QString fullEmail( const QString &email=QString() ) 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.
+
+ @param email Email address to remove
+ */
+ void removeEmail( const QString &email );
+
+ /**
+ Return preferred email address. This is the first email address or the
+ last one added with insertEmail() with a set preferred parameter.
+ */
+ QString preferredEmail() const;
+
+ /**
+ Return list of all email addresses.
+ */
+ QStringList emails() const;
+
+ /**
+ Set the emails to @p list.
+ 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.
+
+ @param phoneNumber The telephone number to insert to the addressee
+ */
+ void insertPhoneNumber( const PhoneNumber &phoneNumber );
+
+ /**
+ Remove phone number. If no phone number with the given id exists for this
+ addresse nothing happens.
+
+ @param phoneNumber The telephone number to remove from the addressee
+ */
+ void removePhoneNumber( const PhoneNumber &phoneNumber );
+
+ /**
+ Return phone number, which matches the given type.
+
+ @param type The type of phone number to get
+ */
+ PhoneNumber phoneNumber( PhoneNumber::Type type ) const;
+
+ /**
+ Return list of all phone numbers.
+ */
+ PhoneNumber::List phoneNumbers() const;
+
+ /**
+ Return list of phone numbers with a special type.
+
+ @param type The type of phone number to get
+ */
+ PhoneNumber::List phoneNumbers( PhoneNumber::Type type ) const;
+
+ /**
+ Return phone number with the given id.
+
+ @param id The identifier of the phone number to look for.
+ See PhoneNumber::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.
+
+ @param key The key to insert
+ */
+ void insertKey( const Key &key );
+
+ /**
+ Remove a key. If no key with the given id exists for this
+ addresse nothing happens.
+
+ @param key The key to remove
+ */
+ 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.
+
+ @param type The type of key to look for
+ @param customTypeString A string to match custom keys against when
+ @p type is @c Key::Custom
+ */
+ Key key( Key::Type type, QString customTypeString = QString() ) 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.
+
+ @param type The type of key to look for
+ @param customTypeString A string to match custom keys against when
+ @p type is @c Key::Custom
+ */
+ Key::List keys( Key::Type type, QString customTypeString = QString() ) const;
+
+ /**
+ Return key with the given id.
+
+ @param id The identifier of the key to look for. See Key::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.
+
+ @param address The address to insert
+ */
+ void insertAddress( const Address &address );
+
+ /**
+ Remove address. If no address with the given id exists for this
+ addresse nothing happens.
+
+ @param address The address to remove
+ */
+ void removeAddress( const Address &address );
+
+ /**
+ Return address, which matches the given type.
+
+ @param type The type of address to look for
+ */
+ Address address( Address::Type type ) const;
+
+ /**
+ Return list of all addresses.
+ */
+ Address::List addresses() const;
+
+ /**
+ Return list of addresses with a special type.
+
+ @param type The type of addresses to look for
+ */
+ Address::List addresses( Address::Type type ) const;
+
+ /**
+ Return address with the given id.
+
+ @param id The identifier of the address to look for. See Address::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.
+
+ An empty value isn't allowed (nothing happens if this is called with
+ any of the three arguments being empty)
+
+ @param app Name of the application inserting this custom entry
+ @param name Name of this application specific custom entry
+ @param value Value of this application specific custom entry
+ */
+ void insertCustom( const QString &app, const QString &name,
+ const QString &value );
+
+ /**
+ Remove custom entry.
+
+ @param app Name of the application which has inserted this custom entry
+ @param name Name of this application specific custom entry
+ */
+ void removeCustom( const QString &app, const QString &name );
+
+ /**
+ Return value of custom entry, identified by app and entry name.
+
+ @param app Name of the application which has inserted this custom entry
+ @param name Name of this application specific custom entry
+ */
+ 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.
+
+ @param rawEmail The input string to parse for name and email
+ @param fullName The name part of the @p rawEmail input, if it contained one
+ @param email The email part of the @p rawEmail input, if it contained one
+ */
+ static void parseEmailAddress( const QString &rawEmail, QString &fullName,
+ QString &email );
+
+ /**
+ Returns string representation of the addressee.
+ */
+ QString toString() const;
+
+#ifndef KDEPIM_NO_KRESOURCES
+ /**
+ Set resource where the addressee is from.
+
+ @param resource The Resource the addressee is from
+ */
+ void setResource( Resource *resource );
+
+ /**
+ Return pointer to resource.
+ */
+ Resource *resource() const;
+#endif
+
+ /**
+ Mark addressee as changed.
+
+ @param value Sets the status indicating changed data
+ */
+ void setChanged( bool value );
+
+ /**
+ Return whether the addressee is changed.
+ */
+ bool changed() const;
+
+ /**
+ Sets the sort mode implementation.
+
+ Comparing to addressee objects is delegated to an instance
+ of a subclass of KABC::SortMode.
+
+ @param mode The sort mode implementator to use
+ */
+ static void setSortMode( KABC::SortMode *mode );
+
+ /**
+ Return whether this addressee is "less-than" a given one
+
+ @param addr The addressee object to compare with
+
+ @see setSortMode()
+ */
+ bool operator< ( const Addressee &addr ) const;
+
+ /**
+ Returns the MIME type used for Addressees
+ */
+ static QString mimeType();
+
+ private:
+ class Private;
+ QSharedDataPointer<Private> d;
+};
+#ifdef MAKE_KABC_LIB
+KDE_DUMMY_QHASH_FUNCTION( Addressee )
+#endif
+
+KABC_EXPORT QDataStream &operator<<( QDataStream &, const Addressee & );
+KABC_EXPORT QDataStream &operator>>( QDataStream &, Addressee & );
+
+}
+
+#define KABC_ADDRESSEE_METATYPE_DEFINED 1
+Q_DECLARE_METATYPE( KABC::Addressee )
+
+#endif
diff --git a/kabc/field.cpp b/kabc/field.cpp
new file mode 100644
index 0000000..42e8c46
--- /dev/null
+++ b/kabc/field.cpp
@@ -0,0 +1,632 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <klocale.h>
+#include <klocalizedstring.h>
+#include <kconfig.h>
+#include <kglobal.h>
+#include <kconfiggroup.h>
+
+#include "field.h"
+
+using namespace KABC;
+
+class Field::Private
+{
+ public:
+ Private( int fieldId, int category = 0,
+ const QString &label = QString(),
+ const QString &key = QString(),
+ const QString &app = QString() )
+ : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
+ mKey( key ), mApp( app ) {}
+
+ enum FieldId
+ {
+ CustomField,
+ FormattedName,
+ FamilyName,
+ GivenName,
+ AdditionalName,
+ Prefix,
+ Suffix,
+ NickName,
+ Birthday,
+ HomeAddressStreet,
+ HomeAddressPostOfficeBox,
+ HomeAddressLocality,
+ HomeAddressRegion,
+ HomeAddressPostalCode,
+ HomeAddressCountry,
+ HomeAddressLabel,
+ BusinessAddressStreet,
+ BusinessAddressPostOfficeBox,
+ BusinessAddressLocality,
+ BusinessAddressRegion,
+ BusinessAddressPostalCode,
+ BusinessAddressCountry,
+ BusinessAddressLabel,
+ HomePhone,
+ BusinessPhone,
+ MobilePhone,
+ HomeFax,
+ BusinessFax,
+ CarPhone,
+ Isdn,
+ Pager,
+ Email,
+ Mailer,
+ Title,
+ Role,
+ Organization,
+ Department,
+ Note,
+ Url
+ };
+
+ int fieldId() { return mFieldId; }
+ int category() { return mCategory; }
+
+ QString label() { return mLabel; }
+ QString key() { return mKey; }
+ QString app() { return mApp; }
+
+ static Field::List mAllFields;
+ static Field::List mDefaultFields;
+ static Field::List mCustomFields;
+
+ private:
+ int mFieldId;
+ int mCategory;
+
+ QString mLabel;
+ QString mKey;
+ QString mApp;
+};
+
+Field::List Field::Private::mAllFields;
+Field::List Field::Private::mDefaultFields;
+Field::List Field::Private::mCustomFields;
+
+Field::Field( Private *p )
+ : d( p )
+{
+}
+
+Field::~Field()
+{
+ delete d;
+}
+
+QString Field::label()
+{
+ switch ( d->fieldId() ) {
+ case Private::FormattedName:
+ return Addressee::formattedNameLabel();
+ case Private::FamilyName:
+ return Addressee::familyNameLabel();
+ case Private::GivenName:
+ return Addressee::givenNameLabel();
+ case Private::AdditionalName:
+ return Addressee::additionalNameLabel();
+ case Private::Prefix:
+ return Addressee::prefixLabel();
+ case Private::Suffix:
+ return Addressee::suffixLabel();
+ case Private::NickName:
+ return Addressee::nickNameLabel();
+ case Private::Birthday:
+ return Addressee::birthdayLabel();
+ case Private::HomeAddressStreet:
+ return Addressee::homeAddressStreetLabel();
+ case Private::HomeAddressPostOfficeBox:
+ return Addressee::homeAddressPostOfficeBoxLabel();
+ case Private::HomeAddressLocality:
+ return Addressee::homeAddressLocalityLabel();
+ case Private::HomeAddressRegion:
+ return Addressee::homeAddressRegionLabel();
+ case Private::HomeAddressPostalCode:
+ return Addressee::homeAddressPostalCodeLabel();
+ case Private::HomeAddressCountry:
+ return Addressee::homeAddressCountryLabel();
+ case Private::HomeAddressLabel:
+ return Addressee::homeAddressLabelLabel();
+ case Private::BusinessAddressStreet:
+ return Addressee::businessAddressStreetLabel();
+ case Private::BusinessAddressPostOfficeBox:
+ return Addressee::businessAddressPostOfficeBoxLabel();
+ case Private::BusinessAddressLocality:
+ return Addressee::businessAddressLocalityLabel();
+ case Private::BusinessAddressRegion:
+ return Addressee::businessAddressRegionLabel();
+ case Private::BusinessAddressPostalCode:
+ return Addressee::businessAddressPostalCodeLabel();
+ case Private::BusinessAddressCountry:
+ return Addressee::businessAddressCountryLabel();
+ case Private::BusinessAddressLabel:
+ return Addressee::businessAddressLabelLabel();
+ case Private::HomePhone:
+ return Addressee::homePhoneLabel();
+ case Private::BusinessPhone:
+ return Addressee::businessPhoneLabel();
+ case Private::MobilePhone:
+ return Addressee::mobilePhoneLabel();
+ case Private::HomeFax:
+ return Addressee::homeFaxLabel();
+ case Private::BusinessFax:
+ return Addressee::businessFaxLabel();
+ case Private::CarPhone:
+ return Addressee::carPhoneLabel();
+ case Private::Isdn:
+ return Addressee::isdnLabel();
+ case Private::Pager:
+ return Addressee::pagerLabel();
+ case Private::Email:
+ return Addressee::emailLabel();
+ case Private::Mailer:
+ return Addressee::mailerLabel();
+ case Private::Title:
+ return Addressee::titleLabel();
+ case Private::Role:
+ return Addressee::roleLabel();
+ case Private::Organization:
+ return Addressee::organizationLabel();
+ case Private::Department:
+ return Addressee::departmentLabel();
+ case Private::Note:
+ return Addressee::noteLabel();
+ case Private::Url:
+ return Addressee::urlLabel();
+ case Private::CustomField:
+ return d->label();
+ default:
+ return i18n( "Unknown Field" );
+ }
+}
+
+int Field::category()
+{
+ return d->category();
+}
+
+QString Field::categoryLabel( int category )
+{
+ switch ( category ) {
+ case All:
+ return i18n( "All" );
+ case Frequent:
+ return i18n( "Frequent" );
+ case Address:
+ return i18nc( "street/postal","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 ( d->fieldId() ) {
+ case Private::FormattedName:
+ return a.formattedName();
+ case Private::FamilyName:
+ return a.familyName();
+ case Private::GivenName:
+ return a.givenName();
+ case Private::AdditionalName:
+ return a.additionalName();
+ case Private::Prefix:
+ return a.prefix();
+ case Private::Suffix:
+ return a.suffix();
+ case Private::NickName:
+ return a.nickName();
+ case Private::Mailer:
+ return a.mailer();
+ case Private::Title:
+ return a.title();
+ case Private::Role:
+ return a.role();
+ case Private::Organization:
+ return a.organization();
+ case Private::Department:
+ return a.department();
+ case Private::Note:
+ return a.note();
+ case Private::Email:
+ return a.preferredEmail();
+ case Private::Birthday:
+ if ( a.birthday().isValid() )
+ return a.birthday().date().toString( Qt::ISODate );
+ else
+ return QString();
+ case Private::Url:
+ return a.url().prettyUrl();
+ case Private::HomePhone:
+ {
+ PhoneNumber::List::ConstIterator it;
+
+ {
+ // check for preferred number
+ const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Home | \
PhoneNumber::Pref ); + for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( ( ( *it ).type() & ~( PhoneNumber::Pref ) ) == PhoneNumber::Home ) {
+ return ( *it ).number();
+ }
+ }
+ }
+
+ {
+ // check for normal home number
+ const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Home );
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( ( ( *it ).type() & ~(PhoneNumber::Pref) ) == PhoneNumber::Home ) {
+ return ( *it ).number();
+ }
+ }
+ }
+
+ return QString();
+ }
+ case Private::BusinessPhone:
+ {
+ PhoneNumber::List::ConstIterator it;
+
+ {
+ // check for preferred number
+ const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Work | \
PhoneNumber::Pref ); + for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( ( ( *it ).type() & ~(PhoneNumber::Pref) ) == PhoneNumber::Work ) {
+ return ( *it ).number();
+ }
+ }
+ }
+
+ {
+ // check for normal work number
+ const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Work );
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( ( ( *it ).type() & ~(PhoneNumber::Pref) ) == PhoneNumber::Work ) {
+ return ( *it ).number();
+ }
+ }
+ }
+
+ return QString();
+ }
+ case Private::MobilePhone:
+ return a.phoneNumber( PhoneNumber::Cell ).number();
+ case Private::HomeFax:
+ return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
+ case Private::BusinessFax:
+ return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
+ case Private::CarPhone:
+ return a.phoneNumber( PhoneNumber::Car ).number();
+ case Private::Isdn:
+ return a.phoneNumber( PhoneNumber::Isdn ).number();
+ case Private::Pager:
+ return a.phoneNumber( PhoneNumber::Pager ).number();
+ case Private::HomeAddressStreet:
+ return a.address( Address::Home ).street();
+ case Private::HomeAddressPostOfficeBox:
+ return a.address( Address::Home ).postOfficeBox();
+ case Private::HomeAddressLocality:
+ return a.address( Address::Home ).locality();
+ case Private::HomeAddressRegion:
+ return a.address( Address::Home ).region();
+ case Private::HomeAddressPostalCode:
+ return a.address( Address::Home ).postalCode();
+ case Private::HomeAddressCountry:
+ return a.address( Address::Home ).country();
+ case Private::BusinessAddressStreet:
+ return a.address( Address::Work ).street();
+ case Private::BusinessAddressPostOfficeBox:
+ return a.address( Address::Work ).postOfficeBox();
+ case Private::BusinessAddressLocality:
+ return a.address( Address::Work ).locality();
+ case Private::BusinessAddressRegion:
+ return a.address( Address::Work ).region();
+ case Private::BusinessAddressPostalCode:
+ return a.address( Address::Work ).postalCode();
+ case Private::BusinessAddressCountry:
+ return a.address( Address::Work ).country();
+ case Private::CustomField:
+ return a.custom( d->app(), d->key() );
+ default:
+ return QString();
+ }
+}
+
+bool Field::setValue( KABC::Addressee &a, const QString &value )
+{
+ switch ( d->fieldId() ) {
+ case Private::FormattedName:
+ a.setFormattedName( value );
+ return true;
+ case Private::FamilyName:
+ a.setFamilyName( value );
+ return true;
+ case Private::GivenName:
+ a.setGivenName( value );
+ return true;
+ case Private::AdditionalName:
+ a.setAdditionalName( value );
+ return true;
+ case Private::Prefix:
+ a.setPrefix( value );
+ return true;
+ case Private::Suffix:
+ a.setSuffix( value );
+ return true;
+ case Private::NickName:
+ a.setNickName( value );
+ return true;
+ case Private::Mailer:
+ a.setMailer( value );
+ return true;
+ case Private::Title:
+ a.setTitle( value );
+ return true;
+ case Private::Role:
+ a.setRole( value );
+ return true;
+ case Private::Organization:
+ a.setOrganization( value );
+ return true;
+ case Private::Department:
+ a.setDepartment( value );
+ return true;
+ case Private::Note:
+ a.setNote( value );
+ return true;
+ case Private::Birthday:
+ a.setBirthday( QDateTime::fromString( value, Qt::ISODate ) );
+ return true;
+ case Private::CustomField:
+ a.insertCustom( d->app(), d->key(), value );
+ return true;
+ default:
+ return false;
+ }
+}
+
+QString Field::sortKey( const KABC::Addressee &a )
+{
+ switch ( d->fieldId() ) {
+ case Private::FormattedName:
+ return a.formattedName();
+ case Private::FamilyName:
+ return a.familyName();
+ case Private::GivenName:
+ return a.givenName();
+ case Private::AdditionalName:
+ return a.additionalName();
+ case Private::Prefix:
+ return a.prefix();
+ case Private::Suffix:
+ return a.suffix();
+ case Private::NickName:
+ return a.nickName();
+ case Private::Mailer:
+ return a.mailer();
+ case Private::Title:
+ return a.title();
+ case Private::Role:
+ return a.role();
+ case Private::Organization:
+ return a.organization();
+ case Private::Department:
+ return a.department();
+ case Private::Note:
+ return a.note();
+ case Private::Birthday:
+ if ( a.birthday().isValid() ) {
+ QDate date = a.birthday().date();
+ QString key;
+ key.sprintf( "%02d-%02d", date.month(), date.day() );
+ return key;
+ } else
+ return QLatin1String( "00-00" );
+ default:
+ return value( a ).toLower();
+ }
+}
+
+bool Field::isCustom()
+{
+ return d->fieldId() == Private::CustomField;
+}
+
+Field::List Field::allFields()
+{
+ if ( Private::mAllFields.isEmpty() ) {
+ createField( Private::FormattedName, Frequent );
+ createField( Private::FamilyName, Frequent );
+ createField( Private::GivenName, Frequent );
+ createField( Private::AdditionalName );
+ createField( Private::Prefix );
+ createField( Private::Suffix );
+ createField( Private::NickName, Personal );
+ createField( Private::Birthday, Personal );
+ createField( Private::HomeAddressStreet, Address|Personal );
+ createField( Private::HomeAddressPostOfficeBox, Address|Personal );
+ createField( Private::HomeAddressLocality, Address|Personal );
+ createField( Private::HomeAddressRegion, Address|Personal );
+ createField( Private::HomeAddressPostalCode, Address|Personal );
+ createField( Private::HomeAddressCountry, Address|Personal );
+ createField( Private::HomeAddressLabel, Address|Personal );
+ createField( Private::BusinessAddressStreet, Address|Organization );
+ createField( Private::BusinessAddressPostOfficeBox, Address|Organization );
+ createField( Private::BusinessAddressLocality, Address|Organization );
+ createField( Private::BusinessAddressRegion, Address|Organization );
+ createField( Private::BusinessAddressPostalCode, Address|Organization );
+ createField( Private::BusinessAddressCountry, Address|Organization );
+ createField( Private::BusinessAddressLabel, Address|Organization );
+ createField( Private::HomePhone, Personal|Frequent );
+ createField( Private::BusinessPhone, Organization|Frequent );
+ createField( Private::MobilePhone, Frequent );
+ createField( Private::HomeFax );
+ createField( Private::BusinessFax );
+ createField( Private::CarPhone );
+ createField( Private::Isdn );
+ createField( Private::Pager );
+ createField( Private::Email, Email|Frequent );
+ createField( Private::Mailer, Email );
+ createField( Private::Title, Organization );
+ createField( Private::Role, Organization );
+ createField( Private::Organization, Organization );
+ createField( Private::Department, Organization );
+ createField( Private::Note );
+ createField( Private::Url );
+ }
+
+ return Private::mAllFields;
+}
+
+Field::List Field::defaultFields()
+{
+ if ( Private::mDefaultFields.isEmpty() ) {
+ createDefaultField( Private::FormattedName );
+ createDefaultField( Private::Email );
+ }
+
+ return Private::mDefaultFields;
+}
+
+void Field::createField( int id, int category )
+{
+ Private::mAllFields.append( new Field( new Private( id, category ) ) );
+}
+
+void Field::createDefaultField( int id, int category )
+{
+ Private::mDefaultFields.append( new Field( new Private( id, category ) ) );
+}
+
+void Field::deleteFields()
+{
+ Field::List::ConstIterator it;
+
+ for ( it = Private::mAllFields.constBegin(); it != Private::mAllFields.constEnd(); \
++it ) { + delete ( *it );
+ }
+ Private::mAllFields.clear();
+
+ for ( it = Private::mDefaultFields.constBegin(); it != \
Private::mDefaultFields.constEnd(); ++it ) { + delete ( *it );
+ }
+ Private::mDefaultFields.clear();
+
+ for ( it = Private::mCustomFields.constBegin(); it != \
Private::mCustomFields.constEnd(); ++it ) { + delete ( *it );
+ }
+ Private::mCustomFields.clear();
+}
+
+void Field::saveFields( const QString &identifier,
+ const Field::List &fields )
+{
+ KConfigGroup cg( KGlobal::config(), "KABCFields" );
+
+ saveFields( cg, identifier, fields );
+}
+
+void Field::saveFields( KConfigGroup &cfg, const QString &identifier,
+ const Field::List &fields )
+{
+ QList<int> fieldIds;
+
+ int custom = 0;
+ Field::List::ConstIterator it;
+ for ( it = fields.begin(); it != fields.end(); ++it ) {
+ fieldIds.append( ( *it )->d->fieldId() );
+ if ( ( *it )->isCustom() ) {
+ QStringList customEntry;
+ customEntry << ( *it )->d->label();
+ customEntry << ( *it )->d->key();
+ customEntry << ( *it )->d->app();
+ cfg.writeEntry( QLatin1String( "KABC_CustomEntry_" ) + identifier + \
QLatin1Char( '_' ) + + QString::number( custom++ ), customEntry \
); + }
+ }
+
+ cfg.writeEntry( identifier, fieldIds );
+}
+
+Field::List Field::restoreFields( const QString &identifier )
+{
+ KConfigGroup cg( KGlobal::config(), "KABCFields" );
+
+ return restoreFields( cg, identifier );
+}
+
+Field::List Field::restoreFields( const KConfigGroup &cfg, const QString &identifier \
) +{
+ const QList<int> fieldIds = cfg.readEntry( identifier,QList<int>() );
+
+ Field::List fields;
+
+ int custom = 0;
+ QList<int>::ConstIterator it;
+ for ( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
+ Private *f = 0;
+ if ( ( *it ) == Private::CustomField ) {
+ QStringList customEntry = cfg.readEntry( QLatin1String( "KABC_CustomEntry_" ) \
+ + identifier + QLatin1Char( '_' ) +
+ QString::number( custom++ \
),QStringList() ); + f = new Private( *it, CustomCategory, customEntry[ 0 ],
+ customEntry[ 1 ], customEntry[ 2 ] );
+ } else {
+ f = new Private( *it );
+ }
+ fields.append( new Field( f ) );
+ }
+
+ return fields;
+}
+
+bool Field::equals( Field *field )
+{
+ bool sameId = ( d->fieldId() == field->d->fieldId() );
+
+ if ( !sameId ) return false;
+
+ if ( d->fieldId() != Private::CustomField ) return true;
+
+ return d->key() == field->d->key();
+}
+
+Field *Field::createCustomField( const QString &label, int category,
+ const QString &key, const QString &app )
+{
+ Field *field = new Field( new Private( Private::CustomField,
+ category | CustomCategory,
+ label, key, app ) );
+ Private::mCustomFields.append( field );
+
+ return field;
+}
diff --git a/kabc/scripts/addressee.src.cpp b/kabc/scripts/addressee.src.cpp
deleted file mode 100644
index 99c0eb1..0000000
--- a/kabc/scripts/addressee.src.cpp
+++ /dev/null
@@ -1,1136 +0,0 @@
-/*
- This file is part of libkabc.
- Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
- Copyright (c) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
- Copyright (c) 2005 Ingo Kloecker <kloecker@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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <QtCore/QList>
-#include <QtCore/QRegExp>
-#include <QtCore/QSharedData>
-
-#include <kdebug.h>
-#include <klocale.h>
-#include <klocalizedstring.h>
-#include <krandom.h>
-
-#include "addresseehelper.h"
-#include "field.h"
-#ifndef KDEPIM_NO_KRESOURCES
-#include "resource.h"
-#endif
-#include "sortmode.h"
-
-#include "addressee.h"
-
-using namespace KABC;
-
-static bool matchBinaryPattern( int value, int pattern );
-
-template <class L>
-static bool listEquals( const QList<L>&, const QList<L>& );
-static bool listEquals( const QStringList&, const QStringList& );
-static bool emailsEquals( const QStringList&, const QStringList& );
-
-class Addressee::Private : public QSharedData
-{
- public:
- Private()
- : mUid( KRandom::randomString( 10 ) ),
-#ifndef KDEPIM_NO_KRESOURCES
- mResource( 0 ),
-#endif
- mEmpty( true ), mChanged( false )
- {
- }
-
- Private( const Private &other )
- : QSharedData( other )
-#ifndef KDEPIM_NO_KRESOURCES
- ,mResource( 0 )
-#endif
- {
- mUid = other.mUid;
- --VARIABLES_ASSIGNMENT--
-
- mPhoneNumbers = other.mPhoneNumbers;
- mAddresses = other.mAddresses;
- mKeys = other.mKeys;
- mEmails = other.mEmails;
- mCategories = other.mCategories;
- mCustom = other.mCustom;
-
-#ifndef KDEPIM_NO_KRESOURCES
- mResource = other.mResource;
-#endif
- mEmpty = other.mEmpty;
- mChanged = other.mChanged;
- }
-
- ~Private()
- {
- }
-
- QString mUid;
- --VARIABLES--
-
- PhoneNumber::List mPhoneNumbers;
- Address::List mAddresses;
- Key::List mKeys;
- QStringList mEmails;
- QStringList mCategories;
- QStringList mCustom;
-
-#ifndef KDEPIM_NO_KRESOURCES
- Resource *mResource;
-#endif
-
- bool mEmpty :1;
- bool mChanged :1;
-
- static KABC::SortMode *mSortMode;
-};
-
-KABC::SortMode *Addressee::Private::mSortMode = 0;
-
-Addressee::Addressee()
- : d( new Private )
-{
-}
-
-Addressee::~Addressee()
-{
-}
-
-Addressee::Addressee( const Addressee &other )
- : d( other.d )
-{
-}
-
-Addressee& Addressee::operator=( const Addressee &other )
-{
- if ( this != &other )
- d = other.d;
-
- return *this;
-}
-
-bool Addressee::operator==( const Addressee &a ) const
-{
- if ( d->mUid != a.d->mUid ) {
- kDebug() << "uid differs";
- return false;
- }
- --EQUALSTEST--
- if ( ( d->mUrl.isValid() || a.d->mUrl.isValid() ) &&
- ( d->mUrl != a.d->mUrl ) ) {
- kDebug() << "url differs";
- return false;
- }
- if ( !listEquals( d->mPhoneNumbers, a.d->mPhoneNumbers ) ) {
- kDebug() << "phoneNumbers differs";
- return false;
- }
- if ( !listEquals( d->mAddresses, a.d->mAddresses ) ) {
- kDebug() << "addresses differs";
- return false;
- }
- if ( !listEquals( d->mKeys, a.d->mKeys ) ) {
- kDebug() << "keys differs";
- return false;
- }
- if ( !emailsEquals( d->mEmails, a.d->mEmails ) ) {
- kDebug() << "emails differs";
- return false;
- }
- if ( !listEquals( d->mCategories, a.d->mCategories ) ) {
- kDebug() << "categories differs";
- return false;
- }
- if ( !listEquals( d->mCustom, a.d->mCustom ) ) {
- kDebug() << "custom differs";
- return false;
- }
-
- return true;
-}
-
-bool Addressee::operator!=( const Addressee &a ) const
-{
- return !( a == *this );
-}
-
-bool Addressee::isEmpty() const
-{
- return d->mEmpty;
-}
-
-void Addressee::setUid( const QString &id )
-{
- if ( id == d->mUid ) return;
- d->mEmpty = false;
- d->mUid = id;
-}
-
-QString Addressee::uid() const
-{
- return d->mUid;
-}
-
-QString Addressee::uidLabel()
-{
- return i18n( "Unique Identifier" );
-}
-
---DEFINITIONS--
-
-void Addressee::setNameFromString( const QString &s )
-{
- QString str = s;
- //remove enclosing quotes from string
- if ( str.length() > 1 &&
- s[ 0 ] == QLatin1Char( '"' ) &&
- s[ s.length() - 1 ] == QLatin1Char( '"' ) ) {
- str = s.mid( 1, s.length() - 2 );
- }
-
- setFormattedName( str );
- setName( str );
-
- // clear all name parts
- setPrefix( QString() );
- setGivenName( QString() );
- setAdditionalName( QString() );
- setFamilyName( QString() );
- setSuffix( QString() );
-
- if ( str.isEmpty() )
- return;
-
- static QString spaceStr = QString::fromLatin1( " " );
- static QString emptyStr = QString::fromLatin1( "" );
- AddresseeHelper *helper = AddresseeHelper::self();
-
- int i = str.indexOf( QLatin1Char( ',' ) );
- if ( i < 0 ) {
- QStringList parts = str.split( spaceStr );
- int leftOffset = 0;
- int rightOffset = parts.count() - 1;
-
- QString suffix;
- while ( rightOffset >= 0 ) {
- if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
- suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : \
spaceStr ) );
- rightOffset--;
- } else
- break;
- }
- setSuffix( suffix );
-
- if ( rightOffset < 0 )
- return;
-
- if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 \
].toLower() ) ) {
- setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] );
- rightOffset--;
- } else {
- if ( helper->tradeAsFamilyName() )
- setFamilyName( parts[ rightOffset ] );
- else
- setGivenName( parts[ rightOffset ] );
- }
-
- QString prefix;
- while ( leftOffset < rightOffset ) {
- if ( helper->containsTitle( parts[ leftOffset ] ) ) {
- prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ \
leftOffset ] );
- leftOffset++;
- } else
- break;
- }
- setPrefix( prefix );
-
- if ( leftOffset < rightOffset ) {
- setGivenName( parts[ leftOffset ] );
- leftOffset++;
- }
-
- QString additionalName;
- while ( leftOffset < rightOffset ) {
- additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + \
parts[ leftOffset ] );
- leftOffset++;
- }
- setAdditionalName( additionalName );
- } else {
- QString part1 = str.left( i );
- QString part2 = str.mid( i + 1 );
-
- QStringList parts = part1.split( spaceStr );
- int leftOffset = 0;
- int rightOffset = parts.count() - 1;
-
- if ( parts.count() > 0 ) {
-
- QString suffix;
- while ( rightOffset >= 0 ) {
- if ( helper->containsSuffix( parts[ rightOffset ] ) ) {
- suffix.prepend( parts[ rightOffset ] + ( suffix.isEmpty() ? emptyStr : \
spaceStr ) );
- rightOffset--;
- } else
- break;
- }
- setSuffix( suffix );
-
- if ( rightOffset - 1 >= 0 && helper->containsPrefix( parts[ rightOffset - 1 \
].toLower() ) ) {
- setFamilyName( parts[ rightOffset - 1 ] + spaceStr + parts[ rightOffset ] );
- rightOffset--;
- } else
- setFamilyName( parts[ rightOffset ] );
-
- QString prefix;
- while ( leftOffset < rightOffset ) {
- if ( helper->containsTitle( parts[ leftOffset ] ) ) {
- prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ \
leftOffset ] );
- leftOffset++;
- } else
- break;
- }
- } else {
- setPrefix( QString() );
- setFamilyName( QString() );
- setSuffix( QString() );
- }
-
- parts = part2.split( spaceStr );
-
- leftOffset = 0;
- rightOffset = parts.count();
-
- if ( parts.count() > 0 ) {
-
- QString prefix;
- while ( leftOffset < rightOffset ) {
- if ( helper->containsTitle( parts[ leftOffset ] ) ) {
- prefix.append( ( prefix.isEmpty() ? emptyStr : spaceStr ) + parts[ \
leftOffset ] );
- leftOffset++;
- } else
- break;
- }
- setPrefix( prefix );
-
- if ( leftOffset < rightOffset ) {
- setGivenName( parts[ leftOffset ] );
- leftOffset++;
- }
-
- QString additionalName;
- while ( leftOffset < rightOffset ) {
- additionalName.append( ( additionalName.isEmpty() ? emptyStr : spaceStr ) + \
parts[ leftOffset ] );
- leftOffset++;
- }
- setAdditionalName( additionalName );
- } else {
- setGivenName( QString() );
- setAdditionalName( QString() );
- }
- }
-}
-
-QString Addressee::realName() const
-{
- QString n( formattedName() );
- if ( !n.isEmpty() )
- return n;
-
- n = assembledName();
- if ( !n.isEmpty() )
- return n;
-
- n = name();
- if ( !n.isEmpty() )
- return n;
-
- return organization();
-}
-
-QString Addressee::assembledName() const
-{
- const QString name = prefix() + QLatin1Char( ' ' ) +
- givenName() + QLatin1Char( ' ' ) +
- additionalName() + QLatin1Char( ' ' ) +
- familyName() + QLatin1Char( ' ' ) +
- suffix();
-
- return name.simplified();
-}
-
-QString Addressee::fullEmail( const QString &email ) const
-{
- QString e;
- if ( email.isNull() ) {
- e = preferredEmail();
- } else {
- e = email;
- }
- if ( e.isEmpty() ) return QString();
-
- QString text;
- if ( realName().isEmpty() )
- text = e;
- else {
- QRegExp needQuotes( QLatin1String( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ) );
- if ( realName().indexOf( needQuotes ) != -1 ) {
- QString name = realName();
- name.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) );
- text = QLatin1String( "\"" ) + name + QLatin1String( "\" <" ) + e + \
QLatin1Char( '>' );
- } else
- text = realName() + QLatin1String( " <" ) + e + QLatin1Char( '>' );
- }
-
- return text;
-}
-
-void Addressee::insertEmail( const QString &email, bool preferred )
-{
- if ( email.simplified().isEmpty() )
- return;
-
- if ( d->mEmails.contains( email ) ) {
- if ( !preferred || d->mEmails.first() == email )
- return;
-
- d->mEmails.removeAll( email );
- d->mEmails.prepend( email );
- } else {
- d->mEmpty = false;
- if ( preferred ) {
- d->mEmails.prepend( email );
- } else {
- d->mEmails.append( email );
- }
- }
-}
-
-void Addressee::removeEmail( const QString &email )
-{
- if ( d->mEmails.contains( email ) ) {
- d->mEmails.removeAll( email );
- }
-}
-
-QString Addressee::preferredEmail() const
-{
- if ( d->mEmails.count() == 0 )
- return QString();
- else
- return d->mEmails.first();
-}
-
-QStringList Addressee::emails() const
-{
- return d->mEmails;
-}
-
-void Addressee::setEmails( const QStringList& emails )
-{
- d->mEmails = emails;
-}
-void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
-{
- d->mEmpty = false;
-
- PhoneNumber::List::Iterator it;
- for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
- if ( ( *it ).id() == phoneNumber.id() ) {
- *it = phoneNumber;
- return;
- }
- }
- if ( !phoneNumber.number().simplified().isEmpty() )
- d->mPhoneNumbers.append( phoneNumber );
-}
-
-void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
-{
- PhoneNumber::List::Iterator it;
- for ( it = d->mPhoneNumbers.begin(); it != d->mPhoneNumbers.end(); ++it ) {
- if ( ( *it ).id() == phoneNumber.id() ) {
- d->mPhoneNumbers.erase( it );
- return;
- }
- }
-}
-
-PhoneNumber Addressee::phoneNumber( PhoneNumber::Type type ) const
-{
- PhoneNumber phoneNumber( QString(), type );
- PhoneNumber::List::ConstIterator it;
- for ( it = d->mPhoneNumbers.constBegin(); it != d->mPhoneNumbers.constEnd(); ++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 d->mPhoneNumbers;
-}
-
-PhoneNumber::List Addressee::phoneNumbers( PhoneNumber::Type type ) const
-{
- PhoneNumber::List list;
-
- PhoneNumber::List::ConstIterator it;
- PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
- for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
- if ( matchBinaryPattern( ( *it ).type(), type ) ) {
- list.append( *it );
- }
- }
- return list;
-}
-
-PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
-{
- PhoneNumber::List::ConstIterator it;
- PhoneNumber::List::ConstIterator end( d->mPhoneNumbers.constEnd() );
- for ( it = d->mPhoneNumbers.constBegin(); it != end; ++it ) {
- if ( ( *it ).id() == id ) {
- return *it;
- }
- }
- return PhoneNumber();
-}
-
-void Addressee::insertKey( const Key &key )
-{
- d->mEmpty = false;
-
- Key::List::Iterator it;
- for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
- if ( ( *it ).id() == key.id() ) {
- *it = key;
- return;
- }
- }
- d->mKeys.append( key );
-}
-
-void Addressee::removeKey( const Key &key )
-{
- Key::List::Iterator it;
- for ( it = d->mKeys.begin(); it != d->mKeys.end(); ++it ) {
- if ( ( *it ).id() == key.id() ) {
- d->mKeys.removeAll( key );
- return;
- }
- }
-}
-
-Key Addressee::key( Key::Type type, QString customTypeString ) const
-{
- Key::List::ConstIterator it;
- Key::List::ConstIterator end( d->mKeys.constEnd() );
- for ( it = d->mKeys.constBegin(); it != 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 )
-{
- d->mKeys = list;
-}
-
-Key::List Addressee::keys() const
-{
- return d->mKeys;
-}
-
-Key::List Addressee::keys( Key::Type type, QString customTypeString ) const
-{
- Key::List list;
-
- Key::List::ConstIterator it;
- Key::List::ConstIterator end( d->mKeys.constEnd() );
- for ( it = d->mKeys.constBegin(); it != 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;
- Key::List::ConstIterator end( d->mKeys.constEnd() );
- for ( it = d->mKeys.constBegin(); it != end; ++it ) {
- if ( ( *it ).id() == id ) {
- return *it;
- }
- }
- return Key();
-}
-
-QString Addressee::toString() const
-{
- QString str;
-
- str += QLatin1String( "Addressee {\n" );
- str += QString::fromLatin1( " Uid: %1\n" ).arg( uid() );
-
- --DEBUG--
-
- str += QLatin1String( " Emails {\n" );
- const QStringList e = emails();
- QStringList::ConstIterator it;
- for ( it = e.begin(); it != e.end(); ++it ) {
- str += QString::fromLatin1( " %1\n" ).arg( *it );
- }
- str += QLatin1String( " }\n" );
-
- str += QLatin1String( " PhoneNumbers {\n" );
- const PhoneNumber::List p = phoneNumbers();
- PhoneNumber::List::ConstIterator it2;
- for ( it2 = p.begin(); it2 != p.end(); ++it2 ) {
- str += ( *it2 ).toString();
- }
- str += QLatin1String( " }\n" );
-
- str += QLatin1String( " Addresses {\n" );
- const Address::List a = addresses();
- Address::List::ConstIterator it3;
- for ( it3 = a.begin(); it3 != a.end(); ++it3 ) {
- str += ( *it3 ).toString();
- }
- str += QLatin1String( " }\n" );
-
- str += QLatin1String( " Keys {\n" );
- const Key::List k = keys();
- Key::List::ConstIterator it4;
- for ( it4 = k.begin(); it4 != k.end(); ++it4 ) {
- str += ( *it4 ).toString();
- }
- str += QLatin1String( " }\n" );
-
- str += QLatin1String( "}\n" );
-
- return str;
-}
-
-
-void Addressee::insertAddress( const Address &address )
-{
- if ( address.isEmpty() )
- return;
-
- d->mEmpty = false;
-
- Address::List::Iterator it;
- for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
- if ( ( *it ).id() == address.id() ) {
- *it = address;
- return;
- }
- }
-
- d->mAddresses.append( address );
-}
-
-void Addressee::removeAddress( const Address &address )
-{
- Address::List::Iterator it;
- for ( it = d->mAddresses.begin(); it != d->mAddresses.end(); ++it ) {
- if ( ( *it ).id() == address.id() ) {
- d->mAddresses.erase( it );
- return;
- }
- }
-}
-
-Address Addressee::address( Address::Type type ) const
-{
- Address address( type );
- Address::List::ConstIterator it;
- Address::List::ConstIterator end( d->mAddresses.constEnd() );
- for ( it = d->mAddresses.constBegin(); it != 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 d->mAddresses;
-}
-
-Address::List Addressee::addresses( Address::Type type ) const
-{
- Address::List list;
-
- Address::List::ConstIterator it;
- Address::List::ConstIterator end( d->mAddresses.constEnd() );
- for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
- if ( matchBinaryPattern( ( *it ).type(), type ) ) {
- list.append( *it );
- }
- }
-
- return list;
-}
-
-Address Addressee::findAddress( const QString &id ) const
-{
- Address::List::ConstIterator it;
- Address::List::ConstIterator end( d->mAddresses.constEnd() );
- for ( it = d->mAddresses.constBegin(); it != end; ++it ) {
- if ( ( *it ).id() == id ) {
- return *it;
- }
- }
- return Address();
-}
-
-void Addressee::insertCategory( const QString &c )
-{
- d->mEmpty = false;
-
- if ( d->mCategories.contains( c ) )
- return;
-
- d->mCategories.append( c );
-}
-
-void Addressee::removeCategory( const QString &category )
-{
- if ( d->mCategories.contains( category ) ) {
- d->mCategories.removeAll( category );
- }
-}
-
-bool Addressee::hasCategory( const QString &category ) const
-{
- return d->mCategories.contains( category );
-}
-
-void Addressee::setCategories( const QStringList &c )
-{
- d->mEmpty = false;
-
- d->mCategories = c;
-}
-
-QStringList Addressee::categories() const
-{
- return d->mCategories;
-}
-
-void Addressee::insertCustom( const QString &app, const QString &name,
- const QString &value )
-{
- if ( value.isEmpty() || name.isEmpty() || app.isEmpty() ) {
- return;
- }
-
- d->mEmpty = false;
-
- QString qualifiedName = app + QLatin1Char( '-' ) + name + QLatin1Char( ':' );
-
- QStringList::Iterator it;
- QStringList::Iterator end( d->mCustom.end() );
- for ( it = d->mCustom.begin(); it != end; ++it ) {
- if ( ( *it ).startsWith( qualifiedName ) ) {
- ( *it ) = qualifiedName + value;
- return;
- }
- }
-
- d->mCustom.append( qualifiedName + value );
-}
-
-void Addressee::removeCustom( const QString &app, const QString &name )
-{
- const QString qualifiedName = app + QLatin1Char( '-' ) + name + QLatin1Char( ':' \
);
-
- QStringList::Iterator it;
- for ( it = d->mCustom.begin(); it != d->mCustom.end(); ++it ) {
- if ( ( *it ).startsWith( qualifiedName ) ) {
- d->mCustom.erase( it );
- return;
- }
- }
-}
-
-QString Addressee::custom( const QString &app, const QString &name ) const
-{
- QString qualifiedName = app + QLatin1Char( '-' ) + name + QLatin1Char( ':' );
- QString value;
-
- QStringList::ConstIterator it;
- QStringList::ConstIterator end( d->mCustom.constEnd() );
- for ( it = d->mCustom.constBegin(); it != end; ++it ) {
- if ( ( *it ).startsWith( qualifiedName ) ) {
- value = ( *it ).mid( ( *it ).indexOf( QLatin1Char( ':' ) ) + 1 );
- break;
- }
- }
-
- return value;
-}
-
-void Addressee::setCustoms( const QStringList &l )
-{
- d->mEmpty = false;
- d->mCustom = l;
-}
-
-QStringList Addressee::customs() const
-{
- return d->mCustom;
-}
-
-void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
- QString &email )
-{
- // This is a simplified version of KPIM::splitAddress().
-
- fullName.clear();
- email.clear();
- if ( rawEmail.isEmpty() )
- return; // KPIM::AddressEmpty;
-
- // The code works on 8-bit strings, so convert the input to UTF-8.
- QByteArray address = rawEmail.toUtf8();
-
- QByteArray displayName;
- QByteArray addrSpec;
- QByteArray comment;
-
- // The following is a primitive parser for a mailbox-list (cf. RFC 2822).
- // The purpose is to extract a displayable string from the mailboxes.
- // Comments in the addr-spec are not handled. No error checking is done.
-
- enum { TopLevel, InComment, InAngleAddress } context = TopLevel;
- bool inQuotedString = false;
- int commentLevel = 0;
- bool stop = false;
-
- for ( char* p = address.data(); *p && !stop; ++p ) {
- switch ( context ) {
- case TopLevel : {
- switch ( *p ) {
- case '"' : inQuotedString = !inQuotedString;
- displayName += *p;
- break;
- case '(' : if ( !inQuotedString ) {
- context = InComment;
- commentLevel = 1;
- }
- else
- displayName += *p;
- break;
- case '<' : if ( !inQuotedString ) {
- context = InAngleAddress;
- }
- else
- displayName += *p;
- break;
- case '\\' : // quoted character
- displayName += *p;
- ++p; // skip the '\'
- if ( *p )
- displayName += *p;
- else
- //return KPIM::UnexpectedEnd;
- goto ABORT_PARSING;
- break;
- case ',' : if ( !inQuotedString ) {
- //if ( allowMultipleAddresses )
- // stop = true;
- //else
- // return KPIM::UnexpectedComma;
- goto ABORT_PARSING;
- }
- else
- displayName += *p;
- break;
- default : displayName += *p;
- }
- break;
- }
- case InComment : {
- switch ( *p ) {
- case '(' : ++commentLevel;
- comment += *p;
- break;
- case ')' : --commentLevel;
- if ( commentLevel == 0 ) {
- context = TopLevel;
- comment += ' '; // separate the text of several comments
- }
- else
- comment += *p;
- break;
- case '\\' : // quoted character
- comment += *p;
- ++p; // skip the '\'
- if ( *p )
- comment += *p;
- else
- //return KPIM::UnexpectedEnd;
- goto ABORT_PARSING;
- break;
- default : comment += *p;
- }
- break;
- }
- case InAngleAddress : {
- switch ( *p ) {
- case '"' : inQuotedString = !inQuotedString;
- addrSpec += *p;
- break;
- case '>' : if ( !inQuotedString ) {
- context = TopLevel;
- }
- else
- addrSpec += *p;
- break;
- case '\\' : // quoted character
- addrSpec += *p;
- ++p; // skip the '\'
- if ( *p )
- addrSpec += *p;
- else
- //return KPIM::UnexpectedEnd;
- goto ABORT_PARSING;
- break;
- default : addrSpec += *p;
- }
- break;
- }
- } // switch ( context )
- }
-
-ABORT_PARSING:
- displayName = displayName.trimmed();
- comment = comment.trimmed();
- addrSpec = addrSpec.trimmed();
-
- fullName = QString::fromUtf8( displayName );
- email = QString::fromUtf8( addrSpec );
-
- // check for errors
- if ( inQuotedString )
- return; // KPIM::UnbalancedQuote;
- if ( context == InComment )
- return; // KPIM::UnbalancedParens;
- if ( context == InAngleAddress )
- return; // KPIM::UnclosedAngleAddr;
-
- if ( addrSpec.isEmpty() ) {
- if ( displayName.isEmpty() )
- return; // KPIM::NoAddressSpec;
- else {
- //addrSpec = displayName;
- //displayName.truncate( 0 );
- // Address of the form "foo@bar" or "foo@bar (Name)".
- email = fullName;
- fullName = QString::fromUtf8( comment );
- }
- }
-
- email = email.toLower();
- // Check that we do not have any extra characters on the end of the
- // strings
- unsigned int len = fullName.length();
- if ( fullName[ 0 ] == QLatin1Char( '"' ) && fullName[ len - 1 ] == QLatin1Char( \
'"' ) ) {
- fullName = fullName.mid( 1, len - 2 );
- }
-}
-
-#ifndef KDEPIM_NO_KRESOURCES
-void Addressee::setResource( Resource *resource )
-{
- d->mResource = resource;
-}
-
-Resource *Addressee::resource() const
-{
- return d->mResource;
-}
-#endif
-
-void Addressee::setChanged( bool value )
-{
- d->mChanged = value;
-}
-
-bool Addressee::changed() const
-{
- return d->mChanged;
-}
-
-void Addressee::setSortMode( KABC::SortMode *mode )
-{
- Private::mSortMode = mode;
-}
-
-bool Addressee::operator< ( const Addressee &addr ) const
-{
- if ( !Private::mSortMode )
- return false;
- else
- return Private::mSortMode->lesser( *this, addr );
-}
-
-QString Addressee::mimeType()
-{
- return QLatin1String( "text/directory" );
-}
-
-QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
-{
- s << a.d->mUid;
-
- --STREAMOUT--
- s << a.d->mPhoneNumbers;
- s << a.d->mAddresses;
- s << a.d->mEmails;
- s << a.d->mCategories;
- s << a.d->mCustom;
- s << a.d->mKeys;
- return s;
-}
-
-QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
-{
- s >> a.d->mUid;
-
- --STREAMIN--
- s >> a.d->mPhoneNumbers;
- s >> a.d->mAddresses;
- s >> a.d->mEmails;
- s >> a.d->mCategories;
- s >> a.d->mCustom;
- s >> a.d->mKeys;
-
- a.d->mEmpty = 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 ) );
-}
-
-template <class L>
-bool listEquals( const QList<L> &list, const QList<L> &pattern )
-{
- if ( list.count() != pattern.count() )
- return false;
- const int numberOfElement( list.count() );
- for ( int i = 0; i < numberOfElement; ++i ) {
- if ( !pattern.contains( list[ i ] ) ) {
- return false;
- }
- }
-
- return true;
-}
-
-bool listEquals( const QStringList &list, const QStringList &pattern )
-{
- if ( list.count() != pattern.count() )
- return false;
-
- const int numberOfElement( list.count() );
- for ( int i = 0; i < numberOfElement; ++i ) {
- if ( !pattern.contains( list[ i ] ) ) {
- return false;
- }
- }
-
- return true;
-}
-
-bool emailsEquals( const QStringList &list, const QStringList &pattern )
-{
- if ( list.count() != pattern.count() )
- return false;
-
- if ( list.isEmpty() )
- return true;
-
- if ( list.first() != pattern.first() )
- return false;
-
- QStringList::ConstIterator it;
- QStringList::ConstIterator end( list.constEnd() );
- for ( it = list.constBegin(); it != end; ++it ) {
- if ( !pattern.contains( *it ) ) {
- return false;
- }
- }
-
- return true;
-}
diff --git a/kabc/scripts/addressee.src.h b/kabc/scripts/addressee.src.h
deleted file mode 100644
index db438e3..0000000
--- a/kabc/scripts/addressee.src.h
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- 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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KABC_ADDRESSEE_SRC_H
-#define KABC_ADDRESSEE_SRC_H
-
-#include <QtCore/QDateTime>
-#include <QtCore/QStringList>
-#include <QtCore/QSharedDataPointer>
-
-#include <kurl.h>
-
-#include "kabc/address.h"
-#include "kabc/geo.h"
-#include "kabc/key.h"
-#include "kabc/phonenumber.h"
-#include "kabc/picture.h"
-#include "kabc/secrecy.h"
-#include "kabc/sound.h"
-#include "kabc/timezone.h"
-#include "kabc/addresseelist.h" // for typedef QList<Addressee> List;
-
-namespace KABC {
-
-#ifndef KDEPIM_NO_KRESOURCES
-class Resource;
-#endif
-class SortMode;
-
-/**
- @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 KABC_EXPORT Addressee
-{
- friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Addressee & );
- friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Addressee & );
-
- public:
- /**
- A list of addressee objects
- */
- typedef AddresseeList List;
- /**
- A map from unique identifier to addressee.
-
- @see uid()
- */
- typedef QMap<QString, Addressee> Map;
-
- /**
- Construct an empty address book entry.
- */
- Addressee();
-
- /**
- Destroys the address book entry.
- */
- ~Addressee();
-
- /**
- Copy constructor.
- */
- Addressee( const Addressee & );
-
- /**
- Assignment operator.
-
- @return a reference to @c this
- */
- Addressee &operator=( const Addressee & );
-
- /**
- Equality operator.
-
- @return @c true if @c this and the given addressee are equal,
- otherwise @c false
- */
- bool operator==( const Addressee & ) const;
-
- /**
- Not-equal operator.
-
- @return @c true if @c this and the given addressee are not equal,
- otherwise @c false
- */
- bool operator!=( const Addressee & ) const;
-
- /**
- Return, if the address book entry is empty.
- */
- bool isEmpty() const;
-
- /**
- Set unique identifier.
-
- @param uid the KABC unique identifier
- */
- void setUid( const QString &uid );
- /**
- Return unique identifier.
- */
- QString uid() const;
- /**
- Return translated label for uid field.
- */
- static QString uidLabel();
-
- --DECLARATIONS--
- /**
- 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() the preferred email address is used.
- */
- QString fullEmail( const QString &email=QString() ) 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.
-
- @param email Email address to remove
- */
- void removeEmail( const QString &email );
-
- /**
- Return preferred email address. This is the first email address or the
- last one added with insertEmail() with a set preferred parameter.
- */
- QString preferredEmail() const;
-
- /**
- Return list of all email addresses.
- */
- QStringList emails() const;
-
- /**
- Set the emails to @p list.
- 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.
-
- @param phoneNumber The telephone number to insert to the addressee
- */
- void insertPhoneNumber( const PhoneNumber &phoneNumber );
-
- /**
- Remove phone number. If no phone number with the given id exists for this
- addresse nothing happens.
-
- @param phoneNumber The telephone number to remove from the addressee
- */
- void removePhoneNumber( const PhoneNumber &phoneNumber );
-
- /**
- Return phone number, which matches the given type.
-
- @param type The type of phone number to get
- */
- PhoneNumber phoneNumber( PhoneNumber::Type type ) const;
-
- /**
- Return list of all phone numbers.
- */
- PhoneNumber::List phoneNumbers() const;
-
- /**
- Return list of phone numbers with a special type.
-
- @param type The type of phone number to get
- */
- PhoneNumber::List phoneNumbers( PhoneNumber::Type type ) const;
-
- /**
- Return phone number with the given id.
-
- @param id The identifier of the phone number to look for.
- See PhoneNumber::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.
-
- @param key The key to insert
- */
- void insertKey( const Key &key );
-
- /**
- Remove a key. If no key with the given id exists for this
- addresse nothing happens.
-
- @param key The key to remove
- */
- 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.
-
- @param type The type of key to look for
- @param customTypeString A string to match custom keys against when
- @p type is @c Key::Custom
- */
- Key key( Key::Type type, QString customTypeString = QString() ) 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.
-
- @param type The type of key to look for
- @param customTypeString A string to match custom keys against when
- @p type is @c Key::Custom
- */
- Key::List keys( Key::Type type, QString customTypeString = QString() ) const;
-
- /**
- Return key with the given id.
-
- @param id The identifier of the key to look for. See Key::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.
-
- @param address The address to insert
- */
- void insertAddress( const Address &address );
-
- /**
- Remove address. If no address with the given id exists for this
- addresse nothing happens.
-
- @param address The address to remove
- */
- void removeAddress( const Address &address );
-
- /**
- Return address, which matches the given type.
-
- @param type The type of address to look for
- */
- Address address( Address::Type type ) const;
-
- /**
- Return list of all addresses.
- */
- Address::List addresses() const;
-
- /**
- Return list of addresses with a special type.
-
- @param type The type of addresses to look for
- */
- Address::List addresses( Address::Type type ) const;
-
- /**
- Return address with the given id.
-
- @param id The identifier of the address to look for. See Address::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.
-
- An empty value isn't allowed (nothing happens if this is called with
- any of the three arguments being empty)
-
- @param app Name of the application inserting this custom entry
- @param name Name of this application specific custom entry
- @param value Value of this application specific custom entry
- */
- void insertCustom( const QString &app, const QString &name,
- const QString &value );
-
- /**
- Remove custom entry.
-
- @param app Name of the application which has inserted this custom entry
- @param name Name of this application specific custom entry
- */
- void removeCustom( const QString &app, const QString &name );
-
- /**
- Return value of custom entry, identified by app and entry name.
-
- @param app Name of the application which has inserted this custom entry
- @param name Name of this application specific custom entry
- */
- 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.
-
- @param rawEmail The input string to parse for name and email
- @param fullName The name part of the @p rawEmail input, if it contained one
- @param email The email part of the @p rawEmail input, if it contained one
- */
- static void parseEmailAddress( const QString &rawEmail, QString &fullName,
- QString &email );
-
- /**
- Returns string representation of the addressee.
- */
- QString toString() const;
-
-#ifndef KDEPIM_NO_KRESOURCES
- /**
- Set resource where the addressee is from.
-
- @param resource The Resource the addressee is from
- */
- void setResource( Resource *resource );
-
- /**
- Return pointer to resource.
- */
- Resource *resource() const;
-#endif
-
- /**
- Mark addressee as changed.
-
- @param value Sets the status indicating changed data
- */
- void setChanged( bool value );
-
- /**
- Return whether the addressee is changed.
- */
- bool changed() const;
-
- /**
- Sets the sort mode implementation.
-
- Comparing to addressee objects is delegated to an instance
- of a subclass of KABC::SortMode.
-
- @param mode The sort mode implementator to use
- */
- static void setSortMode( KABC::SortMode *mode );
-
- /**
- Return whether this addressee is "less-than" a given one
-
- @param addr The addressee object to compare with
-
- @see setSortMode()
- */
- bool operator< ( const Addressee &addr ) const;
-
- /**
- Returns the MIME type used for Addressees
- */
- static QString mimeType();
-
- private:
- class Private;
- QSharedDataPointer<Private> d;
-};
-#ifdef MAKE_KABC_LIB
-KDE_DUMMY_QHASH_FUNCTION( Addressee )
-#endif
-
-KABC_EXPORT QDataStream &operator<<( QDataStream &, const Addressee & );
-KABC_EXPORT QDataStream &operator>>( QDataStream &, Addressee & );
-
-}
-
-#define KABC_ADDRESSEE_METATYPE_DEFINED 1
-Q_DECLARE_METATYPE( KABC::Addressee )
-
-#endif
diff --git a/kabc/scripts/createisomap.pl b/kabc/scripts/createisomap.pl
deleted file mode 100755
index 2726e20..0000000
--- a/kabc/scripts/createisomap.pl
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/perl
-#
-# Create a translation table countryname->iso-code from the entry.desktop
-# files in kdebase/l10n/*/
-#
-# USAGE EXAMPLE:
-# ./createisomap.pl $KDEDIR/share/locale/l10n > countrytransl.map
-#
-# Don't laugh at me. I put this together with an old perl book, perl
-# being a language I've never used before.
-
-@entries = <$ARGV[0]/*/entry.desktop>;
-chomp @entries;
-foreach $entry (@entries) {
- local ( $entryiso, @entryfile, @mappings );
- # print "--> $entry\n";
- $entryiso = $entry;
- $entryiso =~ s/$ARGV[0]\///;
- $entryiso =~ s/\/entry\.desktop//;
- # print " $entryiso\n";
- open (IN, $entry);
- @entryfile = <IN>;
- close IN;
- chomp @entryfile;
- foreach $entryfileline (@entryfile) {
- if ( $entryfileline =~ /^Name.*=(.*)$/ ) {
- # push (@mappings, $1 . "\t" . $entryiso );
- print "$1\t$entryiso\n";
- }
- }
-}
-
diff --git a/kabc/scripts/doxygen-preprocess-addressee.sh \
b/kabc/scripts/doxygen-preprocess-addressee.sh deleted file mode 100755
index a4cfc24..0000000
--- a/kabc/scripts/doxygen-preprocess-addressee.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-if test "$1" = "create"; then
- ./makeaddressee
-elif test "$1" = "cleanup"; then
- rm -f ../addressee.h ../addressee.cpp ../field.cpp
-fi
diff --git a/kabc/scripts/entrylist b/kabc/scripts/entrylist
deleted file mode 100644
index 328512d..0000000
--- a/kabc/scripts/entrylist
+++ /dev/null
@@ -1,83 +0,0 @@
-# This file describes the fields of an address book entry.
-#
-# The following comma-separated fields are used:
-#
-# Control: A generates accessor functions.
-# L generates a static function for returning a tranlsated label
-# F generates a Field id and object for generic field handling
-# E generate an equality test in Addressee::operator==().
-# Field Name : A descriptive name which is shown to the user.
-# Comment : A comment helping translators to understand the field name
-# Type : C++ type of field.
-# Identifier : A string used in code as variable name etc.
-# Field Category : Categories the field belongs to (see Field::FieldCategory).
-# Output function: Function used to convert type to string for debug output \
(optional)
-
-ALE,name,,QString,name
-
-ALFE,formatted name,,QString,formattedName,Frequent
-
-ALFE,family name,,QString,familyName,Frequent
-ALFE,given name,,QString,givenName,Frequent
-ALFE,additional names,,QString,additionalName
-ALFE,honorific prefixes,,QString,prefix
-ALFE,honorific suffixes,,QString,suffix
-
-ALFE,nick name,,QString,nickName,Personal
-
-ALFE,birthday,,QDateTime,birthday,Personal,.toString()
-
-#Address address
-LF,home address street,,QString,homeAddressStreet,Address|Personal
-LF,home address post office box,,QString,homeAddressPostOfficeBox,Address|Personal
-LF,home address city,,QString,homeAddressLocality,Address|Personal
-LF,home address state,,QString,homeAddressRegion,Address|Personal
-LF,home address zip code,,QString,homeAddressPostalCode,Address|Personal
-LF,home address country,,QString,homeAddressCountry,Address|Personal
-LF,home address label,,QString,homeAddressLabel,Address|Personal
-
-LF,business address street,,QString,businessAddressStreet,Address|Organization
-LF,business address post office \
box,,QString,businessAddressPostOfficeBox,Address|Organization
-LF,business address city,,QString,businessAddressLocality,Address|Organization
-LF,business address state,,QString,businessAddressRegion,Address|Organization
-LF,business address zip code,,QString,businessAddressPostalCode,Address|Organization
-LF,business address country,,QString,businessAddressCountry,Address|Organization
-LF,business address label,,QString,businessAddressLabel,Address|Organization
-
-#phoneNumbers
-LF,home phone,,QString,homePhone,Personal|Frequent
-LF,business phone,,QString,businessPhone,Organization|Frequent
-LF,mobile phone,,QString,mobilePhone,Frequent
-LF,home fax,,QString,homeFax
-LF,business fax,,QString,businessFax
-LF,car phone,,QString,carPhone
-LF,ISDN,,QString,isdn
-LF,pager,,QString,pager
-
-#emails
-LF,email address,,QString,email,Email|Frequent
-
-ALFE,mail client,,QString,mailer,Email
-
-ALE,time zone,,TimeZone,timeZone,,.toString()
-ALE,geographic position,,Geo,geo,,.toString()
-
-ALFE,title,a person's title,QString,title,Organization
-ALFE,role,of a person in an organization,QString,role,Organization
-ALFE,organization,,QString,organization,Organization
-ALFE,department,,QString,department,Organization
-
-ALFE,note,,QString,note
-
-ALE,product identifier,,QString,productId
-ALE,revision date,,QDateTime,revision,,.toString()
-
-ALE,sort string,,QString,sortString
-
-ALF,homepage,,KUrl,url,,.url()
-
-ALE,security class,,Secrecy,secrecy,,.toString()
-
-ALE,logo,,Picture,logo,,.toString()
-ALE,photo,,Picture,photo,,.toString()
-ALE,sound,,Sound,sound,,.toString()
diff --git a/kabc/scripts/field.src.cpp b/kabc/scripts/field.src.cpp
deleted file mode 100644
index 58e0845..0000000
--- a/kabc/scripts/field.src.cpp
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- 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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <klocale.h>
-#include <klocalizedstring.h>
-#include <kconfig.h>
-#include <kglobal.h>
-#include <kconfiggroup.h>
-
-#include "field.h"
-
-using namespace KABC;
-
-class Field::Private
-{
- public:
- Private( int fieldId, int category = 0,
- const QString &label = QString(),
- const QString &key = QString(),
- const QString &app = QString() )
- : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
- mKey( key ), mApp( app ) {}
-
- enum FieldId
- {
- CustomField,
- --ENUMS--
- };
-
- int fieldId() { return mFieldId; }
- int category() { return mCategory; }
-
- QString label() { return mLabel; }
- QString key() { return mKey; }
- QString app() { return mApp; }
-
- static Field::List mAllFields;
- static Field::List mDefaultFields;
- static Field::List mCustomFields;
-
- private:
- int mFieldId;
- int mCategory;
-
- QString mLabel;
- QString mKey;
- QString mApp;
-};
-
-Field::List Field::Private::mAllFields;
-Field::List Field::Private::mDefaultFields;
-Field::List Field::Private::mCustomFields;
-
-Field::Field( Private *p )
- : d( p )
-{
-}
-
-Field::~Field()
-{
- delete d;
-}
-
-QString Field::label()
-{
- switch ( d->fieldId() ) {
- --CASELABEL--
- case Private::CustomField:
- return d->label();
- default:
- return i18n( "Unknown Field" );
- }
-}
-
-int Field::category()
-{
- return d->category();
-}
-
-QString Field::categoryLabel( int category )
-{
- switch ( category ) {
- case All:
- return i18n( "All" );
- case Frequent:
- return i18n( "Frequent" );
- case Address:
- return i18nc( "street/postal","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 ( d->fieldId() ) {
- --CASEVALUE--
- case Private::Email:
- return a.preferredEmail();
- case Private::Birthday:
- if ( a.birthday().isValid() )
- return a.birthday().date().toString( Qt::ISODate );
- else
- return QString();
- case Private::Url:
- return a.url().prettyUrl();
- case Private::HomePhone:
- {
- PhoneNumber::List::ConstIterator it;
-
- {
- // check for preferred number
- const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Home | \
PhoneNumber::Pref );
- for ( it = list.begin(); it != list.end(); ++it ) {
- if ( ( ( *it ).type() & ~( PhoneNumber::Pref ) ) == PhoneNumber::Home ) {
- return ( *it ).number();
- }
- }
- }
-
- {
- // check for normal home number
- const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Home );
- for ( it = list.begin(); it != list.end(); ++it ) {
- if ( ( ( *it ).type() & ~(PhoneNumber::Pref) ) == PhoneNumber::Home ) {
- return ( *it ).number();
- }
- }
- }
-
- return QString();
- }
- case Private::BusinessPhone:
- {
- PhoneNumber::List::ConstIterator it;
-
- {
- // check for preferred number
- const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Work | \
PhoneNumber::Pref );
- for ( it = list.begin(); it != list.end(); ++it ) {
- if ( ( ( *it ).type() & ~(PhoneNumber::Pref) ) == PhoneNumber::Work ) {
- return ( *it ).number();
- }
- }
- }
-
- {
- // check for normal work number
- const PhoneNumber::List list = a.phoneNumbers( PhoneNumber::Work );
- for ( it = list.begin(); it != list.end(); ++it ) {
- if ( ( ( *it ).type() & ~(PhoneNumber::Pref) ) == PhoneNumber::Work ) {
- return ( *it ).number();
- }
- }
- }
-
- return QString();
- }
- case Private::MobilePhone:
- return a.phoneNumber( PhoneNumber::Cell ).number();
- case Private::HomeFax:
- return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
- case Private::BusinessFax:
- return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
- case Private::CarPhone:
- return a.phoneNumber( PhoneNumber::Car ).number();
- case Private::Isdn:
- return a.phoneNumber( PhoneNumber::Isdn ).number();
- case Private::Pager:
- return a.phoneNumber( PhoneNumber::Pager ).number();
- case Private::HomeAddressStreet:
- return a.address( Address::Home ).street();
- case Private::HomeAddressPostOfficeBox:
- return a.address( Address::Home ).postOfficeBox();
- case Private::HomeAddressLocality:
- return a.address( Address::Home ).locality();
- case Private::HomeAddressRegion:
- return a.address( Address::Home ).region();
- case Private::HomeAddressPostalCode:
- return a.address( Address::Home ).postalCode();
- case Private::HomeAddressCountry:
- return a.address( Address::Home ).country();
- case Private::BusinessAddressStreet:
- return a.address( Address::Work ).street();
- case Private::BusinessAddressPostOfficeBox:
- return a.address( Address::Work ).postOfficeBox();
- case Private::BusinessAddressLocality:
- return a.address( Address::Work ).locality();
- case Private::BusinessAddressRegion:
- return a.address( Address::Work ).region();
- case Private::BusinessAddressPostalCode:
- return a.address( Address::Work ).postalCode();
- case Private::BusinessAddressCountry:
- return a.address( Address::Work ).country();
- case Private::CustomField:
- return a.custom( d->app(), d->key() );
- default:
- return QString();
- }
-}
-
-bool Field::setValue( KABC::Addressee &a, const QString &value )
-{
- switch ( d->fieldId() ) {
- --CASESETVALUE--
- case Private::Birthday:
- a.setBirthday( QDateTime::fromString( value, Qt::ISODate ) );
- return true;
- case Private::CustomField:
- a.insertCustom( d->app(), d->key(), value );
- return true;
- default:
- return false;
- }
-}
-
-QString Field::sortKey( const KABC::Addressee &a )
-{
- switch ( d->fieldId() ) {
- --CASEVALUE--
- case Private::Birthday:
- if ( a.birthday().isValid() ) {
- QDate date = a.birthday().date();
- QString key;
- key.sprintf( "%02d-%02d", date.month(), date.day() );
- return key;
- } else
- return QLatin1String( "00-00" );
- default:
- return value( a ).toLower();
- }
-}
-
-bool Field::isCustom()
-{
- return d->fieldId() == Private::CustomField;
-}
-
-Field::List Field::allFields()
-{
- if ( Private::mAllFields.isEmpty() ) {
- --CREATEFIELDS--
- }
-
- return Private::mAllFields;
-}
-
-Field::List Field::defaultFields()
-{
- if ( Private::mDefaultFields.isEmpty() ) {
- createDefaultField( Private::FormattedName );
- createDefaultField( Private::Email );
- }
-
- return Private::mDefaultFields;
-}
-
-void Field::createField( int id, int category )
-{
- Private::mAllFields.append( new Field( new Private( id, category ) ) );
-}
-
-void Field::createDefaultField( int id, int category )
-{
- Private::mDefaultFields.append( new Field( new Private( id, category ) ) );
-}
-
-void Field::deleteFields()
-{
- Field::List::ConstIterator it;
-
- for ( it = Private::mAllFields.constBegin(); it != Private::mAllFields.constEnd(); \
++it ) {
- delete ( *it );
- }
- Private::mAllFields.clear();
-
- for ( it = Private::mDefaultFields.constBegin(); it != \
Private::mDefaultFields.constEnd(); ++it ) {
- delete ( *it );
- }
- Private::mDefaultFields.clear();
-
- for ( it = Private::mCustomFields.constBegin(); it != \
Private::mCustomFields.constEnd(); ++it ) {
- delete ( *it );
- }
- Private::mCustomFields.clear();
-}
-
-void Field::saveFields( const QString &identifier,
- const Field::List &fields )
-{
- KConfigGroup cg( KGlobal::config(), "KABCFields" );
-
- saveFields( cg, identifier, fields );
-}
-
-void Field::saveFields( KConfigGroup &cfg, const QString &identifier,
- const Field::List &fields )
-{
- QList<int> fieldIds;
-
- int custom = 0;
- Field::List::ConstIterator it;
- for ( it = fields.begin(); it != fields.end(); ++it ) {
- fieldIds.append( ( *it )->d->fieldId() );
- if ( ( *it )->isCustom() ) {
- QStringList customEntry;
- customEntry << ( *it )->d->label();
- customEntry << ( *it )->d->key();
- customEntry << ( *it )->d->app();
- cfg.writeEntry( QLatin1String( "KABC_CustomEntry_" ) + identifier + \
QLatin1Char( '_' ) +
- QString::number( custom++ ), customEntry );
- }
- }
-
- cfg.writeEntry( identifier, fieldIds );
-}
-
-Field::List Field::restoreFields( const QString &identifier )
-{
- KConfigGroup cg( KGlobal::config(), "KABCFields" );
-
- return restoreFields( cg, identifier );
-}
-
-Field::List Field::restoreFields( const KConfigGroup &cfg, const QString &identifier \
)
-{
- const QList<int> fieldIds = cfg.readEntry( identifier,QList<int>() );
-
- Field::List fields;
-
- int custom = 0;
- QList<int>::ConstIterator it;
- for ( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
- Private *f = 0;
- if ( ( *it ) == Private::CustomField ) {
- QStringList customEntry = cfg.readEntry( QLatin1String( "KABC_CustomEntry_" ) \
+
- identifier + QLatin1Char( '_' ) +
- QString::number( custom++ \
),QStringList() );
- f = new Private( *it, CustomCategory, customEntry[ 0 ],
- customEntry[ 1 ], customEntry[ 2 ] );
- } else {
- f = new Private( *it );
- }
- fields.append( new Field( f ) );
- }
-
- return fields;
-}
-
-bool Field::equals( Field *field )
-{
- bool sameId = ( d->fieldId() == field->d->fieldId() );
-
- if ( !sameId ) return false;
-
- if ( d->fieldId() != Private::CustomField ) return true;
-
- return d->key() == field->d->key();
-}
-
-Field *Field::createCustomField( const QString &label, int category,
- const QString &key, const QString &app )
-{
- Field *field = new Field( new Private( Private::CustomField,
- category | CustomCategory,
- label, key, app ) );
- Private::mCustomFields.append( field );
-
- return field;
-}
diff --git a/kabc/scripts/makeaddressee b/kabc/scripts/makeaddressee
deleted file mode 100755
index d8c8f5b..0000000
--- a/kabc/scripts/makeaddressee
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/usr/bin/perl
-use Cwd;
-use File::Basename;
-
-my $srcdir;
-my $builddir = cwd();
-$srcdir = dirname($0) || die "Can't determine \$srcdir.";
-chomp $srcdir;
-
-chdir $srcdir;
-
-if (!open( ENTRIES, "$srcdir/entrylist" ) ) {
- print "Can't open $srcdir/entrylist\n";
- exit 1;
-}
-
- while(<ENTRIES>) {
- if (/^#/) { next; }
- chop;
- @entries = split /,/;
- if (!/^.+,(\w+),(\w+)/) { next; }
- push @entryCtrl, @entries[0];
- push @entryRealNames, @entries[1];
- push @entryComments, @entries[2];
- push @entryTypes, @entries[3];
- push @entryNames, @entries[4];
- push @entryCategory, @entries[5];
- push @entryDebug, @entries[6];
- }
-
-close ENTRIES;
-
-if (!open( H_IN, "$srcdir/addressee.src.h" ) ) {
- print "Can't open $srcdir/addressee.src.h\n";
- exit 1;
-}
-if (!open( H_OUT, ">$builddir/../addressee.h" ) ) {
- print "Can't open addressee.h\n";
- exit 1;
-}
- print H_OUT "/*** Warning! This file has been generated by the script \
makeaddressee ***/\n";
-
- while( <H_IN> ) {
- if (/--DECLARATIONS--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] =~ /A/ ) {
- print H_OUT " /**\n";
- print H_OUT " Set $entryRealNames[$i].\n";
- print H_OUT " */\n";
- print H_OUT " void set" . ucfirst($entryNames[$i]);
- print H_OUT "( const $entryTypes[$i] &$entryNames[$i] );\n";
-
- print H_OUT " /**\n";
- print H_OUT " Return $entryRealNames[$i].\n";
- print H_OUT " */\n";
- print H_OUT " $entryTypes[$i] $entryNames[$i]() const;\n";
- }
-
- if ( $entryCtrl[$i] !~ /L/ ) { next; }
- print H_OUT " /**\n";
- print H_OUT " Return translated label for $entryNames[$i] field.\n";
- print H_OUT " */\n";
- print H_OUT " static QString $entryNames[$i]Label();\n\n";
- }
- } else {
- print H_OUT;
- }
- }
-
-close H_OUT;
-close H_IN;
-
-if (!open( CPP_IN, "$srcdir/addressee.src.cpp" ) ) {
- print "Can't open $srcdir/addressee.src.cpp\n";
- exit 1;
-}
-if (!open( CPP_OUT, ">$builddir/../addressee.cpp" ) ) {
- print "Can't open addressee.cpp\n";
- exit 1;
-}
- print CPP_OUT "/*** Warning! This file has been generated by the script \
makeaddressee ***/\n";
-
- while( <CPP_IN> ) {
- if (/--VARIABLES--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /A/ ) { next; }
- print CPP_OUT " $entryTypes[$i] m".ucfirst($entryNames[$i]).";\n";
- }
- } elsif (/--VARIABLES_ASSIGNMENT--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /A/ ) { next; }
- print CPP_OUT " m".ucfirst($entryNames[$i])." = \
other.m".ucfirst($entryNames[$i]).";\n";
- }
- } elsif (/--DEFINITIONS--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] =~ /A/ ) {
- print CPP_OUT "void Addressee::set" . ucfirst($entryNames[$i]);
- print CPP_OUT "( const $entryTypes[$i] &$entryNames[$i] )\n{\n";
- print CPP_OUT " if ( $entryNames[$i] == d->m".ucfirst($entryNames[$i])." \
) return;\n";
- print CPP_OUT " d->mEmpty = false;\n";
- print CPP_OUT " d->m".ucfirst($entryNames[$i])." = \
$entryNames[$i];\n}\n\n";
- print CPP_OUT "$entryTypes[$i] Addressee::$entryNames[$i]() const\n{\n";
- print CPP_OUT " return d->m".ucfirst($entryNames[$i]).";\n}\n\n";
- }
-
- if ( $entryCtrl[$i] !~ /L/ ) { next; }
- @labelwords = split ' ', $entryRealNames[$i];
- for( $j=0; $j < @labelwords; ++$j ) {
- $labelwords[$j] = ucfirst $labelwords[$j];
- }
- $label = join ' ', @labelwords;
- print CPP_OUT "QString Addressee::$entryNames[$i]Label()\n{\n";
- if ( $entryComments[$i] ) {
- print CPP_OUT " return i18nc(\"$entryComments[$i]\",\"$label\");\n";
- } else {
- print CPP_OUT " return i18n(\"$label\");\n";
- }
- print CPP_OUT "}\n\n\n";
- }
- } elsif (/--EQUALSTEST--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] =~ /E/ ) {
- if ( $entryNames[$i] !~ "revision" ) {
- if ( $entryTypes[$i] =~ "QString" ) {
- print CPP_OUT " if ( d->m".ucfirst($entryNames[$i])." != \
a.d->m".ucfirst($entryNames[$i])." &&\n";
- print CPP_OUT " !( d->m".ucfirst($entryNames[$i]).".isEmpty() && \
a.d->m".ucfirst($entryNames[$i]).".isEmpty() ) ) {\n";
- print CPP_OUT " kDebug(5700) << \"$entryNames[$i] differs\";\n";
- print CPP_OUT " return false;\n";
- print CPP_OUT " }\n";
- } else {
- print CPP_OUT " if ( d->m".ucfirst($entryNames[$i])." != \
a.d->m".ucfirst($entryNames[$i])." ) {\n";
- print CPP_OUT " kDebug(5700) << \"$entryNames[$i] differs\";\n";
- print CPP_OUT " return false;\n";
- print CPP_OUT " }\n";
- }
- }
- }
- }
- } elsif (/--STREAMOUT--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] =~ /A/ ) {
- print CPP_OUT " s << a.d->m".ucfirst($entryNames[$i]).";\n";
- }
- }
- } elsif (/--STREAMIN--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] =~ /A/ ) {
- print CPP_OUT " s >> a.d->m".ucfirst($entryNames[$i]).";\n";
- }
- }
- } elsif (/--DEBUG--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /A/ ) { next; }
- print CPP_OUT " str += QString::fromLatin1( \" " . \
ucfirst($entryNames[$i]);
- print CPP_OUT ": %1\\n\" ).arg( $entryNames[$i]()$entryDebug[$i] );\n";
- }
- } else {
- print CPP_OUT;
- }
- }
-
-close CPP_OUT;
-close CPP_IN;
-
-if (!open( CPP_IN, "$srcdir/field.src.cpp" ) ) {
- print "Can't open $srcdir/field.src.cpp\n";
- exit 1;
-}
-if (!open( CPP_OUT, ">$builddir/../field.cpp" ) ) {
- print "Can't open field.cpp\n";
- exit 1;
-}
- print CPP_OUT "/*** Warning! This file has been generated by the script \
makeaddressee ***/\n";
-
- while( <CPP_IN> ) {
- if (/--ENUMS--/) {
- $first = 1;
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /F/ ) { next; }
- if ( $first ) { $first = 0; }
- else { print CPP_OUT ",\n"; }
- print CPP_OUT " " . ucfirst($entryNames[$i]);
- }
- print CPP_OUT "\n";
- } elsif (/--CASELABEL--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /F/ ) { next; }
- if ( $entryCtrl[$i] !~ /L/ ) { next; }
- print CPP_OUT " case Private::" . ucfirst($entryNames[$i]) . ":\n";
- print CPP_OUT " return Addressee::$entryNames[$i]Label();\n";
- }
- } elsif (/--CASEVALUE--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /A/ ) { next; }
- if ( $entryCtrl[$i] !~ /F/ ) { next; }
- if ( $entryTypes[$i] ne "QString" ) { next; }
- print CPP_OUT " case Private::" . ucfirst($entryNames[$i]) . ":\n";
- print CPP_OUT " return a.$entryNames[$i]();\n";
- }
- } elsif (/--CASESETVALUE--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /A/ ) { next; }
- if ( $entryCtrl[$i] !~ /F/ ) { next; }
- if ( $entryTypes[$i] ne "QString" ) { next; }
- print CPP_OUT " case Private::" . ucfirst($entryNames[$i]) . ":\n";
- print CPP_OUT " a.set" . ucfirst($entryNames[$i]) . "( value );\n";
- print CPP_OUT " return true;\n";
- }
- } elsif (/--CREATEFIELDS--/) {
- for( $i=0; $i<@entryNames; ++$i ) {
- if ( $entryCtrl[$i] !~ /F/ ) { next; }
- print CPP_OUT " createField( Private::" . ucfirst($entryNames[$i]);
- if ( $entryCategory[$i] ) {
- print CPP_OUT ", $entryCategory[$i]";
- }
- print CPP_OUT " );\n";
- }
- } else {
- print CPP_OUT;
- }
- }
-
-close CPP_OUT;
-close CPP_IN;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic