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

kabc

  • kabc
  • vcardparser
testwrite.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 <kaboutdata.h>
24 #include <kapplication.h>
25 #include <kcmdlineargs.h>
26 
27 #include "kabc/addressee.h"
28 #include "kabc/phonenumber.h"
29 #include "kabc/address.h"
30 #include "kabc/key.h"
31 #include "kabc/picture.h"
32 #include "kabc/sound.h"
33 #include "kabc/secrecy.h"
34 #include "kabc/vcardconverter.h"
35 
36 int main( int argc, char **argv )
37 {
38  KAboutData aboutData( "testwrite", 0, ki18n( "vCard test writer" ), "0.1" );
39 
40  KCmdLineArgs::init( argc, argv, &aboutData );
41 
42  KApplication app( false );
43 
44  KABC::Addressee addressee;
45 
46  addressee.setNameFromString( QLatin1String( "Mr. Tobias Koenig Jr." ) );
47  addressee.setNickName( QLatin1String( "tokoe" ) );
48  addressee.setBirthday( QDateTime( QDate( 1982, 7, 19 ) ) );
49  addressee.setMailer( QLatin1String( "mutt1.2" ) );
50  addressee.setTimeZone( KABC::TimeZone( +2 ) );
51 
52  KABC::Geo geo;
53  geo.setLatitude( 30 );
54  geo.setLongitude( 51 );
55  addressee.setGeo( geo );
56 
57  addressee.setTitle( QLatin1String( "nerd" ) );
58  addressee.setRole( QLatin1String( "Maintainer" ) );
59  addressee.setOrganization( QLatin1String( "KDE" ) );
60  addressee.setNote( QLatin1String( "nerver\ntouch a running system" ) );
61  addressee.setProductId( QLatin1String( "testId" ) );
62  addressee.setRevision( QDateTime::currentDateTime() );
63  addressee.setSortString( QLatin1String( "koenig" ) );
64  addressee.setUrl( KUrl( QLatin1String( "http://wgess16.dyndns.org" ) ) );
65  addressee.setSecrecy( KABC::Secrecy( KABC::Secrecy::Confidential ) );
66 
67  addressee.insertEmail( QLatin1String( "tokoe@kde.org" ), true );
68  addressee.insertEmail( QLatin1String( "tokoe82@yahoo.de" ), true );
69 
70  KABC::PhoneNumber phone1( QLatin1String( "3541523475" ),
71  KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
72  KABC::PhoneNumber phone2( QLatin1String( "+46745673475" ),
73  KABC::PhoneNumber::Work );
74  addressee.insertPhoneNumber( phone1 );
75  addressee.insertPhoneNumber( phone2 );
76 
77  KABC::Key key( QLatin1String( "secret key" ), KABC::Key::X509 );
78  addressee.insertKey( key );
79 
80  QStringList categories;
81  categories << QLatin1String( "Friends" ) << QLatin1String( "School" ) << QLatin1String( "KDE" );
82  addressee.setCategories( categories );
83 
84  KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::Address::Parcel );
85  a.setStreet( QLatin1String( "6544 Battleford Drive" ) );
86  a.setLocality( QLatin1String( "Raleigh" ) );
87  a.setRegion( QLatin1String( "NC" ) );
88  a.setPostalCode( QLatin1String( "27613-3502" ) );
89  a.setCountry( QLatin1String( "U.S.A." ) );
90  addressee.insertAddress( a );
91 
92  addressee.insertCustom( QLatin1String( "1hsdf" ), QLatin1String( "ertuer" ),
93  QLatin1String( "iurt" ) );
94  addressee.insertCustom( QLatin1String( "2hsdf" ), QLatin1String( "ertuer" ),
95  QLatin1String( "iurt" ) );
96  addressee.insertCustom( QLatin1String( "3hsdf" ), QLatin1String( "ertuer" ),
97  QLatin1String( "iurt" ) );
98 
99  KABC::Addressee::List list;
100  for ( int i = 0; i < 1000; ++i ) {
101  KABC::Addressee addr = addressee;
102  addr.setUid( QString::number( i ) );
103  list.append( addr );
104  }
105 
106  KABC::VCardConverter converter;
107  QByteArray txt = converter.createVCards( list );
108 
109  QFile file( QLatin1String( "out.vcf" ) );
110  if ( !file.open( QIODevice::WriteOnly ) ) {
111  qDebug( "Can't open file '%s' fro writing", qPrintable( file.fileName() ) );
112  return 1;
113  }
114 
115  file.write( txt );
116  file.close();
117 
118  return 0;
119 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:29:42 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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