• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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 <klocalizedstring.h>
25#include <klocale.h>
26#include <kapplication.h>
27#include <kcmdlineargs.h>
28
29#include "kabc/addressee.h"
30#include "kabc/phonenumber.h"
31#include "kabc/address.h"
32#include "kabc/key.h"
33#include "kabc/picture.h"
34#include "kabc/sound.h"
35#include "kabc/secrecy.h"
36#include "kabc/vcardconverter.h"
37
38int main( int argc, char **argv )
39{
40 KAboutData aboutData( "testwrite", 0, ki18n( "vCard test writer" ), "0.1" );
41
42 KCmdLineArgs::init( argc, argv, &aboutData );
43
44 KApplication app( false );
45
46 KABC::Addressee addressee;
47
48 addressee.setNameFromString( QLatin1String( "Mr. Tobias Koenig Jr." ) );
49 addressee.setNickName( QLatin1String( "tokoe" ) );
50 addressee.setBirthday( QDateTime( QDate( 1982, 7, 19 ) ) );
51 addressee.setMailer( QLatin1String( "mutt1.2" ) );
52 addressee.setTimeZone( KABC::TimeZone( +2 ) );
53
54 KABC::Geo geo;
55 geo.setLatitude( 30 );
56 geo.setLongitude( 51 );
57 addressee.setGeo( geo );
58
59 addressee.setTitle( QLatin1String( "nerd" ) );
60 addressee.setRole( QLatin1String( "Maintainer" ) );
61 addressee.setOrganization( QLatin1String( "KDE" ) );
62 addressee.setNote( QLatin1String( "nerver\ntouch a running system" ) );
63 addressee.setProductId( QLatin1String( "testId" ) );
64 addressee.setRevision( QDateTime::currentDateTime() );
65 addressee.setSortString( QLatin1String( "koenig" ) );
66 addressee.setUrl( KUrl( QLatin1String( "http://wgess16.dyndns.org" ) ) );
67 addressee.setSecrecy( KABC::Secrecy( KABC::Secrecy::Confidential ) );
68
69 addressee.insertEmail( QLatin1String( "tokoe@kde.org" ), true );
70 addressee.insertEmail( QLatin1String( "tokoe82@yahoo.de" ), true );
71
72 KABC::PhoneNumber phone1( QLatin1String( "3541523475" ),
73 KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
74 KABC::PhoneNumber phone2( QLatin1String( "+46745673475" ),
75 KABC::PhoneNumber::Work );
76 addressee.insertPhoneNumber( phone1 );
77 addressee.insertPhoneNumber( phone2 );
78
79 KABC::Key key( QLatin1String( "secret key" ), KABC::Key::X509 );
80 addressee.insertKey( key );
81
82 QStringList categories;
83 categories << QLatin1String( "Friends" ) << QLatin1String( "School" ) << QLatin1String( "KDE" );
84 addressee.setCategories( categories );
85
86 KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::Address::Parcel );
87 a.setStreet( QLatin1String( "6544 Battleford Drive" ) );
88 a.setLocality( QLatin1String( "Raleigh" ) );
89 a.setRegion( QLatin1String( "NC" ) );
90 a.setPostalCode( QLatin1String( "27613-3502" ) );
91 a.setCountry( QLatin1String( "U.S.A." ) );
92 addressee.insertAddress( a );
93
94 addressee.insertCustom( QLatin1String( "1hsdf" ), QLatin1String( "ertuer" ),
95 QLatin1String( "iurt" ) );
96 addressee.insertCustom( QLatin1String( "2hsdf" ), QLatin1String( "ertuer" ),
97 QLatin1String( "iurt" ) );
98 addressee.insertCustom( QLatin1String( "3hsdf" ), QLatin1String( "ertuer" ),
99 QLatin1String( "iurt" ) );
100
101 KABC::Addressee::List list;
102 for ( int i = 0; i < 1000; ++i ) {
103 KABC::Addressee addr = addressee;
104 addr.setUid( QString::number( i ) );
105 list.append( addr );
106 }
107
108 KABC::VCardConverter converter;
109 QByteArray txt = converter.createVCards( list );
110
111 QFile file( QLatin1String( "out.vcf" ) );
112 if ( !file.open( QIODevice::WriteOnly ) ) {
113 qDebug( "Can't open file '%s' fro writing", qPrintable( file.fileName() ) );
114 return 1;
115 }
116
117 file.write( txt );
118 file.close();
119
120 return 0;
121}
KABC::Address
Postal address information.
Definition address.h:38
KABC::Address::Parcel
@ Parcel
parcel
Definition address.h:55
KABC::Address::Work
@ Work
address at work
Definition address.h:57
KABC::Address::Postal
@ Postal
postal
Definition address.h:54
KABC::AddresseeList
a QValueList of Addressee, with sorting functionality
Definition addresseelist.h:289
KABC::Addressee
address book entry
Definition addressee.h:79
KABC::Addressee::setMailer
void setMailer(const QString &mailer)
Set mail client.
Definition addressee.cpp:868
KABC::Addressee::setSecrecy
void setSecrecy(const Secrecy &secrecy)
Set security class.
Definition addressee.cpp:1108
KABC::Addressee::setBirthday
void setBirthday(const QDateTime &birthday)
Set birthday.
Definition addressee.cpp:710
KABC::Addressee::setOrganization
void setOrganization(const QString &organization)
Set organization.
Definition addressee.cpp:968
KABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition addressee.cpp:1525
KABC::Addressee::insertCustom
void insertCustom(const QString &app, const QString &name, const QString &value)
Insert custom entry.
Definition addressee.cpp:1928
KABC::Addressee::setProductId
void setProductId(const QString &productId)
Set product identifier.
Definition addressee.cpp:1028
KABC::Addressee::setNameFromString
void setNameFromString(const QString &)
Set name fields by parsing the given string and trying to associate the parts of the string with acco...
Definition addressee.cpp:1188
KABC::Addressee::setRevision
void setRevision(const QDateTime &revision)
Set revision date.
Definition addressee.cpp:1048
KABC::Addressee::setNickName
void setNickName(const QString &nickName)
Set nick name.
Definition addressee.cpp:690
KABC::Addressee::insertEmail
void insertEmail(const QString &email, bool preferred=false)
Insert an email address.
Definition addressee.cpp:1420
KABC::Addressee::setCategories
void setCategories(const QStringList &)
Set categories to given value.
Definition addressee.cpp:1916
KABC::Addressee::setTimeZone
void setTimeZone(const TimeZone &timeZone)
Set time zone.
Definition addressee.cpp:888
KABC::Addressee::setNote
void setNote(const QString &note)
Set note.
Definition addressee.cpp:1008
KABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition addressee.cpp:1773
KABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition addressee.cpp:1599
KABC::Addressee::setRole
void setRole(const QString &role)
Set role.
Definition addressee.cpp:948
KABC::Addressee::setUrl
void setUrl(const KUrl &url)
Set homepage.
Definition addressee.cpp:1088
KABC::Addressee::setTitle
void setTitle(const QString &title)
Set title.
Definition addressee.cpp:928
KABC::Addressee::setUid
void setUid(const QString &uid)
Set unique identifier.
Definition addressee.cpp:433
KABC::Addressee::setGeo
void setGeo(const Geo &geo)
Set geographic position.
Definition addressee.cpp:908
KABC::Addressee::setSortString
void setSortString(const QString &sortString)
Set sort string.
Definition addressee.cpp:1068
KABC::Geo
Geographic position.
Definition geo.h:36
KABC::Geo::setLatitude
void setLatitude(float latitude)
Sets the latitude.
Definition geo.cpp:74
KABC::Geo::setLongitude
void setLongitude(float longitude)
Sets the longitude.
Definition geo.cpp:90
KABC::Key
A class to store an encryption key.
Definition key.h:35
KABC::Key::X509
@ X509
X509 key.
Definition key.h:49
KABC::PhoneNumber
Phonenumber information.
Definition phonenumber.h:39
KABC::PhoneNumber::Pref
@ Pref
Preferred number.
Definition phonenumber.h:51
KABC::PhoneNumber::Work
@ Work
Office number.
Definition phonenumber.h:49
KABC::PhoneNumber::Home
@ Home
Home number.
Definition phonenumber.h:48
KABC::TimeZone
Time zone information.
Definition timezone.h:36
KABC::VCardConverter
Class to converting contact objects into vCard format and vice versa.
Definition vcardconverter.h:54
KABC::VCardConverter::createVCards
QByteArray createVCards(Addressee::List list, Version version=v3_0) const
Creates a string in vCard format which contains the given list of contact.
Definition vcardconverter.cpp:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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