00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <tdeabc/addressee.h>
00021 #include <tdeabc/phonenumber.h>
00022 #include <tdeabc/address.h>
00023 #include <tdeabc/key.h>
00024 #include <tdeabc/picture.h>
00025 #include <tdeabc/sound.h>
00026 #include <tdeabc/secrecy.h>
00027 #include <tdeaboutdata.h>
00028 #include <tdeapplication.h>
00029 #include <tdecmdlineargs.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 TDEAboutData aboutData( "testwrite", "vCard test writer", "0.1" );
00039
00040 TDECmdLineArgs::init( argc, argv, &aboutData );
00041
00042 TDEApplication app( false, false );
00043
00044
00045 TDEABC::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( TDEABC::TimeZone( +2 ) );
00052
00053 TDEABC::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( TDEABC::Secrecy( TDEABC::Secrecy::Confidential ) );
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 addressee.insertEmail( TQString::fromUtf8("иван.иванов@българия.оод"), true );
00089 addressee.insertEmail( TQString::fromUtf8("иванчо@yahoo.de"), true );
00090
00091 TDEABC::PhoneNumber phone1( "029876543", TDEABC::PhoneNumber::Pref | TDEABC::PhoneNumber::Home );
00092 TDEABC::PhoneNumber phone2( "+359888111222", TDEABC::PhoneNumber::Work );
00093 addressee.insertPhoneNumber( phone1 );
00094 addressee.insertPhoneNumber( phone2 );
00095
00096 TDEABC::Key key( "secret key", TDEABC::Key::X509 );
00097 addressee.insertKey( key );
00098
00099 TQStringList categories;
00100 categories << "Friends" << "School" << "KDE";
00101 addressee.setCategories( categories );
00102
00103 TDEABC::Address a( TDEABC::Address::Work | TDEABC::Address::Postal | TDEABC::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 TDEABC::Addressee::List list;
00118 for ( int i = 0; i < 20; ++i ) {
00119 TDEABC::Addressee addr = addressee;
00120 addr.setUid( TQString::number( i ) );
00121 list.append( addr );
00122 }
00123
00124 TDEABC::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 }