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

tdeabc

  • tdeabc
  • vcardparser
testvcardformatimpl.cpp
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 }
KURL
TDEABC::Address
Postal address information.
Definition: address.h:56
TDEABC::Addressee
address book entry
Definition: addressee.src.h:75
TDEABC::Addressee::setCategories
void setCategories(const TQStringList &)
Set categories to given value.
Definition: addressee.src.cpp:778
TDEABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.src.cpp:460
TDEABC::Addressee::insertCustom
void insertCustom(const TQString &app, const TQString &name, const TQString &value)
Insert custom entry.
Definition: addressee.src.cpp:791
TDEABC::Addressee::dump
void dump() const
Debug output.
Definition: addressee.src.cpp:631
TDEABC::Addressee::insertEmail
void insertEmail(const TQString &email, bool preferred=false)
Insert an email address.
Definition: addressee.src.cpp:412
TDEABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.src.cpp:675
TDEABC::Addressee::setNameFromString
DECLARATIONS void setNameFromString(const TQString &)
Set name fields by parsing the given string and trying to associate the parts of the string with acco...
Definition: addressee.src.cpp:204
TDEABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition: addressee.src.cpp:534
TDEABC::Geo
Geographic position.
Definition: geo.h:36
TDEABC::Geo::setLongitude
void setLongitude(float)
Sets the longitude.
Definition: geo.cpp:54
TDEABC::Geo::setLatitude
void setLatitude(float)
Sets the latitude.
Definition: geo.cpp:38
TDEABC::Key
A class to store an encryption key.
Definition: key.h:34
TDEABC::PhoneNumber
Phonenumber information.
Definition: phonenumber.h:39
TDEABC::TimeZone
Time zone information.
Definition: timezone.h:36
TDEABC::VCardFormatImpl
Definition: vcardformatimpl.h:44
TDEAboutData
TDEApplication
TDECmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48
TDEStdAccel::key
int key(StdAccel id)

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