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

tdeabc

testvcardformat.cpp
00001 
00002 /*
00003     This file is part of libtdeabc.
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 <kdebug.h>
00022 #include <tdeapplication.h>
00023 #include <tdecmdlineargs.h>
00024 // #include <tdelocale.h>
00025 #include <tdeaboutdata.h>
00026 
00027 #include "vcardformatplugin.h"
00028 
00029 using namespace TDEABC;
00030 
00037 int
00038 main( int argc, char **argv )
00039 {
00040   TDEAboutData aboutData( "testvcardformatplugin", "vCard format plugin", "0.1" );
00041 
00042   TDECmdLineArgs::init( argc, argv, &aboutData );
00043 
00044   TDEApplication app( false, false );
00045 
00046 
00047   TDEABC::Addressee addressee;
00048 
00049   addressee.setNameFromString( TQString::fromUtf8("Иван Иванов") );
00050   addressee.setNickName( TQString::fromUtf8("иванчо") );
00051   addressee.setBirthday( TQDate( 1981, 7, 19 ) );
00052   addressee.setMailer( "mutt1.2" );
00053   addressee.setTimeZone( TDEABC::TimeZone( +2 ) );
00054 
00055   TDEABC::Geo geo;
00056   geo.setLatitude( 30 );
00057   geo.setLongitude( 51 );
00058   addressee.setGeo( geo );
00059 
00060   addressee.setTitle( TQString::fromUtf8("Др") );
00061   addressee.setRole( TQString::fromUtf8("Самарянин") );
00062   addressee.setOrganization( TQString::fromUtf8("България ООД") );
00063   addressee.setNote( TQString::fromUtf8("не\nпипай работеща система") );
00064   addressee.setProductId( "testId" );
00065   addressee.setRevision( TQDateTime::currentDateTime() );
00066   addressee.setSortString( TQString::fromUtf8("сортиране") );
00067   addressee.setUrl( KURL( "http://wgess17.dyndns.org") );
00068   addressee.setSecrecy(  TDEABC::Secrecy( TDEABC::Secrecy::Confidential ) );
00069 /*
00070   TQImage img;
00071   img.load( "testimg.png", "PNG" );
00072   TDEABC::Picture photo;
00073   photo.setData( img );
00074   addressee.setPhoto( photo );
00075 
00076   TQImage img2;
00077   img2.load( "testimg.png", "PNG" );
00078   TDEABC::Picture logo;
00079   logo.setData( img2 );
00080   addressee.setLogo( logo );
00081 
00082   TQFile soundFile( "testsound.wav" );
00083   soundFile.open( IO_ReadOnly );
00084   TQByteArray data = soundFile.readAll();
00085   soundFile.close();
00086   TDEABC::Sound sound;
00087   sound.setData( data );
00088   addressee.setSound( sound );
00089 */
00090   addressee.insertEmail( TQString::fromUtf8("иван.иванов@българия.оод"), true );
00091   addressee.insertEmail( TQString::fromUtf8("иванчо@yahoo.de"), true );
00092 
00093   TDEABC::PhoneNumber phone1( "029876543", TDEABC::PhoneNumber::Pref | TDEABC::PhoneNumber::Home );
00094   TDEABC::PhoneNumber phone2( "+359888111222", TDEABC::PhoneNumber::Work );
00095   addressee.insertPhoneNumber( phone1 );
00096   addressee.insertPhoneNumber( phone2 );
00097 
00098   TDEABC::Key key( "secret key", TDEABC::Key::X509 );
00099   addressee.insertKey( key );
00100 
00101   TQStringList categories;
00102   categories << "Friends" << "School" << "KDE";
00103   addressee.setCategories( categories );
00104 
00105   TDEABC::Address a( TDEABC::Address::Work | TDEABC::Address::Postal | TDEABC::Address::Parcel );
00106   a.setStreet( TQString::fromUtf8("Цар Борис III") );
00107   a.setLocality( TQString::fromUtf8("София" ));
00108   a.setRegion( TQString::fromUtf8("София град" ));
00109   a.setPostalCode( TQString::fromUtf8("1000" ));
00110   a.setCountry( TQString::fromUtf8("България" ));
00111   addressee.insertAddress( a );
00112 
00113   addressee.insertCustom( "1hsdf", "test1",TQString::fromUtf8( "ежзик" ));
00114   addressee.insertCustom( "2hsdf", "test2",TQString::fromUtf8( "ежзик" ));
00115   addressee.insertCustom( "3hsdf", "test3",TQString::fromUtf8( "ежзик" ));
00116 
00117   addressee.dump();
00118 
00119 //   TDEABC::Addressee::List list;
00120 //   for ( int i = 0; i < 20; ++i ) {
00121 //     TDEABC::Addressee addr = addressee;
00122 //     addr.setUid( TQString::number( i ) );
00123 //     list.append( addr );
00124 //   }
00125 
00126 //   TDEABC::VCardConverter converter;
00127 //   TQString txt = converter.createVCards( list );
00128 //
00129 //   TQFile file( "out2.vcf" );
00130 //   file.open( IO_WriteOnly );
00131 //
00132 //   TQTextStream s( &file );
00133 //   s.setEncoding( TQTextStream::UnicodeUTF8 );
00134 //   s << txt;
00135 //   file.close();
00136 
00137   VCardFormatPlugin *vcfplugin = new VCardFormatPlugin();
00138   TQFile file( "vfout.vcf" );
00139   if ( file.open(IO_WriteOnly) ){
00140     vcfplugin->save(addressee, &file);
00141     file.close();
00142   }
00143 
00144 
00145   TDEABC::Addressee addressee2;
00146 
00147   if ( file.open(IO_ReadOnly ) ){
00148     vcfplugin->load(addressee2, &file);
00149     file.close();
00150   }
00151 
00152   addressee2.dump();
00153 
00154   return 0;
00155 
00156 
00157 /*    Addressee::List::iterator itr1;
00158     Addressee::List::iterator itr2;
00159     for ( itr1 = l.begin(), itr2 = parsed.begin();
00160           itr1 != l.end(); ++itr1, ++itr2 ) {
00161         if ( (*itr1).fullEmail() == (*itr2).fullEmail() &&
00162              (*itr1).organization() == (*itr2).organization() &&
00163              (*itr1).phoneNumbers() == (*itr2).phoneNumbers()  &&
00164              (*itr1).emails() == (*itr2).emails() &&
00165              (*itr1).role() == (*itr2).role()  ) {
00166             kdDebug()<<"\tAddressee  - PASSED"<<endl;
00167             kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl;
00168         } else {
00169             kdDebug()<<"\tAddressee  - FAILED"<<endl;
00170             kdDebug()<<">>>>>>>Addressee from code<<<<<<<<"<<endl;
00171             (*itr1).dump();
00172             kdDebug()<<">>>>>>>Addressee from file<<<<<<<<"<<endl;
00173             (*itr2).dump();
00174             //kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl;
00175         }
00176     }
00177 */
00178 }

tdeabc

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

tdeabc

Skip menu "tdeabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.