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

tdeabc

testread.cpp

00001 /*
00002     This file is part of libtdeabc.
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <iostream>
00021 #include <stdlib.h>
00022 
00023 #include <tqfile.h>
00024 #include <tqtextstream.h>
00025 
00026 #include <kprocess.h>
00027 #include <kdebug.h>
00028 #include <tdeapplication.h>
00029 #include <tdecmdlineargs.h>
00030 #include <tdelocale.h>
00031 #include <tdeaboutdata.h>
00032 
00033 #include "tdeabc/vcardconverter.h"
00034 #include "vcard.h"
00035 
00036 static const TDECmdLineOptions options[] =
00037 {
00038   {"vcard21", I18N_NOOP("vCard 2.1"), 0},
00039   {"+inputfile", I18N_NOOP("Input file"), 0},
00040   TDECmdLineLastOption
00041 };
00042 
00043 int main( int argc, char **argv )
00044 {
00045   TDEApplication::disableAutoDcopRegistration();
00046 
00047   TDEAboutData aboutData( "testread", "vCard test reader", "0.1" );
00048   aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
00049 
00050   TDECmdLineArgs::init( argc, argv, &aboutData );
00051   TDECmdLineArgs::addCmdLineOptions( options );
00052 
00053   TDEApplication app( false, false );
00054 
00055   TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
00056 
00057   if ( args->count() != 1 ) {
00058     std::cerr << "Missing argument" << std::endl;
00059     return 1;
00060   }
00061 
00062   TQString inputFile( args->arg( 0 ) );
00063 
00064   TQFile file( inputFile );
00065   if ( !file.open( IO_ReadOnly ) ) {
00066     tqDebug( "Unable to open file '%s' for reading!", file.name().latin1() );
00067     return 1;
00068   }
00069 
00070   TQString text;
00071 
00072   TQTextStream s( &file );
00073   s.setEncoding( TQTextStream::UnicodeUTF8 );
00074   text = s.read();
00075   file.close();
00076 
00077   TDEABC::VCardConverter converter;
00078   TDEABC::Addressee::List list = converter.parseVCards( text );
00079 
00080   if ( args->isSet( "vcard21" ) ) {
00081     text = converter.createVCards( list, TDEABC::VCardConverter::v2_1 ); // uses version 2.1
00082   } else {
00083     text = converter.createVCards( list ); // uses version 3.0
00084   }
00085 
00086   std::cout << text.utf8();
00087 
00088   return 0;
00089 }

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