|
Line 0
Link Here
|
|
|
1 |
|
| 2 |
/* |
| 3 |
This file is part of libtdeabc. |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Library General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Library General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Library General Public License |
| 16 |
along with this library; see the file COPYING.LIB. If not, write to |
| 17 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 |
Boston, MA 02110-1301, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include <kdebug.h> |
| 22 |
#include <tdeapplication.h> |
| 23 |
#include <tdecmdlineargs.h> |
| 24 |
// #include <tdelocale.h> |
| 25 |
#include <tdeaboutdata.h> |
| 26 |
|
| 27 |
#include "vcardformatimpl.h" |
| 28 |
|
| 29 |
using namespace TDEABC; |
| 30 |
|
| 31 |
int |
| 32 |
main( int argc, char **argv ) |
| 33 |
{ |
| 34 |
TDEAboutData aboutData( "testvcardformatimpl", "vCard format plugin", "0.1" ); |
| 35 |
|
| 36 |
TDECmdLineArgs::init( argc, argv, &aboutData ); |
| 37 |
|
| 38 |
TDEApplication app( false, false ); |
| 39 |
|
| 40 |
|
| 41 |
TDEABC::Addressee addressee; |
| 42 |
|
| 43 |
addressee.setNameFromString( TQString::fromUtf8("Иван Иванов") ); |
| 44 |
addressee.setNickName( TQString::fromUtf8("иванчо") ); |
| 45 |
addressee.setBirthday( TQDate( 1981, 7, 19 ) ); |
| 46 |
addressee.setMailer( "mutt1.2" ); |
| 47 |
addressee.setTimeZone( TDEABC::TimeZone( +2 ) ); |
| 48 |
|
| 49 |
TDEABC::Geo geo; |
| 50 |
geo.setLatitude( 30 ); |
| 51 |
geo.setLongitude( 51 ); |
| 52 |
addressee.setGeo( geo ); |
| 53 |
|
| 54 |
addressee.setTitle( TQString::fromUtf8("Др") ); |
| 55 |
addressee.setRole( TQString::fromUtf8("Самарянин") ); |
| 56 |
addressee.setOrganization( TQString::fromUtf8("България ООД") ); |
| 57 |
addressee.setNote( TQString::fromUtf8("не\nпипай работеща система") ); |
| 58 |
addressee.setProductId( "testId" ); |
| 59 |
addressee.setRevision( TQDateTime::currentDateTime() ); |
| 60 |
addressee.setSortString( TQString::fromUtf8("сортиране") ); |
| 61 |
addressee.setUrl( KURL( "http://wgess17.dyndns.org") ); |
| 62 |
addressee.setSecrecy( TDEABC::Secrecy( TDEABC::Secrecy::Confidential ) ); |
| 63 |
/* |
| 64 |
TQImage img; |
| 65 |
img.load( "testimg.png", "PNG" ); |
| 66 |
TDEABC::Picture photo; |
| 67 |
photo.setData( img ); |
| 68 |
addressee.setPhoto( photo ); |
| 69 |
|
| 70 |
TQImage img2; |
| 71 |
img2.load( "testimg.png", "PNG" ); |
| 72 |
TDEABC::Picture logo; |
| 73 |
logo.setData( img2 ); |
| 74 |
addressee.setLogo( logo ); |
| 75 |
|
| 76 |
TQFile soundFile( "testsound.wav" ); |
| 77 |
soundFile.open( IO_ReadOnly ); |
| 78 |
TQByteArray data = soundFile.readAll(); |
| 79 |
soundFile.close(); |
| 80 |
TDEABC::Sound sound; |
| 81 |
sound.setData( data ); |
| 82 |
addressee.setSound( sound ); |
| 83 |
*/ |
| 84 |
addressee.insertEmail( TQString::fromUtf8("иван.иванов@българия.оод"), true ); |
| 85 |
addressee.insertEmail( TQString::fromUtf8("иванчо@yahoo.de"), true ); |
| 86 |
|
| 87 |
TDEABC::PhoneNumber phone1( "029876543", TDEABC::PhoneNumber::Pref | TDEABC::PhoneNumber::Home ); |
| 88 |
TDEABC::PhoneNumber phone2( "+359888111222", TDEABC::PhoneNumber::Work ); |
| 89 |
addressee.insertPhoneNumber( phone1 ); |
| 90 |
addressee.insertPhoneNumber( phone2 ); |
| 91 |
|
| 92 |
TDEABC::Key key( "secret key", TDEABC::Key::X509 ); |
| 93 |
addressee.insertKey( key ); |
| 94 |
|
| 95 |
TQStringList categories; |
| 96 |
categories << "Friends" << "School" << "KDE"; |
| 97 |
addressee.setCategories( categories ); |
| 98 |
|
| 99 |
TDEABC::Address a( TDEABC::Address::Work | TDEABC::Address::Postal | TDEABC::Address::Parcel ); |
| 100 |
a.setStreet( TQString::fromUtf8("Цар Борис III") ); |
| 101 |
a.setLocality( TQString::fromUtf8("София" )); |
| 102 |
a.setRegion( TQString::fromUtf8("София град" )); |
| 103 |
a.setPostalCode( TQString::fromUtf8("1000" )); |
| 104 |
a.setCountry( TQString::fromUtf8("България" )); |
| 105 |
addressee.insertAddress( a ); |
| 106 |
|
| 107 |
addressee.insertCustom( "1hsdf", "test1",TQString::fromUtf8( "ежзик" )); |
| 108 |
addressee.insertCustom( "2hsdf", "test2",TQString::fromUtf8( "ежзик" )); |
| 109 |
addressee.insertCustom( "3hsdf", "test3",TQString::fromUtf8( "ежзик" )); |
| 110 |
|
| 111 |
addressee.dump(); |
| 112 |
|
| 113 |
kdDebug() << ">>>>>>>>>>>>>>>>END FIRST ADDRESSEE<<<<<<<<<<<<<<" << endl; |
| 114 |
|
| 115 |
// TDEABC::Addressee::List list; |
| 116 |
// for ( int i = 0; i < 20; ++i ) { |
| 117 |
// TDEABC::Addressee addr = addressee; |
| 118 |
// addr.setUid( TQString::number( i ) ); |
| 119 |
// list.append( addr ); |
| 120 |
// } |
| 121 |
|
| 122 |
// TDEABC::VCardConverter converter; |
| 123 |
// TQString txt = converter.createVCards( list ); |
| 124 |
// |
| 125 |
// TQFile file( "out2.vcf" ); |
| 126 |
// file.open( IO_WriteOnly ); |
| 127 |
// |
| 128 |
// TQTextStream s( &file ); |
| 129 |
// s.setEncoding( TQTextStream::UnicodeUTF8 ); |
| 130 |
// s << txt; |
| 131 |
// file.close(); |
| 132 |
|
| 133 |
VCardFormatImpl *vcfImpl = new VCardFormatImpl(); |
| 134 |
TQFile file( "vfimpout.vcf" ); |
| 135 |
if ( file.open(IO_WriteOnly) ){ |
| 136 |
vcfImpl->save(addressee, &file); |
| 137 |
file.close(); |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
TDEABC::Addressee addressee2; |
| 142 |
|
| 143 |
if ( file.open(IO_ReadOnly ) ){ |
| 144 |
vcfImpl->load(addressee2, &file); |
| 145 |
file.close(); |
| 146 |
} |
| 147 |
|
| 148 |
addressee2.dump(); |
| 149 |
|
| 150 |
return 0; |
| 151 |
|
| 152 |
|
| 153 |
/* Addressee::List::iterator itr1; |
| 154 |
Addressee::List::iterator itr2; |
| 155 |
for ( itr1 = l.begin(), itr2 = parsed.begin(); |
| 156 |
itr1 != l.end(); ++itr1, ++itr2 ) { |
| 157 |
if ( (*itr1).fullEmail() == (*itr2).fullEmail() && |
| 158 |
(*itr1).organization() == (*itr2).organization() && |
| 159 |
(*itr1).phoneNumbers() == (*itr2).phoneNumbers() && |
| 160 |
(*itr1).emails() == (*itr2).emails() && |
| 161 |
(*itr1).role() == (*itr2).role() ) { |
| 162 |
kdDebug()<<"\tAddressee - PASSED"<<endl; |
| 163 |
kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl; |
| 164 |
} else { |
| 165 |
kdDebug()<<"\tAddressee - FAILED"<<endl; |
| 166 |
kdDebug()<<">>>>>>>Addressee from code<<<<<<<<"<<endl; |
| 167 |
(*itr1).dump(); |
| 168 |
kdDebug()<<">>>>>>>Addressee from file<<<<<<<<"<<endl; |
| 169 |
(*itr2).dump(); |
| 170 |
//kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl; |
| 171 |
} |
| 172 |
} |
| 173 |
*/ |
| 174 |
} |