From ed99a30644c19b0a3cf0d2147243532df4daa16b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 15 Feb 2013 21:57:54 -0600 Subject: Rename additional header files to avoid conflicts with KDE4 --- kabc/vcardparser/CMakeLists.txt | 40 ----- kabc/vcardparser/Makefile.am | 31 ---- kabc/vcardparser/README.testing | 15 -- kabc/vcardparser/checkvcard.pl | 75 -------- kabc/vcardparser/testread.cpp | 89 ---------- kabc/vcardparser/testread2.cpp | 42 ----- kabc/vcardparser/tests/vcard1.vcf | 13 -- kabc/vcardparser/tests/vcard1.vcf.ref | 15 -- kabc/vcardparser/tests/vcard2.vcf | 11 -- kabc/vcardparser/tests/vcard2.vcf.ref | 12 -- kabc/vcardparser/tests/vcard3.vcf | 11 -- kabc/vcardparser/tests/vcard3.vcf.ref | 12 -- kabc/vcardparser/tests/vcard4.vcf | 14 -- kabc/vcardparser/tests/vcard4.vcf.ref | 14 -- kabc/vcardparser/tests/vcard5.vcf | 313 ---------------------------------- kabc/vcardparser/tests/vcard5.vcf.ref | 313 ---------------------------------- kabc/vcardparser/tests/vcard6.vcf | 10 -- kabc/vcardparser/tests/vcard6.vcf.ref | 10 -- kabc/vcardparser/tests/vcard7.vcf | 7 - kabc/vcardparser/tests/vcard7.vcf.ref | 8 - kabc/vcardparser/testutils.cpp | 99 ----------- kabc/vcardparser/testutils.h | 14 -- kabc/vcardparser/testwrite.cpp | 134 --------------- kabc/vcardparser/vcard.cpp | 109 ------------ kabc/vcardparser/vcard.h | 91 ---------- kabc/vcardparser/vcardline.cpp | 151 ---------------- kabc/vcardparser/vcardline.h | 115 ------------- kabc/vcardparser/vcardparser.cpp | 297 -------------------------------- kabc/vcardparser/vcardparser.h | 44 ----- 29 files changed, 2109 deletions(-) delete mode 100644 kabc/vcardparser/CMakeLists.txt delete mode 100644 kabc/vcardparser/Makefile.am delete mode 100644 kabc/vcardparser/README.testing delete mode 100755 kabc/vcardparser/checkvcard.pl delete mode 100644 kabc/vcardparser/testread.cpp delete mode 100644 kabc/vcardparser/testread2.cpp delete mode 100644 kabc/vcardparser/tests/vcard1.vcf delete mode 100644 kabc/vcardparser/tests/vcard1.vcf.ref delete mode 100644 kabc/vcardparser/tests/vcard2.vcf delete mode 100644 kabc/vcardparser/tests/vcard2.vcf.ref delete mode 100644 kabc/vcardparser/tests/vcard3.vcf delete mode 100644 kabc/vcardparser/tests/vcard3.vcf.ref delete mode 100644 kabc/vcardparser/tests/vcard4.vcf delete mode 100644 kabc/vcardparser/tests/vcard4.vcf.ref delete mode 100644 kabc/vcardparser/tests/vcard5.vcf delete mode 100644 kabc/vcardparser/tests/vcard5.vcf.ref delete mode 100644 kabc/vcardparser/tests/vcard6.vcf delete mode 100644 kabc/vcardparser/tests/vcard6.vcf.ref delete mode 100644 kabc/vcardparser/tests/vcard7.vcf delete mode 100644 kabc/vcardparser/tests/vcard7.vcf.ref delete mode 100644 kabc/vcardparser/testutils.cpp delete mode 100644 kabc/vcardparser/testutils.h delete mode 100644 kabc/vcardparser/testwrite.cpp delete mode 100644 kabc/vcardparser/vcard.cpp delete mode 100644 kabc/vcardparser/vcard.h delete mode 100644 kabc/vcardparser/vcardline.cpp delete mode 100644 kabc/vcardparser/vcardline.h delete mode 100644 kabc/vcardparser/vcardparser.cpp delete mode 100644 kabc/vcardparser/vcardparser.h (limited to 'kabc/vcardparser') diff --git a/kabc/vcardparser/CMakeLists.txt b/kabc/vcardparser/CMakeLists.txt deleted file mode 100644 index 2c6fa112a..000000000 --- a/kabc/vcardparser/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - vcard.h vcardline.h vcardparser.h - DESTINATION ${INCLUDE_INSTALL_DIR}/kabc ) - - -##### vcards #################################### - -set( target vcards ) - -set( ${target}_SRCS - vcard.cpp vcardline.cpp vcardparser.cpp -) - -tde_add_library( ${target} STATIC_PIC - SOURCES ${${target}_SRCS} -) diff --git a/kabc/vcardparser/Makefile.am b/kabc/vcardparser/Makefile.am deleted file mode 100644 index 53e4e42ab..000000000 --- a/kabc/vcardparser/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -INCLUDES = -I$(top_builddir)/kabc -I$(top_srcdir)/kabc $(all_includes) - -noinst_LTLIBRARIES = libvcards.la -libvcards_la_SOURCES = vcard.cpp vcardline.cpp vcardparser.cpp - -vcardsincludedir = $(includedir)/kabc -vcardsinclude_HEADERS = vcard.h vcardline.h vcardparser.h - -check_PROGRAMS = testread testwrite testread2 - -testread_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -testread_LDADD = libvcards.la $(top_builddir)/kabc/libkabc.la -testread_SOURCES = testread.cpp - -testread2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -testread2_LDADD = libvcards.la $(top_builddir)/kabc/libkabc.la -testread2_SOURCES = testread2.cpp testutils.cpp - -testwrite_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -testwrite_LDADD = libvcards.la $(top_builddir)/kabc/libkabc.la -testwrite_SOURCES = testwrite.cpp - -TESTFILES = vcard1.vcf vcard2.vcf vcard3.vcf vcard4.vcf vcard6.vcf vcard7.vcf - -check-local: testread - rm -f FAILED; \ - for i in $(TESTFILES); \ - do perl $(top_srcdir)/kabc/vcardparser/checkvcard.pl \ - $(top_srcdir)/kabc/vcardparser/tests/$$i; \ - done; \ - [ ! -e FAILED ] diff --git a/kabc/vcardparser/README.testing b/kabc/vcardparser/README.testing deleted file mode 100644 index a7794931d..000000000 --- a/kabc/vcardparser/README.testing +++ /dev/null @@ -1,15 +0,0 @@ -For testing the vcardparser there are some test files and a small testsuite -automatically checking for regressions. The tests directory contains some vCard -files and correpsonding reference output files (with an additional ".ref" -suffix). For running the geression test do "make check". This will compile some -test programs, parse the test files, write them out as vCard again and compare -the output to the reference file. The check fails, if there are unexpected -differences and shows which lines differed. - -For creating a new test put a vCard file to be parsed into the tests directory. -Create a reference file by running "testread" on the test file. It will put out -the parsed data as vCard again on stdout. Carefully check the output, manually -correct any errors and save the result as reference file in the tests directory. -Now add the filename to the TESTFILES variable in Makefile.am and run "make -check". If the check fails adapt the reference file or fix the bugs in the -parser, whatever is appropriate. diff --git a/kabc/vcardparser/checkvcard.pl b/kabc/vcardparser/checkvcard.pl deleted file mode 100755 index 67160ea4a..000000000 --- a/kabc/vcardparser/checkvcard.pl +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl - -if ( @ARGV != 1 ) { - print STDERR "Missing arg: filename\n"; - exit 1; -} - -$file = $ARGV[0]; - -if ( !open( IN, "$file" ) ) { - print STDERR "Unable to open '$file'\n"; - exit 1; -} - -while( ) { - if (/^VERSION:(.*)$/ ) { - $version = $1; - if ( $version eq "2.1" ) { $options = "--vcard21"; } - } -} - -close IN; - -$ref = "$file.ref"; - -if ( !open( REF, "$ref" ) ) { - print STDERR "Unable to open $ref\n"; - exit 1; -} - -while( ) { - push @ref, $_; -} - -close REF; - -if ( !open( READ, "./testread $file $options 2> /dev/null |" ) ) { - print STDERR "Unable to open testread\n"; - exit 1; -} - -print "Checking '$file':\n"; - -$gotsomething = 0; -$error = 0; -$i = 0; -while( ) { - $gotsomething = 1; - $out = $_; - $ref = @ref[$i++]; - - if ( $out ne $ref ) { - if ( $ref =~ /^UID/ && $out =~ /^UID/ ) { next; } - $error++; - print " Expected : $ref"; - print " Parser output : $out"; - } -} - -close READ; - -if ( $gotsomething == 0 ) { - print "\n FAILED: testread didn't output anything\n"; - system "touch FAILED"; - exit 1; -} -if ( $error > 0 ) { - print "\n FAILED: $error errors found.\n"; - system "touch FAILED"; - exit 1; -} else { - print " OK\n"; -} - -exit 0; diff --git a/kabc/vcardparser/testread.cpp b/kabc/vcardparser/testread.cpp deleted file mode 100644 index 6c3405ef9..000000000 --- a/kabc/vcardparser/testread.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - This file is part of libkabc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "vcardconverter.h" -#include "vcard.h" - -static const TDECmdLineOptions options[] = -{ - {"vcard21", I18N_NOOP("vCard 2.1"), 0}, - {"+inputfile", I18N_NOOP("Input file"), 0}, - TDECmdLineLastOption -}; - -int main( int argc, char **argv ) -{ - TDEApplication::disableAutoDcopRegistration(); - - TDEAboutData aboutData( "testread", "vCard test reader", "0.1" ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - TDECmdLineArgs::addCmdLineOptions( options ); - - TDEApplication app( false, false ); - - TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - - if ( args->count() != 1 ) { - std::cerr << "Missing argument" << std::endl; - return 1; - } - - TQString inputFile( args->arg( 0 ) ); - - TQFile file( inputFile ); - if ( !file.open( IO_ReadOnly ) ) { - tqDebug( "Unable to open file '%s' for reading!", file.name().latin1() ); - return 1; - } - - TQString text; - - TQTextStream s( &file ); - s.setEncoding( TQTextStream::Latin1 ); - text = s.read(); - file.close(); - - KABC::VCardConverter converter; - KABC::Addressee::List list = converter.parseVCards( text ); - - if ( args->isSet( "vcard21" ) ) { - text = converter.createVCards( list, KABC::VCardConverter::v2_1 ); // uses version 2.1 - } else { - text = converter.createVCards( list ); // uses version 3.0 - } - - std::cout << text.utf8(); - - return 0; -} diff --git a/kabc/vcardparser/testread2.cpp b/kabc/vcardparser/testread2.cpp deleted file mode 100644 index ba73081e7..000000000 --- a/kabc/vcardparser/testread2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "testutils.h" -#include -#include -#include - -using namespace KABC; - -int -main() -{ - Addressee::List l = vCardsAsAddresseeList(); - TQString vcards = vCardsAsText(); - - VCardConverter vct; - - Addressee::List parsed = vct.parseVCards( vcards ); - - if ( l.size() != parsed.size() ) { - kdDebug()<<"\tSize - FAILED : "< -#include -#include - -using namespace KABC; - -Addressee -vcard1() -{ - Addressee addr; - - addr.setName( "Frank Dawson" ); - addr.setOrganization( "Lotus Development Corporation" ); - addr.setUrl( KURL( "http://home.earthlink.net/~fdawson") ); - addr.insertEmail( "fdawson@earthlink.net" ); - addr.insertEmail( "Frank_Dawson@Lotus.com", true ); - addr.insertPhoneNumber( PhoneNumber("+1-919-676-9515",PhoneNumber::Voice|PhoneNumber::Msg - |PhoneNumber::Work ) ); - addr.insertPhoneNumber( PhoneNumber("+1-919-676-9564",PhoneNumber::Fax |PhoneNumber::Work )); - Address a( Address::Work | Address::Postal | Address::Parcel ); - a.setStreet( "6544 Battleford Drive" ); - a.setLocality( "Raleigh" ); - a.setRegion( "NC" ); - a.setPostalCode( "27613-3502" ); - a.setCountry( "U.S.A." ); - addr.insertAddress( a ); - return addr; -} - -Addressee -vcard2() -{ - Addressee addr; - - addr.setName( "Tim Howes" ); - addr.setOrganization( "Netscape Communications Corp." ); - addr.insertEmail( "howes@netscape.com" ); - addr.insertPhoneNumber( PhoneNumber("+1-415-937-3419",PhoneNumber::Voice|PhoneNumber::Msg - |PhoneNumber::Work) ); - addr.insertPhoneNumber( PhoneNumber("+1-415-528-4164",PhoneNumber::Fax |PhoneNumber::Work) ); - Address a( Address::Work ); - a.setStreet( "501 E. Middlefield Rd." ); - a.setLocality( "Mountain View" ); - a.setRegion( "CA" ); - a.setPostalCode( "94043" ); - a.setCountry( "U.S.A." ); - addr.insertAddress( a ); - return addr; -} - -Addressee -vcard3() -{ - Addressee addr; - - addr.setName( "ian geiser" ); - addr.setOrganization( "Source eXtreme" ); - addr.insertEmail( "geiseri@yahoo.com" ); - addr.setTitle( "VP of Engineering" ); - return addr; -} - - -QString -vcardAsText( const TQString& location ) -{ - TQString line; - TQFile file( location ); - if ( file.open( IO_ReadOnly ) ) { - TQTextStream stream( &file ); - if ( !stream.eof() ) { - line = stream.read(); - } - file.close(); - } - return line; -} - -Addressee::List -vCardsAsAddresseeList() -{ - Addressee::List l; - - l.append( vcard1() ); - l.append( vcard2() ); - l.append( vcard3() ); - - return l; -} - -QString -vCardsAsText() -{ - TQString vcards = vcardAsText( "tests/vcard1.vcf" ); - vcards += vcardAsText( "tests/vcard2.vcf" ); - vcards += vcardAsText( "tests/vcard3.vcf" ); - - return vcards; -} diff --git a/kabc/vcardparser/testutils.h b/kabc/vcardparser/testutils.h deleted file mode 100644 index 4f2024177..000000000 --- a/kabc/vcardparser/testutils.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TESTUTILS_H -#define TESTUTILS_H - -#include -#include - -KABC::Addressee vcard1(); -KABC::Addressee vcard2(); -KABC::Addressee vcard3(); -KABC::Addressee::List vCardsAsAddresseeList(); -TQString vCardAsText( const TQString& location ); -TQString vCardsAsText(); - -#endif diff --git a/kabc/vcardparser/testwrite.cpp b/kabc/vcardparser/testwrite.cpp deleted file mode 100644 index 5a58bd8a8..000000000 --- a/kabc/vcardparser/testwrite.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - This file is part of libkabc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "vcardconverter.h" - -int main( int argc, char **argv ) -{ - TDEAboutData aboutData( "testwrite", "vCard test writer", "0.1" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - - TDEApplication app( false, false ); - - - KABC::Addressee addressee; - - addressee.setNameFromString( "Mr. Tobias Koenig Jr." ); - addressee.setNickName( "tokoe" ); - addressee.setBirthday( TQDate( 1982, 7, 19 ) ); - addressee.setMailer( "mutt1.2" ); - addressee.setTimeZone( KABC::TimeZone( +2 ) ); - - KABC::Geo geo; - geo.setLatitude( 30 ); - geo.setLongitude( 51 ); - addressee.setGeo( geo ); - - addressee.setTitle( "nerd" ); - addressee.setRole( "Maintainer" ); - addressee.setOrganization( "KDE" ); - addressee.setNote( "nerver\ntouch a running system" ); - addressee.setProductId( "testId" ); - addressee.setRevision( TQDateTime::currentDateTime() ); - addressee.setSortString( "koenig" ); - addressee.setUrl( KURL( "http://wgess16.dyndns.org") ); - addressee.setSecrecy( KABC::Secrecy( KABC::Secrecy::Confidential ) ); -/* - TQImage img; - img.load( "testimg.png", "PNG" ); - KABC::Picture photo; - photo.setData( img ); - addressee.setPhoto( photo ); - - TQImage img2; - img2.load( "testimg.png", "PNG" ); - KABC::Picture logo; - logo.setData( img2 ); - addressee.setLogo( logo ); - - TQFile soundFile( "testsound.wav" ); - soundFile.open( IO_ReadOnly ); - TQByteArray data = soundFile.readAll(); - soundFile.close(); - KABC::Sound sound; - sound.setData( data ); - addressee.setSound( sound ); -*/ - addressee.insertEmail( "tokoe@kde.org", true ); - addressee.insertEmail( "tokoe82@yahoo.de", true ); - - KABC::PhoneNumber phone1( "3541523475", KABC::PhoneNumber::Pref | KABC::PhoneNumber::Home ); - KABC::PhoneNumber phone2( "+46745673475", KABC::PhoneNumber::Work ); - addressee.insertPhoneNumber( phone1 ); - addressee.insertPhoneNumber( phone2 ); - - KABC::Key key( "secret key", KABC::Key::X509 ); - addressee.insertKey( key ); - - TQStringList categories; - categories << "Friends" << "School" << "KDE"; - addressee.setCategories( categories ); - - KABC::Address a( KABC::Address::Work | KABC::Address::Postal | KABC::Address::Parcel ); - a.setStreet( "6544 Battleford Drive" ); - a.setLocality( "Raleigh" ); - a.setRegion( "NC" ); - a.setPostalCode( "27613-3502" ); - a.setCountry( "U.S.A." ); - addressee.insertAddress( a ); - - addressee.insertCustom( "1hsdf", "ertuer", "iurt" ); - addressee.insertCustom( "2hsdf", "ertuer", "iurt" ); - addressee.insertCustom( "3hsdf", "ertuer", "iurt" ); - - KABC::Addressee::List list; - for ( int i = 0; i < 1000; ++i ) { - KABC::Addressee addr = addressee; - addr.setUid( TQString::number( i ) ); - list.append( addr ); - } - - KABC::VCardConverter converter; - TQString txt = converter.createVCards( list ); - - TQFile file( "out.vcf" ); - file.open( IO_WriteOnly ); - - TQTextStream s( &file ); - s.setEncoding( TQTextStream::UnicodeUTF8 ); - s << txt; - file.close(); - - return 0; -} diff --git a/kabc/vcardparser/vcard.cpp b/kabc/vcardparser/vcard.cpp deleted file mode 100644 index 30a8e1c49..000000000 --- a/kabc/vcardparser/vcard.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2003 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "vcard.h" - -using namespace KABC; - -VCard::VCard() -{ -} - -VCard::VCard( const VCard& vcard ) -{ - mLineMap = vcard.mLineMap; -} - -VCard::~VCard() -{ -} - -VCard& VCard::operator=( const VCard& vcard ) -{ - if ( &vcard == this ) - return *this; - - mLineMap = vcard.mLineMap; - - return *this; -} - -void VCard::clear() -{ - mLineMap.clear(); -} - -TQStringList VCard::identifiers() const -{ - return mLineMap.keys(); -} - -void VCard::addLine( const VCardLine& line ) -{ - mLineMap[ line.identifier() ].append( line ); -} - -VCardLine::List VCard::lines( const TQString& identifier ) const -{ - LineMap::ConstIterator it = mLineMap.find( identifier ); - if ( it == mLineMap.end() ) - return VCardLine::List(); - - return *it; -} - -VCardLine VCard::line( const TQString& identifier ) const -{ - LineMap::ConstIterator it = mLineMap.find( identifier ); - if ( it == mLineMap.end() ) - return VCardLine(); - - if ( (*it).isEmpty() ) - return VCardLine(); - else - return (*it).first(); -} - -void VCard::setVersion( Version version ) -{ - mLineMap.erase( "VERSION" ); - - VCardLine line; - line.setIdentifier( "VERSION" ); - if ( version == v2_1 ) - line.setIdentifier( "2.1" ); - else if ( version == v3_0 ) - line.setIdentifier( "3.0" ); - - mLineMap[ "VERSION" ].append( line ); -} - -VCard::Version VCard::version() const -{ - LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" ); - if ( versionEntry == mLineMap.end() ) - return v3_0; - - VCardLine line = ( *versionEntry )[ 0 ]; - if ( line.value() == "2.1" ) - return v2_1; - else - return v3_0; -} diff --git a/kabc/vcardparser/vcard.h b/kabc/vcardparser/vcard.h deleted file mode 100644 index 6afeeda26..000000000 --- a/kabc/vcardparser/vcard.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2003 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef VCARDPARSER_VCARD_H -#define VCARDPARSER_VCARD_H - -#include "vcardline.h" -#include -#include -#include - -namespace KABC { - -class VCard -{ - public: - typedef TQValueList List; - typedef TQMap< TQString, VCardLine::List > LineMap; - - enum Version { v2_1, v3_0 }; - - VCard(); - VCard( const VCard& ); - - ~VCard(); - - VCard& operator=( const VCard& ); - - /** - * Removes all lines from the vCard. - */ - void clear(); - - /** - * Returns a list of all identifiers that exists in the - * vCard. - */ - TQStringList identifiers() const; - - /** - * Adds a VCardLine to the VCard - */ - void addLine( const VCardLine& line ); - - /** - * Returns all lines of the vcard with a special identifier. - */ - VCardLine::List lines( const TQString& identifier ) const; - - /** - * Returns only the first line of the vcard with a special identifier. - */ - VCardLine line( const TQString& identifier ) const; - - /** - * Set the version of the vCard. - */ - void setVersion( Version version ); - - /** - * Returns the version of this vCard. - */ - Version version() const; - - private: - LineMap mLineMap; - - class VCardPrivate; - VCardPrivate *d; -}; - -} - -#endif diff --git a/kabc/vcardparser/vcardline.cpp b/kabc/vcardparser/vcardline.cpp deleted file mode 100644 index 6680cf7d0..000000000 --- a/kabc/vcardparser/vcardline.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2003 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "vcardline.h" - -using namespace KABC; - -class VCardLine::VCardLinePrivate -{ - public: - TQString mGroup; -}; - -VCardLine::VCardLine() - : d( 0 ) -{ -} - -VCardLine::VCardLine( const TQString &identifier ) - : d( 0 ) -{ - mIdentifier = identifier; -} - -VCardLine::VCardLine( const TQString &identifier, const TQVariant &value ) - : d( 0 ) -{ - mIdentifier = identifier; - mValue = value; -} - -VCardLine::VCardLine( const VCardLine& line ) - : d( 0 ) -{ - mParamMap = line.mParamMap; - mValue = line.mValue; - mIdentifier = line.mIdentifier; -} - -VCardLine::~VCardLine() -{ - delete d; - d = 0; -} - -VCardLine& VCardLine::operator=( const VCardLine& line ) -{ - if ( &line == this ) - return *this; - - mParamMap = line.mParamMap; - mValue = line.mValue; - mIdentifier = line.mIdentifier; - - return *this; -} - -void VCardLine::setIdentifier( const TQString& identifier ) -{ - mIdentifier = identifier; -} - -TQString VCardLine::identifier() const -{ - return mIdentifier; -} - -void VCardLine::setValue( const TQVariant& value ) -{ - mValue = value; -} - -TQVariant VCardLine::value() const -{ - return mValue; -} - -void VCardLine::setGroup( const TQString& group ) -{ - if ( !d ) - d = new VCardLinePrivate(); - - d->mGroup = group; -} - -TQString VCardLine::group() const -{ - if ( d ) - return d->mGroup; - else - return TQString(); -} - -bool VCardLine::hasGroup() const -{ - if ( !d ) - return false; - else - return d->mGroup.isEmpty(); -} - -TQStringList VCardLine::parameterList() const -{ - return mParamMap.keys(); -} - -void VCardLine::addParameter( const TQString& param, const TQString& value ) -{ - TQStringList &list = mParamMap[ param ]; - if ( list.findIndex( value ) == -1 ) // not included yet - list.append( value ); -} - -TQStringList VCardLine::parameters( const TQString& param ) const -{ - ParamMap::ConstIterator it = mParamMap.find( param ); - if ( it == mParamMap.end() ) - return TQStringList(); - else - return *it; -} - -TQString VCardLine::parameter( const TQString& param ) const -{ - ParamMap::ConstIterator it = mParamMap.find( param ); - if ( it == mParamMap.end() ) - return TQString::null; - else { - if ( (*it).isEmpty() ) - return TQString::null; - else - return (*it).first(); - } -} diff --git a/kabc/vcardparser/vcardline.h b/kabc/vcardparser/vcardline.h deleted file mode 100644 index 92fe743f6..000000000 --- a/kabc/vcardparser/vcardline.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2003 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef VCARDLINE_H -#define VCARDLINE_H - -#include -#include -#include -#include -#include - -namespace KABC { - -class VCardLine -{ - public: - typedef TQValueList List; - typedef TQMap ParamMap; - - VCardLine(); - VCardLine( const TQString &identifier ); - VCardLine( const TQString &identifier, const TQVariant &value ); - VCardLine( const VCardLine& ); - - ~VCardLine(); - - VCardLine& operator=( const VCardLine& ); - - /** - * Sets the identifier of this line e.g. UID, FN, CLASS - */ - void setIdentifier( const TQString& identifier ); - - /** - * Returns the identifier of this line. - */ - TQString identifier() const; - - /** - * Sets the value of of this line. - */ - void setValue( const TQVariant& value ); - - /** - * Returns the value of this line. - */ - TQVariant value() const; - - /** - * Sets the group the line belongs to. - */ - void setGroup( const TQString& group ); - - /** - * Returns the group the line belongs to. - */ - TQString group() const; - - /** - * Returns whether the line belongs to a group. - */ - bool hasGroup() const; - - /** - * Returns all parameters. - */ - TQStringList parameterList() const; - - /** - * Add a new parameter to the line. - */ - void addParameter( const TQString& param, const TQString& value ); - - /** - * Returns the values of a special parameter. - * You can get a list of all parameters with paramList(). - */ - TQStringList parameters( const TQString& param ) const; - - /** - * Returns only the first value of a special parameter. - * You can get a list of all parameters with paramList(). - */ - TQString parameter( const TQString& param ) const; - - private: - ParamMap mParamMap; - TQString mIdentifier; - TQVariant mValue; - - class VCardLinePrivate; - VCardLinePrivate *d; -}; - -} - -#endif diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp deleted file mode 100644 index aed9ebd39..000000000 --- a/kabc/vcardparser/vcardparser.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2003 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include - -#include "vcardparser.h" - -#define FOLD_WIDTH 75 - -using namespace KABC; - -static TQString backslash( "\\\\" ); -static TQString comma( "\\," ); -static TQString newline( "\\n" ); -static TQString cr( "\\r" ); - -static void addEscapes( TQString &str ) -{ - str.replace( '\\', backslash ); - str.replace( ',', comma ); - str.replace( '\r', cr ); - str.replace( '\n', newline ); -} - -static void removeEscapes( TQString &str ) -{ - str.replace( cr, "\\r" ); - str.replace( newline, "\n" ); - str.replace( comma, "," ); - str.replace( backslash, "\\" ); -} - -VCardParser::VCardParser() -{ -} - -VCardParser::~VCardParser() -{ -} - -VCard::List VCardParser::parseVCards( const TQString& text ) -{ - static TQRegExp sep( "[\x0d\x0a]" ); - - VCard currentVCard; - VCard::List vCardList; - TQString currentLine; - - const TQStringList lines = TQStringList::split( sep, text ); - TQStringList::ConstIterator it; - - bool inVCard = false; - TQStringList::ConstIterator linesEnd( lines.end() ); - for ( it = lines.begin(); it != linesEnd; ++it ) { - - if ( (*it).isEmpty() ) // empty line - continue; - - if ( (*it)[ 0 ] == ' ' || (*it)[ 0 ] == '\t' ) { // folded line => append to previous - currentLine += TQString( *it ).remove( 0, 1 ); - continue; - } else { - if ( inVCard && !currentLine.isEmpty() ) { // now parse the line - int colon = currentLine.find( ':' ); - if ( colon == -1 ) { // invalid line - currentLine = (*it); - continue; - } - - VCardLine vCardLine; - const TQString key = currentLine.left( colon ).stripWhiteSpace(); - TQString value = currentLine.mid( colon + 1 ); - - TQStringList params = TQStringList::split( ';', key ); - - // check for group - if ( params[0].find( '.' ) != -1 ) { - const TQStringList groupList = TQStringList::split( '.', params[0] ); - vCardLine.setGroup( groupList[0] ); - vCardLine.setIdentifier( groupList[1] ); - } else - vCardLine.setIdentifier( params[0] ); - - if ( params.count() > 1 ) { // find all parameters - TQStringList::ConstIterator paramIt = params.begin(); - for ( ++paramIt; paramIt != params.end(); ++paramIt ) { - TQStringList pair = TQStringList::split( '=', *paramIt ); - if ( pair.size() == 1 ) { - // correct the 2.1 'standard' - if ( pair[0].lower() == "quoted-printable" ) { - pair[0] = "encoding"; - pair[1] = "quoted-printable"; - } else if ( pair[0].lower() == "base64" ) { - pair[0] = "encoding"; - pair[1] = "base64"; - } else { - pair.prepend( "type" ); - } - } - // This is pretty much a faster pair[1].contains( ',' )... - if ( pair[1].find( ',' ) != -1 ) { // parameter in type=x,y,z format - const TQStringList args = TQStringList::split( ',', pair[ 1 ] ); - TQStringList::ConstIterator argIt; - for ( argIt = args.begin(); argIt != args.end(); ++argIt ) - vCardLine.addParameter( pair[0].lower(), *argIt ); - } else - vCardLine.addParameter( pair[0].lower(), pair[1] ); - } - } - - removeEscapes( value ); - - TQByteArray output; - bool wasBase64Encoded = false; - - params = vCardLine.parameterList(); - if ( params.findIndex( "encoding" ) != -1 ) { // have to decode the data - TQByteArray input; - input = TQCString(value.latin1()); - if ( vCardLine.parameter( "encoding" ).lower() == "b" || - vCardLine.parameter( "encoding" ).lower() == "base64" ) { - KCodecs::base64Decode( input, output ); - wasBase64Encoded = true; - } - else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) { - // join any qp-folded lines - while ( value.at( value.length() - 1 ) == '=' && it != linesEnd ) { - value = value.remove( value.length() - 1, 1 ) + (*it); - ++it; - } - input = TQCString(value.latin1()); - KCodecs::quotedPrintableDecode( input, output ); - } - } else { - output = TQCString(value.latin1()); - } - - if ( params.findIndex( "charset" ) != -1 ) { // have to convert the data - TQTextCodec *codec = - TQTextCodec::codecForName( vCardLine.parameter( "charset" ).latin1() ); - if ( codec ) { - vCardLine.setValue( codec->toUnicode( output ) ); - } else { - vCardLine.setValue( TQString(TQString::fromUtf8( output )) ); - } - } else if ( wasBase64Encoded ) { - vCardLine.setValue( output ); - } else { // if charset not given, assume it's in UTF-8 (as used in previous KDE versions) - vCardLine.setValue( TQString(TQString::fromUtf8( output )) ); - } - - currentVCard.addLine( vCardLine ); - } - - // we do not save the start and end tag as vcardline - if ( (*it).lower().startsWith( "begin:vcard" ) ) { - inVCard = true; - currentLine.setLength( 0 ); - currentVCard.clear(); // flush vcard - continue; - } - - if ( (*it).lower().startsWith( "end:vcard" ) ) { - inVCard = false; - vCardList.append( currentVCard ); - currentLine.setLength( 0 ); - currentVCard.clear(); // flush vcard - continue; - } - - currentLine = (*it); - } - } - - return vCardList; -} - -TQString VCardParser::createVCards( const VCard::List& list ) -{ - TQString text; - TQString textLine; - TQString encodingType; - TQStringList idents; - TQStringList params; - TQStringList values; - TQStringList::ConstIterator identIt; - TQStringList::Iterator paramIt; - TQStringList::ConstIterator valueIt; - - VCardLine::List lines; - VCardLine::List::ConstIterator lineIt; - VCard::List::ConstIterator cardIt; - - bool hasEncoding; - - text.reserve( list.size() * 300 ); // reserve memory to be more efficient - - // iterate over the cards - VCard::List::ConstIterator listEnd( list.end() ); - for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) { - text.append( "BEGIN:VCARD\r\n" ); - - idents = (*cardIt).identifiers(); - for ( identIt = idents.constBegin(); identIt != idents.constEnd(); ++identIt ) { - lines = (*cardIt).lines( (*identIt) ); - - // iterate over the lines - for ( lineIt = lines.constBegin(); lineIt != lines.constEnd(); ++lineIt ) { - if ( !(*lineIt).value().asString().isEmpty() ) { - if ((*lineIt).identifier() != TQString("URI")) { - if ( (*lineIt).hasGroup() ) - textLine = (*lineIt).group() + "." + (*lineIt).identifier(); - else - textLine = (*lineIt).identifier(); - - params = (*lineIt).parameterList(); - hasEncoding = false; - if ( params.count() > 0 ) { // we have parameters - for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) { - if ( (*paramIt) == "encoding" ) { - hasEncoding = true; - encodingType = (*lineIt).parameter( "encoding" ).lower(); - } - - values = (*lineIt).parameters( *paramIt ); - for ( valueIt = values.constBegin(); valueIt != values.constEnd(); ++valueIt ) { - textLine.append( ";" + (*paramIt).upper() ); - if ( !(*valueIt).isEmpty() ) - textLine.append( "=" + (*valueIt) ); - } - } - } - - if ( hasEncoding ) { // have to encode the data - TQByteArray input, output; - if ( encodingType == "b" ) { - input = (*lineIt).value().toByteArray(); - KCodecs::base64Encode( input, output ); - } else if ( encodingType == "quoted-printable" ) { - input = (*lineIt).value().toString().utf8(); - input.resize( input.size() - 1 ); // strip \0 - KCodecs::quotedPrintableEncode( input, output, false ); - } - - TQString value( output ); - addEscapes( value ); - textLine.append( ":" + value ); - } else { - TQString value( (*lineIt).value().asString() ); - addEscapes( value ); - textLine.append( ":" + value ); - } - - if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line - for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i ) - text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" ); - } else - text.append( textLine + "\r\n" ); - } - else { - // URIs can be full of weird symbols, etc. so bypass all checks - textLine = (*lineIt).identifier(); - TQString value( (*lineIt).value().asString() ); - addEscapes( value ); - textLine.append( ":" + value ); - text.append( textLine + "\r\n" ); - } - } - } - } - - text.append( "END:VCARD\r\n" ); - text.append( "\r\n" ); - } - - return text; -} diff --git a/kabc/vcardparser/vcardparser.h b/kabc/vcardparser/vcardparser.h deleted file mode 100644 index da5fdd46e..000000000 --- a/kabc/vcardparser/vcardparser.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2003 Tobias Koenig - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef VCARDPARSER_H -#define VCARDPARSER_H - -#include "vcard.h" - -namespace KABC { - -class VCardParser -{ - public: - VCardParser(); - ~VCardParser(); - - static VCard::List parseVCards( const TQString& text ); - static TQString createVCards( const VCard::List& list ); - - private: - class VCardParserPrivate; - VCardParserPrivate *d; -}; - -} - -#endif -- cgit v1.2.3