• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

kabc

testwrite.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 <kaboutdata.h>
00024 #include <kapplication.h>
00025 #include <kcmdlineargs.h>
00026 
00027 #include "kabc/addressee.h"
00028 #include "kabc/phonenumber.h"
00029 #include "kabc/address.h"
00030 #include "kabc/key.h"
00031 #include "kabc/picture.h"
00032 #include "kabc/sound.h"
00033 #include "kabc/secrecy.h"
00034 #include "kabc/vcardconverter.h"
00035 
00036 int main( int argc, char **argv )
00037 {
00038   KAboutData aboutData( "testwrite", 0, ki18n("vCard test writer"), "0.1" );
00039 
00040   KCmdLineArgs::init( argc, argv, &aboutData );
00041 
00042   KApplication app( false );
00043 
00044   KABC::Addressee addressee;
00045 
00046   addressee.setNameFromString( "Mr. Tobias Koenig Jr." );
00047   addressee.setNickName( "tokoe" );
00048   addressee.setBirthday( QDateTime( QDate( 1982, 7, 19 ) ) );
00049   addressee.setMailer( "mutt1.2" );
00050   addressee.setTimeZone( KABC::TimeZone( +2 ) );
00051 
00052   KABC::Geo geo;
00053   geo.setLatitude( 30 );
00054   geo.setLongitude( 51 );
00055   addressee.setGeo( geo );
00056 
00057   addressee.setTitle( "nerd" );
00058   addressee.setRole( "Maintainer" );
00059   addressee.setOrganization( "KDE" );
00060   addressee.setNote( "nerver\ntouch a running system" );
00061   addressee.setProductId( "testId" );
00062   addressee.setRevision( QDateTime::currentDateTime() );
00063   addressee.setSortString( "koenig" );
00064   addressee.setUrl( KUrl( "http://wgess16.dyndns.org" ) );
00065   addressee.setSecrecy( KABC::Secrecy( KABC::Secrecy::Confidential ) );
00066 
00067   addressee.insertEmail( "tokoe@kde.org", true );
00068   addressee.insertEmail( "tokoe82@yahoo.de", true );
00069 
00070   KABC::PhoneNumber phone1( "3541523475", KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
00071   KABC::PhoneNumber phone2( "+46745673475", KABC::PhoneNumber::Work );
00072   addressee.insertPhoneNumber( phone1 );
00073   addressee.insertPhoneNumber( phone2 );
00074 
00075   KABC::Key key( "secret key", KABC::Key::X509 );
00076   addressee.insertKey( key );
00077 
00078   QStringList categories;
00079   categories << "Friends" << "School" << "KDE";
00080   addressee.setCategories( categories );
00081 
00082   KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::Address::Parcel );
00083   a.setStreet( "6544 Battleford Drive" );
00084   a.setLocality( "Raleigh" );
00085   a.setRegion( "NC" );
00086   a.setPostalCode( "27613-3502" );
00087   a.setCountry( "U.S.A." );
00088   addressee.insertAddress( a );
00089 
00090   addressee.insertCustom( "1hsdf", "ertuer", "iurt" );
00091   addressee.insertCustom( "2hsdf", "ertuer", "iurt" );
00092   addressee.insertCustom( "3hsdf", "ertuer", "iurt" );
00093 
00094   KABC::Addressee::List list;
00095   for ( int i = 0; i < 1000; ++i ) {
00096     KABC::Addressee addr = addressee;
00097     addr.setUid( QString::number( i ) );
00098     list.append( addr );
00099   }
00100 
00101   KABC::VCardConverter converter;
00102   QByteArray txt = converter.createVCards( list );
00103 
00104   QFile file( "out.vcf" );
00105   if ( !file.open( QIODevice::WriteOnly ) ) {
00106     qDebug( "Can't open file '%s' fro writing", qPrintable( file.fileName() ) );
00107     return 1;
00108   }
00109 
00110   file.write( txt );
00111   file.close();
00112 
00113   return 0;
00114 }

kabc

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.6
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal