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

kabc

testwrite2.cpp
00001 /*
00002     This file is part of libtdeabc.
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <kabc/addressee.h>
00021 #include <kabc/phonenumber.h>
00022 #include <kabc/address.h>
00023 #include <kabc/key.h>
00024 #include <kabc/picture.h>
00025 #include <kabc/sound.h>
00026 #include <kabc/secrecy.h>
00027 #include <kaboutdata.h>
00028 #include <kapplication.h>
00029 #include <kcmdlineargs.h>
00030 
00031 #include <tqfile.h>
00032 #include <tqtextstream.h>
00033 
00034 #include "vcardconverter.h"
00035 
00036 int main( int argc, char **argv )
00037 {
00038   KAboutData aboutData( "testwrite", "vCard test writer", "0.1" );
00039 
00040   KCmdLineArgs::init( argc, argv, &aboutData );
00041 
00042   KApplication app( false, false );
00043 
00044 
00045   KABC::Addressee addressee;
00046 
00047   addressee.setNameFromString( TQString::fromUtf8("Иван Иванов") );
00048   addressee.setNickName( TQString::fromUtf8("иванчо") );
00049   addressee.setBirthday( TQDate( 1981, 7, 19 ) );
00050   addressee.setMailer( "mutt1.2" );
00051   addressee.setTimeZone( KABC::TimeZone( +2 ) );
00052 
00053   KABC::Geo geo;
00054   geo.setLatitude( 30 );
00055   geo.setLongitude( 51 );
00056   addressee.setGeo( geo );
00057 
00058   addressee.setTitle( TQString::fromUtf8("Др") );
00059   addressee.setRole( TQString::fromUtf8("Самарянин") );
00060   addressee.setOrganization( TQString::fromUtf8("България ООД") );
00061   addressee.setNote( TQString::fromUtf8("не\nпипай работеща система") );
00062   addressee.setProductId( "testId" );
00063   addressee.setRevision( TQDateTime::currentDateTime() );
00064   addressee.setSortString( TQString::fromUtf8("сортиране") );
00065   addressee.setUrl( KURL( "http://wgess17.dyndns.org") );
00066   addressee.setSecrecy(  KABC::Secrecy( KABC::Secrecy::Confidential ) );
00067 /*
00068   TQImage img;
00069   img.load( "testimg.png", "PNG" );
00070   KABC::Picture photo;
00071   photo.setData( img );
00072   addressee.setPhoto( photo );
00073 
00074   TQImage img2;
00075   img2.load( "testimg.png", "PNG" );
00076   KABC::Picture logo;
00077   logo.setData( img2 );
00078   addressee.setLogo( logo );
00079 
00080   TQFile soundFile( "testsound.wav" );
00081   soundFile.open( IO_ReadOnly );
00082   TQByteArray data = soundFile.readAll();
00083   soundFile.close();
00084   KABC::Sound sound;
00085   sound.setData( data );
00086   addressee.setSound( sound );
00087 */
00088   addressee.insertEmail( TQString::fromUtf8("иван.иванов@българия.оод"), true );
00089   addressee.insertEmail( TQString::fromUtf8("иванчо@yahoo.de"), true );
00090 
00091   KABC::PhoneNumber phone1( "029876543", KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
00092   KABC::PhoneNumber phone2( "+359888111222", KABC::PhoneNumber::Work );
00093   addressee.insertPhoneNumber( phone1 );
00094   addressee.insertPhoneNumber( phone2 );
00095 
00096   KABC::Key key( "secret key", KABC::Key::X509 );
00097   addressee.insertKey( key );
00098 
00099   TQStringList categories;
00100   categories << "Friends" << "School" << "KDE";
00101   addressee.setCategories( categories );
00102 
00103   KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::Address::Parcel );
00104   a.setStreet( TQString::fromUtf8("Цар Борис III") );
00105   a.setLocality( TQString::fromUtf8("София" ));
00106   a.setRegion( TQString::fromUtf8("София град" ));
00107   a.setPostalCode( TQString::fromUtf8("1000" ));
00108   a.setCountry( TQString::fromUtf8("България" ));
00109   addressee.insertAddress( a );
00110 
00111   addressee.insertCustom( "1hsdf", "test1",TQString::fromUtf8( "ежзик" ));
00112   addressee.insertCustom( "2hsdf", "test2",TQString::fromUtf8( "ежзик" ));
00113   addressee.insertCustom( "3hsdf", "test3",TQString::fromUtf8( "ежзик" ));
00114 
00115   addressee.dump();
00116 
00117   KABC::Addressee::List list;
00118   for ( int i = 0; i < 20; ++i ) {
00119     KABC::Addressee addr = addressee;
00120     addr.setUid( TQString::number( i ) );
00121     list.append( addr );
00122   }
00123 
00124   KABC::VCardConverter converter;
00125   TQString txt = converter.createVCards( list );
00126 
00127   TQFile file( "out2.vcf" );
00128   file.open( IO_WriteOnly );
00129 
00130   TQTextStream s( &file );
00131   s.setEncoding( TQTextStream::UnicodeUTF8 );
00132   s << txt;
00133   file.close();
00134 
00135   return 0;
00136 }

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.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |