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

kabc

  • kabc
  • 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 <kapplication.h>
23 #include <kcmdlineargs.h>
24 // #include <klocale.h>
25 #include <kaboutdata.h>
26 
27 #include "vcardformatimpl.h"
28 
29 using namespace KABC;
30 
31 int
32 main( int argc, char **argv )
33 {
34  KAboutData aboutData( "testvcardformatimpl", "vCard format plugin", "0.1" );
35 
36  KCmdLineArgs::init( argc, argv, &aboutData );
37 
38  KApplication app( false, false );
39 
40 
41  KABC::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( KABC::TimeZone( +2 ) );
48 
49  KABC::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( KABC::Secrecy( KABC::Secrecy::Confidential ) );
63 /*
64  TQImage img;
65  img.load( "testimg.png", "PNG" );
66  KABC::Picture photo;
67  photo.setData( img );
68  addressee.setPhoto( photo );
69 
70  TQImage img2;
71  img2.load( "testimg.png", "PNG" );
72  KABC::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  KABC::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  KABC::PhoneNumber phone1( "029876543", KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home );
88  KABC::PhoneNumber phone2( "+359888111222", KABC::PhoneNumber::Work );
89  addressee.insertPhoneNumber( phone1 );
90  addressee.insertPhoneNumber( phone2 );
91 
92  KABC::Key key( "secret key", KABC::Key::X509 );
93  addressee.insertKey( key );
94 
95  TQStringList categories;
96  categories << "Friends" << "School" << "KDE";
97  addressee.setCategories( categories );
98 
99  KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::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 // KABC::Addressee::List list;
116 // for ( int i = 0; i < 20; ++i ) {
117 // KABC::Addressee addr = addressee;
118 // addr.setUid( TQString::number( i ) );
119 // list.append( addr );
120 // }
121 
122 // KABC::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  KABC::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
KApplication
KABC::Address
Postal address information.
Definition: address.h:55
KABC::Addressee::insertCustom
void insertCustom(const TQString &app, const TQString &name, const TQString &value)
Insert custom entry.
Definition: addressee.src.cpp:791
KABC::PhoneNumber
Phonenumber information.
Definition: phonenumber.h:38
KABC::Addressee::insertPhoneNumber
void insertPhoneNumber(const PhoneNumber &phoneNumber)
Insert a phone number.
Definition: addressee.src.cpp:460
KABC::Key
A class to store an encryption key.
Definition: key.h:33
kdDebug
kdbgstream kdDebug(int area=0)
KABC::VCardFormatImpl
Definition: vcardformatimpl.h:43
KABC::Addressee::insertKey
void insertKey(const Key &key)
Insert a key.
Definition: addressee.src.cpp:534
KAboutData
KABC::TimeZone
Time zone information.
Definition: timezone.h:35
KABC::Geo::setLongitude
void setLongitude(float)
Sets the longitude.
Definition: geo.cpp:54
KStdAccel::key
int key(StdAccel) KDE_DEPRECATED
KABC::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
KABC::Addressee
address book entry
Definition: addressee.src.h:74
KABC::Addressee::insertAddress
void insertAddress(const Address &address)
Insert an address.
Definition: addressee.src.cpp:675
KABC::Addressee::setCategories
void setCategories(const TQStringList &)
Set categories to given value.
Definition: addressee.src.cpp:778
KCmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
KABC::Geo
Geographic position.
Definition: geo.h:35
KABC
static data, shared by ALL addressee objects
Definition: address.h:48
KABC::Addressee::insertEmail
void insertEmail(const TQString &email, bool preferred=false)
Insert an email address.
Definition: addressee.src.cpp:412
endl
kndbgstream & endl(kndbgstream &s)
KABC::Addressee::dump
void dump() const
Debug output.
Definition: addressee.src.cpp:631
KABC::Geo::setLatitude
void setLatitude(float)
Sets the latitude.
Definition: geo.cpp:38

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.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |