kabc
testutils.cpp
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2007 KDE-PIM team <kde-pim@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include <QtCore/QFile> 00022 00023 #include <kabc/addressee.h> 00024 00025 #include "vcardparser.h" 00026 00027 using namespace KABC; 00028 00029 Addressee vcard1() 00030 { 00031 Addressee addr; 00032 00033 addr.setName( QLatin1String( "Frank Dawson" ) ); 00034 addr.setOrganization( QLatin1String( "Lotus Development Corporation" ) ); 00035 addr.setUrl( KUrl( QLatin1String( "http://home.earthlink.net/~fdawson" ) ) ); 00036 addr.insertEmail( QLatin1String( "fdawson@earthlink.net" ) ); 00037 addr.insertEmail( QLatin1String( "Frank_Dawson@Lotus.com" ), true ); 00038 addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-919-676-9515" ), 00039 PhoneNumber::Voice|PhoneNumber::Msg|PhoneNumber::Work ) ); 00040 addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-919-676-9564" ), 00041 PhoneNumber::Fax |PhoneNumber::Work ) ); 00042 Address a( Address::Work | Address::Postal | Address::Parcel ); 00043 a.setStreet( QLatin1String( "6544 Battleford Drive" ) ); 00044 a.setLocality( QLatin1String( "Raleigh" ) ); 00045 a.setRegion( QLatin1String( "NC" ) ); 00046 a.setPostalCode( QLatin1String( "27613-3502" ) ); 00047 a.setCountry( QLatin1String( "U.S.A." ) ); 00048 addr.insertAddress( a ); 00049 return addr; 00050 } 00051 00052 Addressee vcard2() 00053 { 00054 Addressee addr; 00055 00056 addr.setName( QLatin1String( "Tim Howes" ) ); 00057 addr.setOrganization( QLatin1String( "Netscape Communications Corp." ) ); 00058 addr.insertEmail( QLatin1String( "howes@netscape.com" ) ); 00059 addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-415-937-3419" ), 00060 PhoneNumber::Voice|PhoneNumber::Msg|PhoneNumber::Work ) ); 00061 addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-415-528-4164" ), 00062 PhoneNumber::Fax|PhoneNumber::Work ) ); 00063 Address a( Address::Work ); 00064 a.setStreet( QLatin1String( "501 E. Middlefield Rd." ) ); 00065 a.setLocality( QLatin1String( "Mountain View" ) ); 00066 a.setRegion( QLatin1String( "CA" ) ); 00067 a.setPostalCode( QLatin1String( "94043" ) ); 00068 a.setCountry( QLatin1String( "U.S.A." ) ); 00069 addr.insertAddress( a ); 00070 return addr; 00071 } 00072 00073 Addressee vcard3() 00074 { 00075 Addressee addr; 00076 00077 addr.setName( QLatin1String( "ian geiser" ) ); 00078 addr.setOrganization( QLatin1String( "Source eXtreme" ) ); 00079 addr.insertEmail( QLatin1String( "geiseri@yahoo.com" ) ); 00080 addr.setTitle( QLatin1String( "VP of Engineering" ) ); 00081 return addr; 00082 } 00083 00084 QByteArray vcardAsText( const QString &location ) 00085 { 00086 QByteArray text; 00087 00088 QFile file( location ); 00089 if ( file.open( QIODevice::ReadOnly ) ) { 00090 text = file.readAll(); 00091 file.close(); 00092 } 00093 00094 return text; 00095 } 00096 00097 Addressee::List vCardsAsAddresseeList() 00098 { 00099 Addressee::List l; 00100 00101 l.append( vcard1() ); 00102 l.append( vcard2() ); 00103 l.append( vcard3() ); 00104 00105 return l; 00106 } 00107 00108 QByteArray vCardsAsText() 00109 { 00110 QByteArray vcards = vcardAsText( QLatin1String( "tests/vcard1.vcf" ) ); 00111 vcards += vcardAsText( QLatin1String( "tests/vcard2.vcf" ) ); 00112 vcards += vcardAsText( QLatin1String( "tests/vcard3.vcf" ) ); 00113 00114 return vcards; 00115 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:20:25 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:20:25 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.