kitchensync

metaaddressbook.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002,2003 Holger Freyther <freyther@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "metaaddressbook.h"
00023 
00024 using namespace OpieHelper;
00025 
00026 MetaAddressbook::MetaAddressbook( KSync::AddressBookSyncee *async, const QString& file )
00027   : MD5Template<KSync::AddressBookSyncee, KSync::AddressBookSyncEntry>( async, file )
00028 {}
00029 
00030 MetaAddressbook::~MetaAddressbook()
00031 {}
00032 
00033 
00034 QString MetaAddressbook::entryToString( KSync::AddressBookSyncEntry* entry) {
00035     KABC::Addressee adr = entry->addressee();
00036 
00037     QString str;
00038     str = adr.givenName();
00039     str += adr.additionalName();
00040     str += adr.familyName();
00041     str += adr.suffix();
00042     str += adr.role();
00043     str += adr.organization();
00044 
00045 
00046     /*
00047      * busines numbers
00048      */
00049     KABC::PhoneNumber number = adr.phoneNumber( KABC::PhoneNumber::Work );
00050     str += number.number();
00051 
00052     number = adr.phoneNumber( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
00053     str += number.number();
00054 
00055     number = adr.phoneNumber( KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell );
00056     str += number.number();
00057 
00058     str += adr.preferredEmail();
00059     str += adr.emails().join(";");
00060 
00061     /*
00062      * home/private numbers
00063      */
00064     number = adr.phoneNumber( KABC::PhoneNumber::Home );
00065     str += number.number();
00066 
00067     number = adr.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
00068     str += number.number();
00069 
00070     number = adr.phoneNumber( KABC::PhoneNumber::Cell );
00071     str += number.number();
00072 
00073     /*
00074      * address bits
00075      */
00076     KABC::Address ad = adr.address( KABC::Address::Work );
00077     str += ad.street();
00078     str += ad.locality();
00079     str += ad.postalCode();
00080     str += ad.country();
00081     str += ad.region();
00082 
00083 
00084     /*
00085      * home address
00086      */
00087     ad = adr.address( KABC::Address::Home );
00088     str += ad.street();
00089     str += ad.locality();
00090     str += ad.region();
00091     str += ad.postalCode();
00092     str += ad.country();
00093 
00094     str += adr.custom( "KADDRESSBOOK", "X-Department" );
00095     str += adr.custom( "KADDRESSBOOK", "X-SpouseName" );
00096     str += adr.custom( "KADDRESSBOOK", "X-Office" );
00097     str += adr.custom( "KADDRESSBOOK", "X-Profession" );
00098     str += adr.custom( "KADDRESSBOOK", "AssistantsName" );
00099     str += adr.custom( "KADDRESSBOOK", "ManagersName" );
00100     str += adr.custom( "opie", "Children" );
00101     str += adr.custom( "opie", "HomeWebPage" );
00102     str += adr.custom( "opie", "Gender" );
00103 //    str += adr.custom( "opie", "Birthday" );
00104     str += adr.birthday().date().toString(Qt::ISODate);
00105     str += adr.custom( "KADDRESSBOOK", "X-Anniversary" );
00106 
00107     str += adr.note();
00108     str += adr.nickName();
00109     str += adr.categories().join(";");
00110 
00111 
00112     return str;
00113 }
KDE Home | KDE Accessibility Home | Description of Access Keys