kabc
testutils.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }