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

tdeabc

  • tdeabc
  • vcardparser
vcardparser/testread.cpp
1/*
2 This file is part of libtdeabc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include <iostream>
21#include <stdlib.h>
22
23#include <tqfile.h>
24#include <tqtextstream.h>
25
26#include <tdeprocess.h>
27#include <kdebug.h>
28#include <tdeapplication.h>
29#include <tdecmdlineargs.h>
30#include <tdelocale.h>
31#include <tdeaboutdata.h>
32
33#include "tdeabc/vcardconverter.h"
34#include "vcard.h"
35
36static const TDECmdLineOptions options[] =
37{
38 {"vcard21", I18N_NOOP("vCard 2.1"), 0},
39 {"+inputfile", I18N_NOOP("Input file"), 0},
40 TDECmdLineLastOption
41};
42
43int main( int argc, char **argv )
44{
45 TDEApplication::disableAutoDcopRegistration();
46
47 TDEAboutData aboutData( "testread", "vCard test reader", "0.1" );
48 aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
49
50 TDECmdLineArgs::init( argc, argv, &aboutData );
51 TDECmdLineArgs::addCmdLineOptions( options );
52
53 TDEApplication app( false, false );
54
55 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
56
57 if ( args->count() != 1 ) {
58 std::cerr << "Missing argument" << std::endl;
59 return 1;
60 }
61
62 TQString inputFile( args->arg( 0 ) );
63
64 TQFile file( inputFile );
65 if ( !file.open( IO_ReadOnly ) ) {
66 tqDebug( "Unable to open file '%s' for reading!", file.name().latin1() );
67 return 1;
68 }
69
70 TQString text;
71
72 TQTextStream s( &file );
73 s.setEncoding( TQTextStream::UnicodeUTF8 );
74 text = s.read();
75 file.close();
76
77 TDEABC::VCardConverter converter;
78 TDEABC::Addressee::List list = converter.parseVCards( text );
79
80 if ( args->isSet( "vcard21" ) ) {
81 text = converter.createVCards( list, TDEABC::VCardConverter::v2_1 ); // uses version 2.1
82 } else {
83 text = converter.createVCards( list ); // uses version 3.0
84 }
85
86 std::cout << text.utf8();
87
88 return 0;
89}
TDEABC::VCardConverter
Class to converting contact objects into vCard format and vice versa.
Definition: vcardconverter.h:54
TDEABC::VCardConverter::createVCards
TQString createVCards(Addressee::List list, Version version=v3_0)
Creates a string in vCard format which contains the given list of contact.
Definition: vcardconverter.cpp:54
TDEABC::VCardConverter::parseVCards
Addressee::List parseVCards(const TQString &vcard)
Parses a string in vCard format and returns a list of contact objects.
Definition: vcardconverter.cpp:68
TDEAboutData
TDEApplication
TDEApplication::disableAutoDcopRegistration
static void disableAutoDcopRegistration()
TDECmdLineArgs
TDECmdLineArgs::isSet
bool isSet(const char *option) const
TDECmdLineArgs::parsedArgs
static TDECmdLineArgs * parsedArgs(const char *id=0)
TDECmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const TDECmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
TDECmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noTDEApp=false)
TDECmdLineArgs::arg
const char * arg(int n) const
TDECmdLineArgs::count
int count() const
I18N_NOOP
#define I18N_NOOP(x)
endl
kndbgstream & endl(kndbgstream &s)
TDECmdLineOptions
tdelocale.h

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