• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kabc
 

kabc

  • kabc
  • vcardparser
arser/testwrite.cpp
1 /*
2  This file is part of libkabc.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include <kabc/addressee.h>
21 #include <kabc/phonenumber.h>
22 #include <kabc/address.h>
23 #include <kabc/key.h>
24 #include <kabc/picture.h>
25 #include <kabc/sound.h>
26 #include <kabc/secrecy.h>
27 #include <kaboutdata.h>
28 #include <kapplication.h>
29 #include <kcmdlineargs.h>
30 
31 #include <tqfile.h>
32 #include <tqtextstream.h>
33 
34 #include "vcardconverter.h"
35 
36 int main( int argc, char **argv )
37 {
38  KAboutData aboutData( "testwrite", "vCard test writer", "0.1" );
39 
40  KCmdLineArgs::init( argc, argv, &aboutData );
41 
42  KApplication app( false, false );
43 
44 
45  KABC::Addressee addressee;
46 
47  addressee.setNameFromString( "Mr. Tobias Koenig Jr." );
48  addressee.setNickName( "tokoe" );
49  addressee.setBirthday( TQDate( 1982, 7, 19 ) );
50  addressee.setMailer( "mutt1.2" );
51  addressee.setTimeZone( KABC::TimeZone( +2 ) );
52 
53  KABC::Geo geo;
54  geo.setLatitude( 30 );
55  geo.setLongitude( 51 );
56  addressee.setGeo( geo );
57 
58  addressee.setTitle( "nerd" );
59  addressee.setRole( "Maintainer" );
60  addressee.setOrganization( "KDE" );
61  addressee.setNote( "nerver\ntouch a running system" );
62  addressee.setProductId( "testId" );
63  addressee.setRevision( TQDateTime::currentDateTime() );
64  addressee.setSortString( "koenig" );
65  addressee.setUrl( KURL( "http://wgess16.dyndns.org") );
66  addressee.setSecrecy( KABC::Secrecy( KABC::Secrecy::Confidential ) );
67 /*
68  TQImage img;
69  img.load( "testimg.png", "PNG" );
70  KABC::Picture photo;
71  photo.setData( img );
72  addressee.setPhoto( photo );
73 
74  TQImage img2;
75  img2.load( "testimg.png", "PNG" );
76  KABC::Picture logo;
77  logo.setData( img2 );
78  addressee.setLogo( logo );
79 
80  TQFile soundFile( "testsound.wav" );
81  soundFile.open( IO_ReadOnly );
82  TQByteArray data = soundFile.readAll();
83  soundFile.close();
84  KABC::Sound sound;
85  sound.setData( data );
86  addressee.setSound( sound );
87 */
88  addressee.insertEmail( "tokoe@kde.org", true );
89  addressee.insertEmail( "tokoe82@yahoo.de", true );
90 
91  KABC::PhoneNumber phone1( "3541523475", KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
92  KABC::PhoneNumber phone2( "+46745673475", KABC::PhoneNumber::Work );
93  addressee.insertPhoneNumber( phone1 );
94  addressee.insertPhoneNumber( phone2 );
95 
96  KABC::Key key( "secret key", KABC::Key::X509 );
97  addressee.insertKey( key );
98 
99  TQStringList categories;
100  categories << "Friends" << "School" << "KDE";
101  addressee.setCategories( categories );
102 
103  KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::Address::Parcel );
104  a.setStreet( "6544 Battleford Drive" );
105  a.setLocality( "Raleigh" );
106  a.setRegion( "NC" );
107  a.setPostalCode( "27613-3502" );
108  a.setCountry( "U.S.A." );
109  addressee.insertAddress( a );
110 
111  addressee.insertCustom( "1hsdf", "ertuer", "iurt" );
112  addressee.insertCustom( "2hsdf", "ertuer", "iurt" );
113  addressee.insertCustom( "3hsdf", "ertuer", "iurt" );
114 
115  KABC::Addressee::List list;
116  for ( int i = 0; i < 1000; ++i ) {
117  KABC::Addressee addr = addressee;
118  addr.setUid( TQString::number( i ) );
119  list.append( addr );
120  }
121 
122  KABC::VCardConverter converter;
123  TQString txt = converter.createVCards( list );
124 
125  TQFile file( "out.vcf" );
126  file.open( IO_WriteOnly );
127 
128  TQTextStream s( &file );
129  s.setEncoding( TQTextStream::UnicodeUTF8 );
130  s << txt;
131  file.close();
132 
133  return 0;
134 }

kabc

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

kabc

Skip menu "kabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kabc by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |