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

kabc

  • kabc
  • 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 <kapplication.h>
23 #include <kcmdlineargs.h>
24 // #include <klocale.h>
25 #include <kaboutdata.h>
26 
27 #include "vcardformatplugin.h"
28 
29 using namespace KABC;
30 
37 int
38 main( int argc, char **argv )
39 {
40  KAboutData aboutData( "testvcardformatplugin", "vCard format plugin", "0.1" );
41 
42  KCmdLineArgs::init( argc, argv, &aboutData );
43 
44  KApplication app( false, false );
45 
46 
47  KABC::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( KABC::TimeZone( +2 ) );
54 
55  KABC::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( KABC::Secrecy( KABC::Secrecy::Confidential ) );
69 /*
70  TQImage img;
71  img.load( "testimg.png", "PNG" );
72  KABC::Picture photo;
73  photo.setData( img );
74  addressee.setPhoto( photo );
75 
76  TQImage img2;
77  img2.load( "testimg.png", "PNG" );
78  KABC::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  KABC::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  KABC::PhoneNumber phone1( "029876543", KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
94  KABC::PhoneNumber phone2( "+359888111222", KABC::PhoneNumber::Work );
95  addressee.insertPhoneNumber( phone1 );
96  addressee.insertPhoneNumber( phone2 );
97 
98  KABC::Key key( "secret key", KABC::Key::X509 );
99  addressee.insertKey( key );
100 
101  TQStringList categories;
102  categories << "Friends" << "School" << "KDE";
103  addressee.setCategories( categories );
104 
105  KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::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 // KABC::Addressee::List list;
120 // for ( int i = 0; i < 20; ++i ) {
121 // KABC::Addressee addr = addressee;
122 // addr.setUid( TQString::number( i ) );
123 // list.append( addr );
124 // }
125 
126 // KABC::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  KABC::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 }

kabc

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

kabc

Skip menu "kabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kabc by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |