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

tdeabc

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

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.6.3
This website is maintained by Timothy Pearson.