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

tdeabc

  • tdeabc
  • vcardparser
testvcardformat.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 "vcardformatplugin.h"
28 
29 using namespace TDEABC;
30 
37 int
38 main( int argc, char **argv )
39 {
40  TDEAboutData aboutData( "testvcardformatplugin", "vCard format plugin", "0.1" );
41 
42  TDECmdLineArgs::init( argc, argv, &aboutData );
43 
44  TDEApplication app( false, false );
45 
46 
47  TDEABC::Addressee addressee;
48 
49  addressee.setNameFromString( TQString::fromUtf8("Иван Иванов") );
50  addressee.setNickName( TQString::fromUtf8("иванчо") );
51  addressee.setBirthday( TQDate( 1981, 7, 19 ) );
52  addressee.setMailer( "mutt1.2" );
53  addressee.setTimeZone( TDEABC::TimeZone( +2 ) );
54 
55  TDEABC::Geo geo;
56  geo.setLatitude( 30 );
57  geo.setLongitude( 51 );
58  addressee.setGeo( geo );
59 
60  addressee.setTitle( TQString::fromUtf8("Др") );
61  addressee.setRole( TQString::fromUtf8("Самарянин") );
62  addressee.setOrganization( TQString::fromUtf8("България ООД") );
63  addressee.setNote( TQString::fromUtf8("не\nпипай работеща система") );
64  addressee.setProductId( "testId" );
65  addressee.setRevision( TQDateTime::currentDateTime() );
66  addressee.setSortString( TQString::fromUtf8("сортиране") );
67  addressee.setUrl( KURL( "http://wgess17.dyndns.org") );
68  addressee.setSecrecy( TDEABC::Secrecy( TDEABC::Secrecy::Confidential ) );
69 /*
70  TQImage img;
71  img.load( "testimg.png", "PNG" );
72  TDEABC::Picture photo;
73  photo.setData( img );
74  addressee.setPhoto( photo );
75 
76  TQImage img2;
77  img2.load( "testimg.png", "PNG" );
78  TDEABC::Picture logo;
79  logo.setData( img2 );
80  addressee.setLogo( logo );
81 
82  TQFile soundFile( "testsound.wav" );
83  soundFile.open( IO_ReadOnly );
84  TQByteArray data = soundFile.readAll();
85  soundFile.close();
86  TDEABC::Sound sound;
87  sound.setData( data );
88  addressee.setSound( sound );
89 */
90  addressee.insertEmail( TQString::fromUtf8("иван.иванов@българия.оод"), true );
91  addressee.insertEmail( TQString::fromUtf8("иванчо@yahoo.de"), true );
92 
93  TDEABC::PhoneNumber phone1( "029876543", TDEABC::PhoneNumber::Pref | TDEABC::PhoneNumber::Home );
94  TDEABC::PhoneNumber phone2( "+359888111222", TDEABC::PhoneNumber::Work );
95  addressee.insertPhoneNumber( phone1 );
96  addressee.insertPhoneNumber( phone2 );
97 
98  TDEABC::Key key( "secret key", TDEABC::Key::X509 );
99  addressee.insertKey( key );
100 
101  TQStringList categories;
102  categories << "Friends" << "School" << "KDE";
103  addressee.setCategories( categories );
104 
105  TDEABC::Address a( TDEABC::Address::Work | TDEABC::Address::Postal | TDEABC::Address::Parcel );
106  a.setStreet( TQString::fromUtf8("Цар Борис III") );
107  a.setLocality( TQString::fromUtf8("София" ));
108  a.setRegion( TQString::fromUtf8("София град" ));
109  a.setPostalCode( TQString::fromUtf8("1000" ));
110  a.setCountry( TQString::fromUtf8("България" ));
111  addressee.insertAddress( a );
112 
113  addressee.insertCustom( "1hsdf", "test1",TQString::fromUtf8( "ежзик" ));
114  addressee.insertCustom( "2hsdf", "test2",TQString::fromUtf8( "ежзик" ));
115  addressee.insertCustom( "3hsdf", "test3",TQString::fromUtf8( "ежзик" ));
116 
117  addressee.dump();
118 
119 // TDEABC::Addressee::List list;
120 // for ( int i = 0; i < 20; ++i ) {
121 // TDEABC::Addressee addr = addressee;
122 // addr.setUid( TQString::number( i ) );
123 // list.append( addr );
124 // }
125 
126 // TDEABC::VCardConverter converter;
127 // TQString txt = converter.createVCards( list );
128 //
129 // TQFile file( "out2.vcf" );
130 // file.open( IO_WriteOnly );
131 //
132 // TQTextStream s( &file );
133 // s.setEncoding( TQTextStream::UnicodeUTF8 );
134 // s << txt;
135 // file.close();
136 
137  VCardFormatPlugin *vcfplugin = new VCardFormatPlugin();
138  TQFile file( "vfout.vcf" );
139  if ( file.open(IO_WriteOnly) ){
140  vcfplugin->save(addressee, &file);
141  file.close();
142  }
143 
144 
145  TDEABC::Addressee addressee2;
146 
147  if ( file.open(IO_ReadOnly ) ){
148  vcfplugin->load(addressee2, &file);
149  file.close();
150  }
151 
152  addressee2.dump();
153 
154  return 0;
155 
156 
157 /* Addressee::List::iterator itr1;
158  Addressee::List::iterator itr2;
159  for ( itr1 = l.begin(), itr2 = parsed.begin();
160  itr1 != l.end(); ++itr1, ++itr2 ) {
161  if ( (*itr1).fullEmail() == (*itr2).fullEmail() &&
162  (*itr1).organization() == (*itr2).organization() &&
163  (*itr1).phoneNumbers() == (*itr2).phoneNumbers() &&
164  (*itr1).emails() == (*itr2).emails() &&
165  (*itr1).role() == (*itr2).role() ) {
166  kdDebug()<<"\tAddressee - PASSED"<<endl;
167  kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl;
168  } else {
169  kdDebug()<<"\tAddressee - FAILED"<<endl;
170  kdDebug()<<">>>>>>>Addressee from code<<<<<<<<"<<endl;
171  (*itr1).dump();
172  kdDebug()<<">>>>>>>Addressee from file<<<<<<<<"<<endl;
173  (*itr2).dump();
174  //kdDebug()<<"\t\t"<< (*itr1).fullEmail() << " VS. " << (*itr2).fullEmail()<<endl;
175  }
176  }
177 */
178 }
KURL
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::Key
A class to store an encryption key.
Definition: key.h:33
TDEABC::Geo::setLongitude
void setLongitude(float)
Sets the longitude.
Definition: geo.cpp:54
TDEABC::Addressee::insertEmail
void insertEmail(const TQString &email, bool preferred=false)
Insert an email address.
Definition: addressee.src.cpp:412
TDEStdAccel::key
int key(StdAccel) KDE_DEPRECATED
TDEAboutData
TDEABC::TimeZone
Time zone information.
Definition: timezone.h:35
TDEABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.src.cpp:675
TDEApplication
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48
TDEABC::Addressee::setCategories
void setCategories(const TQStringList &)
Set categories to given value.
Definition: addressee.src.cpp:778
TDEABC::Address
Postal address information.
Definition: address.h:55
TDEABC::Geo::setLatitude
void setLatitude(float)
Sets the latitude.
Definition: geo.cpp:38
TDECmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
TDEABC::Geo
Geographic position.
Definition: geo.h:35
TDEABC::PhoneNumber
Phonenumber information.
Definition: phonenumber.h:38
TDEABC::VCardFormatPlugin::save
void save(const Addressee &, TQFile *file)
Save a single Addressee to file.
Definition: vcardformatplugin.cpp:81
TDEABC::Addressee
address book entry
Definition: addressee.src.h:74
TDEABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition: addressee.src.cpp:534
TDEABC::Addressee::dump
void dump() const
Debug output.
Definition: addressee.src.cpp:631
TDEABC::VCardFormatPlugin
Interface of vCard backend for address book.
Definition: vcardformatplugin.h:37
TDEABC::Addressee::insertCustom
void insertCustom(const TQString &app, const TQString &name, const TQString &value)
Insert custom entry.
Definition: addressee.src.cpp:791
TDEABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.src.cpp:460
TDEABC::VCardFormatPlugin::load
bool load(Addressee &, TQFile *file)
Load single addressee from file.
Definition: vcardformatplugin.cpp:39

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.8.8
This website is maintained by Timothy Pearson.