• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • kabc
  • vcardparser
testutils.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2007 KDE-PIM team <kde-pim@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <QtCore/QFile>
22 
23 #include <kabc/addressee.h>
24 
25 #include "vcardparser.h"
26 
27 using namespace KABC;
28 
29 Addressee vcard1()
30 {
31  Addressee addr;
32 
33  addr.setName( QLatin1String( "Frank Dawson" ) );
34  addr.setOrganization( QLatin1String( "Lotus Development Corporation" ) );
35  addr.setUrl( KUrl( QLatin1String( "http://home.earthlink.net/~fdawson" ) ) );
36  addr.insertEmail( QLatin1String( "fdawson@earthlink.net" ) );
37  addr.insertEmail( QLatin1String( "Frank_Dawson@Lotus.com" ), true );
38  addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-919-676-9515" ),
39  PhoneNumber::Voice|PhoneNumber::Msg|PhoneNumber::Work ) );
40  addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-919-676-9564" ),
41  PhoneNumber::Fax |PhoneNumber::Work ) );
42  Address a( Address::Work | Address::Postal | Address::Parcel );
43  a.setStreet( QLatin1String( "6544 Battleford Drive" ) );
44  a.setLocality( QLatin1String( "Raleigh" ) );
45  a.setRegion( QLatin1String( "NC" ) );
46  a.setPostalCode( QLatin1String( "27613-3502" ) );
47  a.setCountry( QLatin1String( "U.S.A." ) );
48  addr.insertAddress( a );
49  return addr;
50 }
51 
52 Addressee vcard2()
53 {
54  Addressee addr;
55 
56  addr.setName( QLatin1String( "Tim Howes" ) );
57  addr.setOrganization( QLatin1String( "Netscape Communications Corp." ) );
58  addr.insertEmail( QLatin1String( "howes@netscape.com" ) );
59  addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-415-937-3419" ),
60  PhoneNumber::Voice|PhoneNumber::Msg|PhoneNumber::Work ) );
61  addr.insertPhoneNumber( PhoneNumber( QLatin1String( "+1-415-528-4164" ),
62  PhoneNumber::Fax|PhoneNumber::Work ) );
63  Address a( Address::Work );
64  a.setStreet( QLatin1String( "501 E. Middlefield Rd." ) );
65  a.setLocality( QLatin1String( "Mountain View" ) );
66  a.setRegion( QLatin1String( "CA" ) );
67  a.setPostalCode( QLatin1String( "94043" ) );
68  a.setCountry( QLatin1String( "U.S.A." ) );
69  addr.insertAddress( a );
70  return addr;
71 }
72 
73 Addressee vcard3()
74 {
75  Addressee addr;
76 
77  addr.setName( QLatin1String( "ian geiser" ) );
78  addr.setOrganization( QLatin1String( "Source eXtreme" ) );
79  addr.insertEmail( QLatin1String( "geiseri@yahoo.com" ) );
80  addr.setTitle( QLatin1String( "VP of Engineering" ) );
81  return addr;
82 }
83 
84 QByteArray vcardAsText( const QString &location )
85 {
86  QByteArray text;
87 
88  QFile file( location );
89  if ( file.open( QIODevice::ReadOnly ) ) {
90  text = file.readAll();
91  file.close();
92  }
93 
94  return text;
95 }
96 
97 Addressee::List vCardsAsAddresseeList()
98 {
99  Addressee::List l;
100 
101  l.append( vcard1() );
102  l.append( vcard2() );
103  l.append( vcard3() );
104 
105  return l;
106 }
107 
108 QByteArray vCardsAsText()
109 {
110  QByteArray vcards = vcardAsText( QLatin1String( "tests/vcard1.vcf" ) );
111  vcards += vcardAsText( QLatin1String( "tests/vcard2.vcf" ) );
112  vcards += vcardAsText( QLatin1String( "tests/vcard3.vcf" ) );
113 
114  return vcards;
115 }
KABC::Address
Postal address information.
Definition: address.h:37
KABC::PhoneNumber
Phonenumber information.
Definition: phonenumber.h:38
KABC::PhoneNumber::Voice
Voice.
Definition: phonenumber.h:52
KABC::Addressee::insertEmail
void insertEmail(const QString &email, bool preferred=false)
Insert an email address.
Definition: addressee.cpp:1231
KABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.cpp:1276
KABC::AddresseeList
a QValueList of Addressee, with sorting functionality
Definition: addresseelist.h:288
KABC::PhoneNumber::Fax
Fax machine.
Definition: phonenumber.h:53
KABC::Address::Parcel
parcel
Definition: address.h:55
KABC::Address::Postal
postal
Definition: address.h:54
KABC::Addressee::setTitle
void setTitle(const QString &title)
Set title.
Definition: addressee.cpp:765
KABC::Addressee::setOrganization
void setOrganization(const QString &organization)
Set organization.
Definition: addressee.cpp:805
KABC::Addressee::setUrl
void setUrl(const KUrl &url)
Set homepage.
Definition: addressee.cpp:925
KABC::PhoneNumber::Msg
Messaging.
Definition: phonenumber.h:50
KABC::Addressee::setName
void setName(const QString &name)
Set name.
Definition: addressee.cpp:387
KABC::Addressee
address book entry
Definition: addressee.h:74
KABC::PhoneNumber::Work
Office number.
Definition: phonenumber.h:49
KABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.cpp:1512
KABC::Address::Work
address at work
Definition: address.h:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal