From 5159cd2beb2e87806a5b54e9991b7895285c9d3e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 01:04:16 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- kabc/CMakeLists.txt | 14 +- kabc/Makefile.am | 10 +- kabc/addresseehelper.cpp | 2 +- kabc/addresslineedit.cpp | 2 +- kabc/formatfactory.h | 2 +- kabc/formats/CMakeLists.txt | 4 +- kabc/kab2kabc.cpp | 476 ------------------------- kabc/kab2kabc.desktop | 105 ------ kabc/ldapclient.cpp | 2 +- kabc/ldapclient.h | 2 +- kabc/ldapconfigwidget.h | 2 +- kabc/plugins/dir/CMakeLists.txt | 6 +- kabc/plugins/dir/resourcedir.cpp | 2 +- kabc/plugins/dir/resourcedir.h | 2 +- kabc/plugins/file/CMakeLists.txt | 6 +- kabc/plugins/file/resourcefile.cpp | 4 +- kabc/plugins/file/resourcefile.h | 2 +- kabc/plugins/ldapkio/CMakeLists.txt | 8 +- kabc/plugins/ldapkio/resourceldapkio.cpp | 4 +- kabc/plugins/ldapkio/resourceldapkio.h | 2 +- kabc/plugins/ldapkio/resourceldapkioconfig.cpp | 2 +- kabc/plugins/net/CMakeLists.txt | 6 +- kabc/plugins/net/resourcenet.cpp | 4 +- kabc/plugins/net/resourcenet.h | 2 +- kabc/plugins/sql/resourcesql.h | 2 +- kabc/scripts/field.src.cpp | 2 +- kabc/tdeab2tdeabc.cpp | 476 +++++++++++++++++++++++++ kabc/tdeab2tdeabc.desktop | 105 ++++++ 28 files changed, 628 insertions(+), 628 deletions(-) delete mode 100644 kabc/kab2kabc.cpp delete mode 100644 kabc/kab2kabc.desktop create mode 100644 kabc/tdeab2tdeabc.cpp create mode 100644 kabc/tdeab2tdeabc.desktop (limited to 'kabc') diff --git a/kabc/CMakeLists.txt b/kabc/CMakeLists.txt index 5f2619cf9..57c4741fe 100644 --- a/kabc/CMakeLists.txt +++ b/kabc/CMakeLists.txt @@ -29,8 +29,8 @@ include_directories( ${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio ${CMAKE_SOURCE_DIR}/kab ) @@ -58,7 +58,7 @@ install( FILES ##### other data ################################ -install( FILES kab2kabc.desktop DESTINATION ${AUTOSTART_INSTALL_DIR} ) +install( FILES tdeab2tdeabc.desktop DESTINATION ${AUTOSTART_INSTALL_DIR} ) install( FILES kabc_manager.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources ) install( FILES countrytransl.map DESTINATION ${DATA_INSTALL_DIR}/kabc ) @@ -102,18 +102,18 @@ set( ${target}_SRCS tde_add_library( ${target} SHARED AUTOMOC SOURCES ${${target}_SRCS} VERSION 1.2.0 - LINK vcards-static vcard-shared kio-shared tderesources-shared + LINK vcards-static vcard-shared tdeio-shared tderesources-shared DEPENDENCIES addressee.h dcopidl DESTINATION ${LIB_INSTALL_DIR} ) -##### kab2kabc ################################## +##### tdeab2tdeabc ################################## -set( target kab2kabc ) +set( target tdeab2tdeabc ) set( ${target}_SRCS - kab2kabc.cpp + tdeab2tdeabc.cpp ) tde_add_executable( ${target} diff --git a/kabc/Makefile.am b/kabc/Makefile.am index ef989662f..57e72aec2 100644 --- a/kabc/Makefile.am +++ b/kabc/Makefile.am @@ -50,13 +50,13 @@ kabcinclude_HEADERS = address.h addressbook.h addressee.h addresseedialog.h \ METASOURCES = AUTO -bin_PROGRAMS = kab2kabc +bin_PROGRAMS = tdeab2tdeabc -kab2kabc_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -kab2kabc_LDADD = libkabc.la ../kab/libkab.la -kab2kabc_SOURCES = kab2kabc.cpp +tdeab2tdeabc_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +tdeab2tdeabc_LDADD = libkabc.la ../kab/libkab.la +tdeab2tdeabc_SOURCES = tdeab2tdeabc.cpp -autostart_DATA = kab2kabc.desktop +autostart_DATA = tdeab2tdeabc.desktop autostartdir = $(datadir)/autostart manager_DATA = kabc_manager.desktop diff --git a/kabc/addresseehelper.cpp b/kabc/addresseehelper.cpp index 908795869..5b8998852 100644 --- a/kabc/addresseehelper.cpp +++ b/kabc/addresseehelper.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include #include "addresseehelper.h" diff --git a/kabc/addresslineedit.cpp b/kabc/addresslineedit.cpp index 76d99f634..efb0738aa 100644 --- a/kabc/addresslineedit.cpp +++ b/kabc/addresslineedit.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include #include diff --git a/kabc/formatfactory.h b/kabc/formatfactory.h index 76a3704d5..ff9da5504 100644 --- a/kabc/formatfactory.h +++ b/kabc/formatfactory.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "formatplugin.h" diff --git a/kabc/formats/CMakeLists.txt b/kabc/formats/CMakeLists.txt index 327cb1ea6..60ea1c3fd 100644 --- a/kabc/formats/CMakeLists.txt +++ b/kabc/formats/CMakeLists.txt @@ -18,8 +18,8 @@ include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio ) link_directories( diff --git a/kabc/kab2kabc.cpp b/kabc/kab2kabc.cpp deleted file mode 100644 index 11b80639a..000000000 --- a/kabc/kab2kabc.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/* - This file is part of libkabc. - Copyright (c) 2001 Cornelius Schumacher - - 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 "addressbook.h" -#include "stdaddressbook.h" - -using namespace KABC; - -static const KCmdLineOptions options[] = -{ - { "disable-autostart", I18N_NOOP( "Disable automatic startup on login" ), 0 }, - { "quiet", "", 0 }, - { "o", 0, 0 }, - { "override", I18N_NOOP( "Override existing entries" ), "1" }, - KCmdLineLastOption -}; - -void readKMailEntry( const TQString &kmailEntry, KABC::AddressBook *ab ) -{ - kdDebug() << "KMAILENTRY: " << kmailEntry << endl; - - TQString entry = kmailEntry.simplifyWhiteSpace(); - if ( entry.isEmpty() ) return; - - TQString email; - TQString name; - TQString comment; - - if ( entry.at( entry.length() -1 ) == ')' ) { - int br = entry.findRev( '(' ); - if ( br >= 0 ) { - comment = entry.mid( br + 1, entry.length() - br - 2 ); - entry.truncate( br ); - if ( entry.at( entry.length() - 1 ).isSpace() ) { - entry.truncate( br - 1 ); - } - } - } - - int posSpace = entry.findRev( ' ' ); - if ( posSpace < 0 ) { - email = entry; - if ( !comment.isEmpty() ) { - name = comment; - comment = ""; - } - } else { - email = entry.mid( posSpace + 1 ); - name = entry.left( posSpace ); - } - - if ( email.at( 0 ) == '<' && email.at( email.length() - 1) == '>' ) { - email = email.mid( 1, email.length() - 2 ); - } - if ( name.at( 0 ) == '"' && name.at( name.length() - 1) == '"' ) { - name = name.mid( 1, name.length() - 2 ); - } - if ( name.at( 0 ) == '\'' && name.at( name.length() - 1) == '\'' ) { - name = name.mid( 1, name.length() - 2 ); - } - - if ( name.at( name.length() -1 ) == ')' ) { - int br = name.findRev( '(' ); - if ( br >= 0 ) { - comment = name.mid( br + 1, name.length() - br - 2 ) + " " + comment; - name.truncate( br ); - if ( name.at( name.length() - 1 ).isSpace() ) { - name.truncate( br - 1 ); - } - } - } - - kdDebug() << " EMAIL : " << email << endl; - kdDebug() << " NAME : " << name << endl; - kdDebug() << " COMMENT : " << comment << endl; - - KABC::Addressee::List al = ab->findByEmail( email ); - if ( al.isEmpty() ) { - KABC::Addressee a; - a.setNameFromString( name ); - a.insertEmail( email ); - a.setNote( comment ); - - ab->insertAddressee( a ); - - kdDebug() << "--INSERTED: " << a.realName() << endl; - } -} - -void importKMailAddressBook( KABC::AddressBook *ab ) -{ - TQString fileName = locateLocal( "data", "kmail/addressbook" ); - TQString kmailConfigName = locate( "config", "kmailrc" ); - if ( !kmailConfigName.isEmpty() ) { - TDEConfig cfg( kmailConfigName ); - cfg.setGroup( "Addressbook" ); - fileName = cfg.readPathEntry( "default", fileName ); - } - if ( !KStandardDirs::exists( fileName ) ) { - kdDebug(5700) << "Couldn't find KMail addressbook." << endl; - return; - } - - TQFile f( fileName ); - if ( !f.open(IO_ReadOnly) ) { - kdDebug(5700) << "Couldn't open file '" << fileName << "'" << endl; - return; - } - - TQStringList kmailEntries; - - TQTextStream t( &f ); - while ( !t.eof() ) { - kmailEntries.append( t.readLine() ); - } - f.close(); - - TQStringList::ConstIterator it; - for ( it = kmailEntries.begin(); it != kmailEntries.end(); ++it ) { - if ( (*it).at( 0 ) == '#' ) continue; - bool insideQuote = false; - int end = (*it).length() - 1; - for ( int i = end; i; i-- ) { - if ( (*it).at( i ) == '"' ) { - if ( insideQuote ) - insideQuote = false; - else - insideQuote = true; - } else if ( (*it).at( i ) == ',' && !insideQuote ) { - readKMailEntry( (*it).mid( i + 1, end - i ), ab ); - end = i - 1; - } - } - - readKMailEntry( (*it).mid( 0, end + 1 ), ab ); - } -} - -void readKAddressBookEntries( const TQString &dataString, Addressee &a ) -{ - // Strip "KMail:1.0" prefix and "[EOS]" suffix. - TQString str = dataString.mid( 11, dataString.length() - 24 ); - - TQStringList entries = TQStringList::split( "\n[EOR]\n ", str ); - - Address homeAddress( Address::Home ); - Address businessAddress( Address::Work ); - Address otherAddress; - - TQStringList::ConstIterator it; - for ( it = entries.begin(); it != entries.end(); ++it ) { - int pos = (*it).find( "\n" ); - TQString fieldName = (*it).left( pos ); - TQString fieldValue = (*it).mid( pos + 2 ); - - if ( fieldName == "X-HomeFax" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Home | - PhoneNumber::Fax ) ); - } else if ( fieldName == "X-OtherPhone" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, 0 ) ); - } else if ( fieldName == "X-PrimaryPhone" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Pref ) ); - } else if ( fieldName == "X-BusinessFax" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Work | - PhoneNumber::Fax ) ); - } else if ( fieldName == "X-CarPhone" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Car ) ); - } else if ( fieldName == "X-MobilePhone" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Cell ) ); - } else if ( fieldName == "X-ISDN" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Isdn ) ); - } else if ( fieldName == "X-OtherFax" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Fax ) ); - } else if ( fieldName == "X-Pager" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Pager ) ); - } else if ( fieldName == "X-BusinessPhone" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Work ) ); - } else if ( fieldName == "X-HomePhone" ) { - a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Home ) ); - } else if ( fieldName == "X-HomeAddress" ) { - homeAddress.setLabel( fieldValue ); - } else if ( fieldName == "X-HomeAddressStreet" ) { - homeAddress.setStreet( fieldValue ); - } else if ( fieldName == "X-HomeAddressCity" ) { - homeAddress.setLocality( fieldValue ); - } else if ( fieldName == "X-HomeAddressPostalCode" ) { - homeAddress.setPostalCode( fieldValue ); - } else if ( fieldName == "X-HomeAddressState" ) { - homeAddress.setRegion( fieldValue ); - } else if ( fieldName == "X-HomeAddressCountry" ) { - homeAddress.setCountry( fieldValue ); - } else if ( fieldName == "X-BusinessAddress" ) { - businessAddress.setLabel( fieldValue ); - } else if ( fieldName == "X-BusinessAddressStreet" ) { - businessAddress.setStreet( fieldValue ); - } else if ( fieldName == "X-BusinessAddressCity" ) { - businessAddress.setLocality( fieldValue ); - } else if ( fieldName == "X-BusinessAddressPostalCode" ) { - businessAddress.setPostalCode( fieldValue ); - } else if ( fieldName == "X-BusinessAddressState" ) { - businessAddress.setRegion( fieldValue ); - } else if ( fieldName == "X-BusinessAddressCountry" ) { - businessAddress.setCountry( fieldValue ); - } else if ( fieldName == "X-OtherAddress" ) { - otherAddress.setLabel( fieldValue ); - } else if ( fieldName == "X-OtherAddressStreet" ) { - otherAddress.setStreet( fieldValue ); - } else if ( fieldName == "X-OtherAddressCity" ) { - otherAddress.setLocality( fieldValue ); - } else if ( fieldName == "X-OtherAddressPostalCode" ) { - otherAddress.setPostalCode( fieldValue ); - } else if ( fieldName == "X-OtherAddressState" ) { - otherAddress.setRegion( fieldValue ); - } else if ( fieldName == "X-OtherAddressCountry" ) { - otherAddress.setCountry( fieldValue ); - } else if ( fieldName == "NICKNAME" ) { - a.setNickName( fieldValue ); - } else if ( fieldName == "ORG" ) { - a.setOrganization( fieldValue ); - } else if ( fieldName == "ROLE" ) { - a.setRole( fieldValue ); - } else if ( fieldName == "BDAY" ) { - a.setBirthday( TDEGlobal::locale()->readDate( fieldValue ) ); - } else if ( fieldName == "WEBPAGE" ) { - a.setUrl( KURL( fieldValue ) ); - } else if ( fieldName == "N" ) { - } else if ( fieldName == "X-FirstName" ) { - } else if ( fieldName == "X-MiddleName" ) { - } else if ( fieldName == "X-LastName" ) { - } else if ( fieldName == "X-Title" ) { - } else if ( fieldName == "X-Suffix" ) { - } else if ( fieldName == "X-FileAs" ) { - } else if ( fieldName == "EMAIL" ) { - a.insertEmail( fieldValue, true ); - } else if ( fieldName == "X-E-mail2" ) { - a.insertEmail( fieldValue ); - } else if ( fieldName == "X-E-mail3" ) { - a.insertEmail( fieldValue ); - } else if ( fieldName == "X-Notes" ) { - } else { - a.insertCustom( "KADDRESSBOOK", fieldName, fieldValue ); - } - } - - if ( !homeAddress.isEmpty() ) a.insertAddress( homeAddress ); - if ( !businessAddress.isEmpty() ) a.insertAddress( businessAddress ); - if ( !otherAddress.isEmpty() ) a.insertAddress( otherAddress ); -} - -void importKab( KABC::AddressBook *ab, bool override, bool quiet ) -{ - TQString fileName = TDEGlobal::dirs()->saveLocation( "data", "kab/" ); - fileName += "addressbook.kab"; - if ( !TQFile::exists( fileName ) ) { - if ( !quiet ) { - KMessageBox::error( 0, "" + i18n( "Address book file %1 not found! Make sure the old address book is located there and you have read permission for this file." ) - .arg( fileName ) + "" ); - } - kdDebug(5700) << "No KDE 2 addressbook found." << endl; - return; - } - - kdDebug(5700) << "Converting old-style kab addressbook to " - "new-style kabc addressbook." << endl; - - KabAPI kab( 0 ); - if ( kab.init() != ::AddressBook::NoError ) { - kdDebug(5700) << "Error initing kab" << endl; - exit( 1 ); - } - - KabKey key; - ::AddressBook::Entry entry; - - int num = kab.addressbook()->noOfEntries(); - - kdDebug(5700) << "kab Addressbook has " << num << " entries." << endl; - - for ( int i = 0; i < num; ++i ) { - if ( ::AddressBook::NoError != kab.addressbook()->getKey( i, key ) ) { - kdDebug(5700) << "Error getting key for index " << i << " from kab." << endl; - continue; - } - if ( ::AddressBook::NoError != kab.addressbook()->getEntry( key, entry ) ) { - kdDebug(5700) << "Error getting entry for index " << i << " from kab." << endl; - continue; - } - - Addressee a; - - // Convert custom entries - int count = 0; - bool idFound = false; - TQStringList::ConstIterator customIt; - for ( customIt = entry.custom.begin(); customIt != entry.custom.end(); ++customIt ) { - if ( (*customIt).startsWith( "X-KABC-UID:" ) ) { - a.setUid( (*customIt).mid( (*customIt).find( ":" ) + 1 ) ); - idFound = true; - } else if ( (*customIt).startsWith( "KMail:1.0\n" ) ) { - readKAddressBookEntries( *customIt, a ); - } else { - a.insertCustom( "kab2kabc", TQString::number( count++ ), *customIt ); - } - } - if ( idFound ) { - if ( !override ) continue; - } else { - entry.custom << "X-KABC-UID:" + a.uid(); - ::AddressBook::ErrorCode error = kab.addressbook()->change( key, entry ); - if ( error != ::AddressBook::NoError ) { - kdDebug(5700) << "kab.change returned with error " << error << endl; - } else { - kdDebug(5700) << "Wrote back to kab uid " << a.uid() << endl; - } - } - - a.setTitle( entry.title ); - a.setFormattedName( entry.fn ); - a.setPrefix( entry.nameprefix ); - a.setGivenName( entry.firstname ); - a.setAdditionalName( entry.middlename ); - a.setFamilyName( entry.lastname ); - a.setBirthday( entry.birthday ); - - TQStringList::ConstIterator emailIt; - for ( emailIt = entry.emails.begin(); emailIt != entry.emails.end(); ++emailIt ) - a.insertEmail( *emailIt ); - - TQStringList::ConstIterator phoneIt; - for ( phoneIt = entry.telephone.begin(); phoneIt != entry.telephone.end(); ++phoneIt ) { - int kabType = (*phoneIt++).toInt(); - if ( phoneIt == entry.telephone.end() ) break; - TQString number = *phoneIt; - int type = 0; - if ( kabType == ::AddressBook::Fixed ) type = PhoneNumber::Voice; - else if ( kabType == ::AddressBook::Mobile ) type = PhoneNumber::Cell | PhoneNumber::Voice; - else if ( kabType == ::AddressBook::Fax ) type = PhoneNumber::Fax; - else if ( kabType == ::AddressBook::Modem ) type = PhoneNumber::Modem; - a.insertPhoneNumber( PhoneNumber( number, type ) ); - } - - if ( entry.URLs.count() > 0 ) { - a.setUrl( KURL( entry.URLs.first() ) ); - if ( entry.URLs.count() > 1 ) { - kdWarning() << "More than one URL. Ignoring all but the first." << endl; - } - } - - int noAdr = entry.noOfAddresses(); - for ( int j = 0; j < noAdr; ++j ) { - ::AddressBook::Entry::Address kabAddress; - entry.getAddress( j, kabAddress ); - - Address adr; - - adr.setStreet( kabAddress.address ); - adr.setPostalCode( kabAddress.zip ); - adr.setLocality( kabAddress.town ); - adr.setCountry( kabAddress.country ); - adr.setRegion( kabAddress.state ); - - TQString label; - if ( !kabAddress.headline.isEmpty() ) label += kabAddress.headline + "\n"; - if ( !kabAddress.position.isEmpty() ) label += kabAddress.position + "\n"; - if ( !kabAddress.org.isEmpty() ) label += kabAddress.org + "\n"; - if ( !kabAddress.orgUnit.isEmpty() ) label += kabAddress.orgUnit + "\n"; - if ( !kabAddress.orgSubUnit.isEmpty() ) label += kabAddress.orgSubUnit + "\n"; - if ( !kabAddress.deliveryLabel.isEmpty() ) label += kabAddress.deliveryLabel + "\n"; - adr.setLabel( label ); - - a.insertAddress( adr ); - } - - TQString note = entry.comment; - - if ( !entry.user1.isEmpty() ) note += "\nUser1: " + entry.user1; - if ( !entry.user2.isEmpty() ) note += "\nUser2: " + entry.user2; - if ( !entry.user3.isEmpty() ) note += "\nUser3: " + entry.user3; - if ( !entry.user4.isEmpty() ) note += "\nUser4: " + entry.user4; - - if ( !entry.keywords.count() == 0 ) note += "\nKeywords: " + entry.keywords.join( ", " ); - - TQStringList::ConstIterator talkIt; - for ( talkIt = entry.talk.begin(); talkIt != entry.talk.end(); ++talkIt ) { - note += "\nTalk: " + (*talkIt); - } - - a.setNote( note ); - - a.setPrefix( entry.rank + a.prefix() ); // Add rank to prefix - - a.setCategories( entry.categories ); - - kdDebug(5700) << "Addressee: " << a.familyName() << endl; - - ab->insertAddressee( a ); - } - - kab.save( true ); -} - -int main( int argc, char **argv ) -{ - TDEAboutData aboutData( "kab2kabc", I18N_NOOP( "Kab to Kabc Converter" ), "0.1" ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - TDECmdLineArgs::addCmdLineOptions( options ); - - TDEApplication app; - - TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - - bool override = false; - - if ( args->isSet( "override" ) ) { - kdDebug() << "Override existing entries." << endl; - - override = true; - } - - bool quiet = false; - - if ( args->isSet( "quiet" ) ) - quiet = true; - - if ( args->isSet( "disable-autostart" ) ) { - kdDebug() << "Disable autostart." << endl; - - TDEConfig *config = app.config(); - config->setGroup( "Startup" ); - config->writeEntry( "EnableAutostart", false ); - } - - KABC::AddressBook *kabcBook = StdAddressBook::self(); - - importKMailAddressBook( kabcBook ); - - importKab( kabcBook, override, quiet ); - - StdAddressBook::save(); - - kdDebug(5700) << "Saved kabc addressbook to '" << kabcBook->identifier() << "'" << endl; -} - diff --git a/kabc/kab2kabc.desktop b/kabc/kab2kabc.desktop deleted file mode 100644 index 3015b3935..000000000 --- a/kabc/kab2kabc.desktop +++ /dev/null @@ -1,105 +0,0 @@ -[Desktop Entry] -Name=kab2kabc -Name[af]=kab-na-kabc -Name[csb]=Kònwersëjô adresowi knéżczi -Name[eo]=Konvertilo de "kab" al "kabc" -Name[fr]=KAB2KABC -Name[fy]=Kab2kabc -Name[hu]=Kab2kabc -Name[it]=Kab2Kabc -Name[nl]=Kab2kabc -Name[pl]=Konwersja książki adresowej -Name[pt_BR]=Conversão de kab para kabc -Name[ro]=Kab2kabc -Name[sv]=Kab2kabc -Name[te]=కెఎబి2కెఎబిసి -Name[zu]=i-kab2kabc -Exec=kab2kabc --disable-autostart --quiet -Icon=misc -Type=Application -Comment=libkab to libkabc conversion tool. -Comment[af]=libkab na libkabc omskakeling program. -Comment[ar]=أداة تحويل libkab إلى libkabc. -Comment[az]=libkab - libkabc dönüşdürmə vasitəsi. -Comment[be]=Інструмент пераўтварэння libkab у libkabc. -Comment[bg]=Програма за конвертиране на libkab до libkabc. -Comment[bn]=libkab থেকে libkabc-তে পরিবর্তন করার প্রোগ্রাম। -Comment[bs]=alat za pretvaranje libkab u libkabc. -Comment[ca]=Eina de conversió de libkab a libkabc. -Comment[cs]=Převod dat z libkab do libkabc. -Comment[csb]=Nôrzãdze do kònwersëji z libkab do libkabc. -Comment[cy]=erfyn trosi libkab i libkabc -Comment[da]=libkab-til-libkabc-konverteringsværktøj. -Comment[de]=Konvertierung von libkab in libkabc -Comment[el]=Εργαλείο μετατροπής από το libkab στο libkabc. -Comment[eo]=Konvertilo de "libkab" al "libkabc" -Comment[es]=Conversor libkab a libkabc. -Comment[et]=libkab -> libkabc teisendamine -Comment[eu]=libkab-etik libkabc-era bihurtzeko tresna. -Comment[fa]=ابزار تبدیل libkab به libcabc. -Comment[fi]=libkab-libkabc -muunnin -Comment[fr]=Outil de conversion de libkab vers libkabc. -Comment[fy]=Konversjeprogramma fan libkab nei libkabc. -Comment[ga]=Uirlis tiontaithe ó libkab go libkabc. -Comment[gl]=Ferramenta de conversión de libkab a libkabc. -Comment[he]=כלי המרה מ־libkab ל־libkabc -Comment[hi]=libkab से libkabc बदलने वाला औजार -Comment[hr]=Alat za pretvaranje iz libkab u libkabc -Comment[hsb]=libkab -> libkabc konwerter -Comment[hu]=libkab -> libkabc konvertáló. -Comment[id]=konverter libkab ke libkabc. -Comment[is]=libkab í libkabc breytingatól. -Comment[it]=Strumento di conversione da libkab a libkabc. -Comment[ja]=libkab から libkabc への変換ツール -Comment[ka]=libkab => libkabc გარდაქმნის ხელსაწყო. -Comment[kk]=libkab дегеннен libkabc дегенге айналдыру құралы. -Comment[km]=ឧបករណ៍​បម្លែង​ពី libkab ទៅ libkabc -Comment[ko]=libkab을 libkabc로 바꿔주는 연장. -Comment[lb]=libkab op libkabc Konvertéierungs-Hëllefsmëttel. -Comment[lt]=libkab į libkabc konvertavimo įrankis. -Comment[lv]=libkab uz libkabc kovertēšanas rīks. -Comment[mk]=алатка за претворање од libkab во libkabc. -Comment[mn]=libkab-аас libkabc-руу хөрвүүлэгч -Comment[ms]=perkakasan penukaran libkab to libkabc. -Comment[mt]=Għodda għall-konverżjoni libkab għal libkabc -Comment[nb]=libkab til libkabc konverteringsverktøy. -Comment[nds]=Warktüüch för't Ümwanneln vun libkab na libkabc. -Comment[ne]=libkab to libkabc रूपान्तरण उपकरण । -Comment[nl]=Conversieprogramma van libkab naar libkabc. -Comment[nn]=Konverterer libkab til libkabc -Comment[nso]=Sebereka sa phetosetso ya libkab go libkabc -Comment[pa]=libkab ਤੋ libkabc ਤਬਦੀਲੀ ਸੰਦ। -Comment[pl]=Narzędzie do konwersji z libkab do libkabc. -Comment[pt]=Ferramenta de conversão de libkab para libkabc. -Comment[pt_BR]=Ferramenta de conversão de libkab para libkabc. -Comment[ro]=Utilitar de conversie de la "libkab" la "libkabc". -Comment[ru]=утилита преобразования libkab в libkabc. -Comment[rw]=Igikoresho cy'ihindura libkab muri libkabc. -Comment[se]=konverterenreaidu libkab:as libkabc:ai -Comment[sk]=Prevod dát z libkab do libkabc. -Comment[sl]=Orodje za pretvorbo iz libkab v libkabc -Comment[sq]=Vegla për shëndrimin e libkab në libkabc. -Comment[sr]=Алат за конверзију из libkab-а у libkabc. -Comment[sr@Latn]=Alat za konverziju iz libkab-a u libkabc. -Comment[ss]=Lithulusi lekutjintja le-libkab kuya ku-libkabc. -Comment[sv]=Konverteringsverktyg från libkab till libkabc -Comment[ta]=libkab இலிருந்து libkabc க்கு மாற்றும் கருவி. -Comment[te]=libkab నుంచి libkabc కు మార్చు పనిముట్టు -Comment[tg]=асбоби дигаргунсози libkab ба libkabc -Comment[th]=เครื่องมือเปลี่ยน libkab เป็น libkabc -Comment[tr]=libkab' tan libkabc' ye dönüştürme aracı -Comment[tt]=libkab-›libkabc äyländerü qoralı. -Comment[uk]=Засіб перетворення libkab до libkabc. -Comment[uz]=libkab'ni libkabc'ga aylantiradigan vosita. -Comment[uz@cyrillic]=libkab'ни libkabc'га айлантирадиган восита. -Comment[ven]=Tshishumiswa tsha u shandukisa libkab itshi ya kha libkabc -Comment[vi]=Công cụ chuyển đổi libkab sang libkabc. -Comment[xh]=libkab kwi libkabc isixhobo sokuguqulela. -Comment[zh_CN]=libkab 到 libkabc 的转换工具。 -Comment[zh_HK]=libkab 至 libkabc 的轉換工具 -Comment[zh_TW]=libkab 至 libkabc 轉換工具 -Comment[zu]=Ithuluzi lokuguqula le-libkab kuyaku-libkabc -Terminal=false -NoDisplay=true -X-TDE-autostart-condition=kab2kabcrc:Startup:EnableAutostart:true -OnlyShowIn=TDE; diff --git a/kabc/ldapclient.cpp b/kabc/ldapclient.cpp index 568408ba2..f696ae915 100644 --- a/kabc/ldapclient.cpp +++ b/kabc/ldapclient.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include diff --git a/kabc/ldapclient.h b/kabc/ldapclient.h index 5f8513599..f43a644ce 100644 --- a/kabc/ldapclient.h +++ b/kabc/ldapclient.h @@ -31,7 +31,7 @@ #include #include -#include +#include namespace KABC { diff --git a/kabc/ldapconfigwidget.h b/kabc/ldapconfigwidget.h index 0fd0dd7e5..01074292e 100644 --- a/kabc/ldapconfigwidget.h +++ b/kabc/ldapconfigwidget.h @@ -27,7 +27,7 @@ #include #include -#include +#include class TQGridLayout; class TQSpinBox; diff --git a/kabc/plugins/dir/CMakeLists.txt b/kabc/plugins/dir/CMakeLists.txt index 47f81a355..737d1144e 100644 --- a/kabc/plugins/dir/CMakeLists.txt +++ b/kabc/plugins/dir/CMakeLists.txt @@ -20,9 +20,9 @@ include_directories( ${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefile ) link_directories( diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index 0dfd0352a..6b1759f1d 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h index a7b041643..f62ee91ba 100644 --- a/kabc/plugins/dir/resourcedir.h +++ b/kabc/plugins/dir/resourcedir.h @@ -21,7 +21,7 @@ #ifndef KABC_RESOURCEDIR_H #define KABC_RESOURCEDIR_H -#include +#include #include #include diff --git a/kabc/plugins/file/CMakeLists.txt b/kabc/plugins/file/CMakeLists.txt index 3dbcd639f..f8847d7e9 100644 --- a/kabc/plugins/file/CMakeLists.txt +++ b/kabc/plugins/file/CMakeLists.txt @@ -20,9 +20,9 @@ include_directories( ${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefile ) link_directories( diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 3e5b1fa8f..2d2008c0d 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -30,9 +30,9 @@ #include #include -#include +#include #include -#include +#include #include #include #include diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h index 494c43ea6..3d2efe85f 100644 --- a/kabc/plugins/file/resourcefile.h +++ b/kabc/plugins/file/resourcefile.h @@ -21,7 +21,7 @@ #ifndef KABC_RESOURCEFILE_H #define KABC_RESOURCEFILE_H -#include +#include #include #include diff --git a/kabc/plugins/ldapkio/CMakeLists.txt b/kabc/plugins/ldapkio/CMakeLists.txt index 150377bd9..0869c54e1 100644 --- a/kabc/plugins/ldapkio/CMakeLists.txt +++ b/kabc/plugins/ldapkio/CMakeLists.txt @@ -20,9 +20,9 @@ include_directories( ${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfiles + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefiles ) link_directories( @@ -68,6 +68,6 @@ set( ${target}_SRCS tde_add_kpart( ${target} SOURCES ${${target}_SRCS} - LINK kabc_ldapkio-shared + LINK kabc_ldaptdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kabc/plugins/ldapkio/resourceldapkio.cpp b/kabc/plugins/ldapkio/resourceldapkio.cpp index cdf21fb82..034fb0ef8 100644 --- a/kabc/plugins/ldapkio/resourceldapkio.cpp +++ b/kabc/plugins/ldapkio/resourceldapkio.cpp @@ -29,12 +29,12 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include diff --git a/kabc/plugins/ldapkio/resourceldapkio.h b/kabc/plugins/ldapkio/resourceldapkio.h index 6f40b12f8..5c9282b9c 100644 --- a/kabc/plugins/ldapkio/resourceldapkio.h +++ b/kabc/plugins/ldapkio/resourceldapkio.h @@ -24,7 +24,7 @@ #include #include -#include +#include class TDEConfig; diff --git a/kabc/plugins/ldapkio/resourceldapkioconfig.cpp b/kabc/plugins/ldapkio/resourceldapkioconfig.cpp index 53c72aa2b..b517cffa5 100644 --- a/kabc/plugins/ldapkio/resourceldapkioconfig.cpp +++ b/kabc/plugins/ldapkio/resourceldapkioconfig.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "resourceldapkio.h" diff --git a/kabc/plugins/net/CMakeLists.txt b/kabc/plugins/net/CMakeLists.txt index 365922d6c..e92fbfc32 100644 --- a/kabc/plugins/net/CMakeLists.txt +++ b/kabc/plugins/net/CMakeLists.txt @@ -20,9 +20,9 @@ include_directories( ${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile + ${CMAKE_SOURCE_DIR}/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio + ${CMAKE_SOURCE_DIR}/tdeio/tdefile ) link_directories( diff --git a/kabc/plugins/net/resourcenet.cpp b/kabc/plugins/net/resourcenet.cpp index 78fb16256..9ef909904 100644 --- a/kabc/plugins/net/resourcenet.cpp +++ b/kabc/plugins/net/resourcenet.cpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/kabc/plugins/net/resourcenet.h b/kabc/plugins/net/resourcenet.h index a13bfa175..940627ecb 100644 --- a/kabc/plugins/net/resourcenet.h +++ b/kabc/plugins/net/resourcenet.h @@ -21,7 +21,7 @@ #ifndef KABC_RESOURCENET_H #define KABC_RESOURCENET_H -#include +#include #include diff --git a/kabc/plugins/sql/resourcesql.h b/kabc/plugins/sql/resourcesql.h index 9f1201844..770e5b73b 100644 --- a/kabc/plugins/sql/resourcesql.h +++ b/kabc/plugins/sql/resourcesql.h @@ -21,7 +21,7 @@ #ifndef KABC_RESOURCESQL_H #define KABC_RESOURCESQL_H -#include +#include #include "addressbook.h" #include "resource.h" diff --git a/kabc/scripts/field.src.cpp b/kabc/scripts/field.src.cpp index 6362d223c..2c80810b7 100644 --- a/kabc/scripts/field.src.cpp +++ b/kabc/scripts/field.src.cpp @@ -19,7 +19,7 @@ */ #include -#include +#include #include #include "field.h" diff --git a/kabc/tdeab2tdeabc.cpp b/kabc/tdeab2tdeabc.cpp new file mode 100644 index 000000000..afb688078 --- /dev/null +++ b/kabc/tdeab2tdeabc.cpp @@ -0,0 +1,476 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 Cornelius Schumacher + + 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 "addressbook.h" +#include "stdaddressbook.h" + +using namespace KABC; + +static const KCmdLineOptions options[] = +{ + { "disable-autostart", I18N_NOOP( "Disable automatic startup on login" ), 0 }, + { "quiet", "", 0 }, + { "o", 0, 0 }, + { "override", I18N_NOOP( "Override existing entries" ), "1" }, + KCmdLineLastOption +}; + +void readKMailEntry( const TQString &kmailEntry, KABC::AddressBook *ab ) +{ + kdDebug() << "KMAILENTRY: " << kmailEntry << endl; + + TQString entry = kmailEntry.simplifyWhiteSpace(); + if ( entry.isEmpty() ) return; + + TQString email; + TQString name; + TQString comment; + + if ( entry.at( entry.length() -1 ) == ')' ) { + int br = entry.findRev( '(' ); + if ( br >= 0 ) { + comment = entry.mid( br + 1, entry.length() - br - 2 ); + entry.truncate( br ); + if ( entry.at( entry.length() - 1 ).isSpace() ) { + entry.truncate( br - 1 ); + } + } + } + + int posSpace = entry.findRev( ' ' ); + if ( posSpace < 0 ) { + email = entry; + if ( !comment.isEmpty() ) { + name = comment; + comment = ""; + } + } else { + email = entry.mid( posSpace + 1 ); + name = entry.left( posSpace ); + } + + if ( email.at( 0 ) == '<' && email.at( email.length() - 1) == '>' ) { + email = email.mid( 1, email.length() - 2 ); + } + if ( name.at( 0 ) == '"' && name.at( name.length() - 1) == '"' ) { + name = name.mid( 1, name.length() - 2 ); + } + if ( name.at( 0 ) == '\'' && name.at( name.length() - 1) == '\'' ) { + name = name.mid( 1, name.length() - 2 ); + } + + if ( name.at( name.length() -1 ) == ')' ) { + int br = name.findRev( '(' ); + if ( br >= 0 ) { + comment = name.mid( br + 1, name.length() - br - 2 ) + " " + comment; + name.truncate( br ); + if ( name.at( name.length() - 1 ).isSpace() ) { + name.truncate( br - 1 ); + } + } + } + + kdDebug() << " EMAIL : " << email << endl; + kdDebug() << " NAME : " << name << endl; + kdDebug() << " COMMENT : " << comment << endl; + + KABC::Addressee::List al = ab->findByEmail( email ); + if ( al.isEmpty() ) { + KABC::Addressee a; + a.setNameFromString( name ); + a.insertEmail( email ); + a.setNote( comment ); + + ab->insertAddressee( a ); + + kdDebug() << "--INSERTED: " << a.realName() << endl; + } +} + +void importKMailAddressBook( KABC::AddressBook *ab ) +{ + TQString fileName = locateLocal( "data", "kmail/addressbook" ); + TQString kmailConfigName = locate( "config", "kmailrc" ); + if ( !kmailConfigName.isEmpty() ) { + TDEConfig cfg( kmailConfigName ); + cfg.setGroup( "Addressbook" ); + fileName = cfg.readPathEntry( "default", fileName ); + } + if ( !KStandardDirs::exists( fileName ) ) { + kdDebug(5700) << "Couldn't find KMail addressbook." << endl; + return; + } + + TQFile f( fileName ); + if ( !f.open(IO_ReadOnly) ) { + kdDebug(5700) << "Couldn't open file '" << fileName << "'" << endl; + return; + } + + TQStringList kmailEntries; + + TQTextStream t( &f ); + while ( !t.eof() ) { + kmailEntries.append( t.readLine() ); + } + f.close(); + + TQStringList::ConstIterator it; + for ( it = kmailEntries.begin(); it != kmailEntries.end(); ++it ) { + if ( (*it).at( 0 ) == '#' ) continue; + bool insideQuote = false; + int end = (*it).length() - 1; + for ( int i = end; i; i-- ) { + if ( (*it).at( i ) == '"' ) { + if ( insideQuote ) + insideQuote = false; + else + insideQuote = true; + } else if ( (*it).at( i ) == ',' && !insideQuote ) { + readKMailEntry( (*it).mid( i + 1, end - i ), ab ); + end = i - 1; + } + } + + readKMailEntry( (*it).mid( 0, end + 1 ), ab ); + } +} + +void readKAddressBookEntries( const TQString &dataString, Addressee &a ) +{ + // Strip "KMail:1.0" prefix and "[EOS]" suffix. + TQString str = dataString.mid( 11, dataString.length() - 24 ); + + TQStringList entries = TQStringList::split( "\n[EOR]\n ", str ); + + Address homeAddress( Address::Home ); + Address businessAddress( Address::Work ); + Address otherAddress; + + TQStringList::ConstIterator it; + for ( it = entries.begin(); it != entries.end(); ++it ) { + int pos = (*it).find( "\n" ); + TQString fieldName = (*it).left( pos ); + TQString fieldValue = (*it).mid( pos + 2 ); + + if ( fieldName == "X-HomeFax" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Home | + PhoneNumber::Fax ) ); + } else if ( fieldName == "X-OtherPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, 0 ) ); + } else if ( fieldName == "X-PrimaryPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Pref ) ); + } else if ( fieldName == "X-BusinessFax" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Work | + PhoneNumber::Fax ) ); + } else if ( fieldName == "X-CarPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Car ) ); + } else if ( fieldName == "X-MobilePhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Cell ) ); + } else if ( fieldName == "X-ISDN" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Isdn ) ); + } else if ( fieldName == "X-OtherFax" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Fax ) ); + } else if ( fieldName == "X-Pager" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Pager ) ); + } else if ( fieldName == "X-BusinessPhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Work ) ); + } else if ( fieldName == "X-HomePhone" ) { + a.insertPhoneNumber( PhoneNumber( fieldValue, PhoneNumber::Home ) ); + } else if ( fieldName == "X-HomeAddress" ) { + homeAddress.setLabel( fieldValue ); + } else if ( fieldName == "X-HomeAddressStreet" ) { + homeAddress.setStreet( fieldValue ); + } else if ( fieldName == "X-HomeAddressCity" ) { + homeAddress.setLocality( fieldValue ); + } else if ( fieldName == "X-HomeAddressPostalCode" ) { + homeAddress.setPostalCode( fieldValue ); + } else if ( fieldName == "X-HomeAddressState" ) { + homeAddress.setRegion( fieldValue ); + } else if ( fieldName == "X-HomeAddressCountry" ) { + homeAddress.setCountry( fieldValue ); + } else if ( fieldName == "X-BusinessAddress" ) { + businessAddress.setLabel( fieldValue ); + } else if ( fieldName == "X-BusinessAddressStreet" ) { + businessAddress.setStreet( fieldValue ); + } else if ( fieldName == "X-BusinessAddressCity" ) { + businessAddress.setLocality( fieldValue ); + } else if ( fieldName == "X-BusinessAddressPostalCode" ) { + businessAddress.setPostalCode( fieldValue ); + } else if ( fieldName == "X-BusinessAddressState" ) { + businessAddress.setRegion( fieldValue ); + } else if ( fieldName == "X-BusinessAddressCountry" ) { + businessAddress.setCountry( fieldValue ); + } else if ( fieldName == "X-OtherAddress" ) { + otherAddress.setLabel( fieldValue ); + } else if ( fieldName == "X-OtherAddressStreet" ) { + otherAddress.setStreet( fieldValue ); + } else if ( fieldName == "X-OtherAddressCity" ) { + otherAddress.setLocality( fieldValue ); + } else if ( fieldName == "X-OtherAddressPostalCode" ) { + otherAddress.setPostalCode( fieldValue ); + } else if ( fieldName == "X-OtherAddressState" ) { + otherAddress.setRegion( fieldValue ); + } else if ( fieldName == "X-OtherAddressCountry" ) { + otherAddress.setCountry( fieldValue ); + } else if ( fieldName == "NICKNAME" ) { + a.setNickName( fieldValue ); + } else if ( fieldName == "ORG" ) { + a.setOrganization( fieldValue ); + } else if ( fieldName == "ROLE" ) { + a.setRole( fieldValue ); + } else if ( fieldName == "BDAY" ) { + a.setBirthday( TDEGlobal::locale()->readDate( fieldValue ) ); + } else if ( fieldName == "WEBPAGE" ) { + a.setUrl( KURL( fieldValue ) ); + } else if ( fieldName == "N" ) { + } else if ( fieldName == "X-FirstName" ) { + } else if ( fieldName == "X-MiddleName" ) { + } else if ( fieldName == "X-LastName" ) { + } else if ( fieldName == "X-Title" ) { + } else if ( fieldName == "X-Suffix" ) { + } else if ( fieldName == "X-FileAs" ) { + } else if ( fieldName == "EMAIL" ) { + a.insertEmail( fieldValue, true ); + } else if ( fieldName == "X-E-mail2" ) { + a.insertEmail( fieldValue ); + } else if ( fieldName == "X-E-mail3" ) { + a.insertEmail( fieldValue ); + } else if ( fieldName == "X-Notes" ) { + } else { + a.insertCustom( "KADDRESSBOOK", fieldName, fieldValue ); + } + } + + if ( !homeAddress.isEmpty() ) a.insertAddress( homeAddress ); + if ( !businessAddress.isEmpty() ) a.insertAddress( businessAddress ); + if ( !otherAddress.isEmpty() ) a.insertAddress( otherAddress ); +} + +void importKab( KABC::AddressBook *ab, bool override, bool quiet ) +{ + TQString fileName = TDEGlobal::dirs()->saveLocation( "data", "kab/" ); + fileName += "addressbook.kab"; + if ( !TQFile::exists( fileName ) ) { + if ( !quiet ) { + KMessageBox::error( 0, "" + i18n( "Address book file %1 not found! Make sure the old address book is located there and you have read permission for this file." ) + .arg( fileName ) + "" ); + } + kdDebug(5700) << "No KDE 2 addressbook found." << endl; + return; + } + + kdDebug(5700) << "Converting old-style kab addressbook to " + "new-style kabc addressbook." << endl; + + KabAPI kab( 0 ); + if ( kab.init() != ::AddressBook::NoError ) { + kdDebug(5700) << "Error initing kab" << endl; + exit( 1 ); + } + + KabKey key; + ::AddressBook::Entry entry; + + int num = kab.addressbook()->noOfEntries(); + + kdDebug(5700) << "kab Addressbook has " << num << " entries." << endl; + + for ( int i = 0; i < num; ++i ) { + if ( ::AddressBook::NoError != kab.addressbook()->getKey( i, key ) ) { + kdDebug(5700) << "Error getting key for index " << i << " from kab." << endl; + continue; + } + if ( ::AddressBook::NoError != kab.addressbook()->getEntry( key, entry ) ) { + kdDebug(5700) << "Error getting entry for index " << i << " from kab." << endl; + continue; + } + + Addressee a; + + // Convert custom entries + int count = 0; + bool idFound = false; + TQStringList::ConstIterator customIt; + for ( customIt = entry.custom.begin(); customIt != entry.custom.end(); ++customIt ) { + if ( (*customIt).startsWith( "X-KABC-UID:" ) ) { + a.setUid( (*customIt).mid( (*customIt).find( ":" ) + 1 ) ); + idFound = true; + } else if ( (*customIt).startsWith( "KMail:1.0\n" ) ) { + readKAddressBookEntries( *customIt, a ); + } else { + a.insertCustom( "tdeab2tdeabc", TQString::number( count++ ), *customIt ); + } + } + if ( idFound ) { + if ( !override ) continue; + } else { + entry.custom << "X-KABC-UID:" + a.uid(); + ::AddressBook::ErrorCode error = kab.addressbook()->change( key, entry ); + if ( error != ::AddressBook::NoError ) { + kdDebug(5700) << "kab.change returned with error " << error << endl; + } else { + kdDebug(5700) << "Wrote back to kab uid " << a.uid() << endl; + } + } + + a.setTitle( entry.title ); + a.setFormattedName( entry.fn ); + a.setPrefix( entry.nameprefix ); + a.setGivenName( entry.firstname ); + a.setAdditionalName( entry.middlename ); + a.setFamilyName( entry.lastname ); + a.setBirthday( entry.birthday ); + + TQStringList::ConstIterator emailIt; + for ( emailIt = entry.emails.begin(); emailIt != entry.emails.end(); ++emailIt ) + a.insertEmail( *emailIt ); + + TQStringList::ConstIterator phoneIt; + for ( phoneIt = entry.telephone.begin(); phoneIt != entry.telephone.end(); ++phoneIt ) { + int kabType = (*phoneIt++).toInt(); + if ( phoneIt == entry.telephone.end() ) break; + TQString number = *phoneIt; + int type = 0; + if ( kabType == ::AddressBook::Fixed ) type = PhoneNumber::Voice; + else if ( kabType == ::AddressBook::Mobile ) type = PhoneNumber::Cell | PhoneNumber::Voice; + else if ( kabType == ::AddressBook::Fax ) type = PhoneNumber::Fax; + else if ( kabType == ::AddressBook::Modem ) type = PhoneNumber::Modem; + a.insertPhoneNumber( PhoneNumber( number, type ) ); + } + + if ( entry.URLs.count() > 0 ) { + a.setUrl( KURL( entry.URLs.first() ) ); + if ( entry.URLs.count() > 1 ) { + kdWarning() << "More than one URL. Ignoring all but the first." << endl; + } + } + + int noAdr = entry.noOfAddresses(); + for ( int j = 0; j < noAdr; ++j ) { + ::AddressBook::Entry::Address kabAddress; + entry.getAddress( j, kabAddress ); + + Address adr; + + adr.setStreet( kabAddress.address ); + adr.setPostalCode( kabAddress.zip ); + adr.setLocality( kabAddress.town ); + adr.setCountry( kabAddress.country ); + adr.setRegion( kabAddress.state ); + + TQString label; + if ( !kabAddress.headline.isEmpty() ) label += kabAddress.headline + "\n"; + if ( !kabAddress.position.isEmpty() ) label += kabAddress.position + "\n"; + if ( !kabAddress.org.isEmpty() ) label += kabAddress.org + "\n"; + if ( !kabAddress.orgUnit.isEmpty() ) label += kabAddress.orgUnit + "\n"; + if ( !kabAddress.orgSubUnit.isEmpty() ) label += kabAddress.orgSubUnit + "\n"; + if ( !kabAddress.deliveryLabel.isEmpty() ) label += kabAddress.deliveryLabel + "\n"; + adr.setLabel( label ); + + a.insertAddress( adr ); + } + + TQString note = entry.comment; + + if ( !entry.user1.isEmpty() ) note += "\nUser1: " + entry.user1; + if ( !entry.user2.isEmpty() ) note += "\nUser2: " + entry.user2; + if ( !entry.user3.isEmpty() ) note += "\nUser3: " + entry.user3; + if ( !entry.user4.isEmpty() ) note += "\nUser4: " + entry.user4; + + if ( !entry.keywords.count() == 0 ) note += "\nKeywords: " + entry.keywords.join( ", " ); + + TQStringList::ConstIterator talkIt; + for ( talkIt = entry.talk.begin(); talkIt != entry.talk.end(); ++talkIt ) { + note += "\nTalk: " + (*talkIt); + } + + a.setNote( note ); + + a.setPrefix( entry.rank + a.prefix() ); // Add rank to prefix + + a.setCategories( entry.categories ); + + kdDebug(5700) << "Addressee: " << a.familyName() << endl; + + ab->insertAddressee( a ); + } + + kab.save( true ); +} + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "tdeab2tdeabc", I18N_NOOP( "Kab to Kabc Converter" ), "0.1" ); + aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app; + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + bool override = false; + + if ( args->isSet( "override" ) ) { + kdDebug() << "Override existing entries." << endl; + + override = true; + } + + bool quiet = false; + + if ( args->isSet( "quiet" ) ) + quiet = true; + + if ( args->isSet( "disable-autostart" ) ) { + kdDebug() << "Disable autostart." << endl; + + TDEConfig *config = app.config(); + config->setGroup( "Startup" ); + config->writeEntry( "EnableAutostart", false ); + } + + KABC::AddressBook *kabcBook = StdAddressBook::self(); + + importKMailAddressBook( kabcBook ); + + importKab( kabcBook, override, quiet ); + + StdAddressBook::save(); + + kdDebug(5700) << "Saved kabc addressbook to '" << kabcBook->identifier() << "'" << endl; +} + diff --git a/kabc/tdeab2tdeabc.desktop b/kabc/tdeab2tdeabc.desktop new file mode 100644 index 000000000..945f044d4 --- /dev/null +++ b/kabc/tdeab2tdeabc.desktop @@ -0,0 +1,105 @@ +[Desktop Entry] +Name=tdeab2tdeabc +Name[af]=kab-na-kabc +Name[csb]=Kònwersëjô adresowi knéżczi +Name[eo]=Konvertilo de "kab" al "kabc" +Name[fr]=KAB2KABC +Name[fy]=Kab2kabc +Name[hu]=Kab2kabc +Name[it]=Kab2Kabc +Name[nl]=Kab2kabc +Name[pl]=Konwersja książki adresowej +Name[pt_BR]=Conversão de kab para kabc +Name[ro]=Kab2kabc +Name[sv]=Kab2kabc +Name[te]=కెఎబి2కెఎబిసి +Name[zu]=i-tdeab2tdeabc +Exec=tdeab2tdeabc --disable-autostart --quiet +Icon=misc +Type=Application +Comment=libkab to libkabc conversion tool. +Comment[af]=libkab na libkabc omskakeling program. +Comment[ar]=أداة تحويل libkab إلى libkabc. +Comment[az]=libkab - libkabc dönüşdürmə vasitəsi. +Comment[be]=Інструмент пераўтварэння libkab у libkabc. +Comment[bg]=Програма за конвертиране на libkab до libkabc. +Comment[bn]=libkab থেকে libkabc-তে পরিবর্তন করার প্রোগ্রাম। +Comment[bs]=alat za pretvaranje libkab u libkabc. +Comment[ca]=Eina de conversió de libkab a libkabc. +Comment[cs]=Převod dat z libkab do libkabc. +Comment[csb]=Nôrzãdze do kònwersëji z libkab do libkabc. +Comment[cy]=erfyn trosi libkab i libkabc +Comment[da]=libkab-til-libkabc-konverteringsværktøj. +Comment[de]=Konvertierung von libkab in libkabc +Comment[el]=Εργαλείο μετατροπής από το libkab στο libkabc. +Comment[eo]=Konvertilo de "libkab" al "libkabc" +Comment[es]=Conversor libkab a libkabc. +Comment[et]=libkab -> libkabc teisendamine +Comment[eu]=libkab-etik libkabc-era bihurtzeko tresna. +Comment[fa]=ابزار تبدیل libkab به libcabc. +Comment[fi]=libkab-libkabc -muunnin +Comment[fr]=Outil de conversion de libkab vers libkabc. +Comment[fy]=Konversjeprogramma fan libkab nei libkabc. +Comment[ga]=Uirlis tiontaithe ó libkab go libkabc. +Comment[gl]=Ferramenta de conversión de libkab a libkabc. +Comment[he]=כלי המרה מ־libkab ל־libkabc +Comment[hi]=libkab से libkabc बदलने वाला औजार +Comment[hr]=Alat za pretvaranje iz libkab u libkabc +Comment[hsb]=libkab -> libkabc konwerter +Comment[hu]=libkab -> libkabc konvertáló. +Comment[id]=konverter libkab ke libkabc. +Comment[is]=libkab í libkabc breytingatól. +Comment[it]=Strumento di conversione da libkab a libkabc. +Comment[ja]=libkab から libkabc への変換ツール +Comment[ka]=libkab => libkabc გარდაქმნის ხელსაწყო. +Comment[kk]=libkab дегеннен libkabc дегенге айналдыру құралы. +Comment[km]=ឧបករណ៍​បម្លែង​ពី libkab ទៅ libkabc +Comment[ko]=libkab을 libkabc로 바꿔주는 연장. +Comment[lb]=libkab op libkabc Konvertéierungs-Hëllefsmëttel. +Comment[lt]=libkab į libkabc konvertavimo įrankis. +Comment[lv]=libkab uz libkabc kovertēšanas rīks. +Comment[mk]=алатка за претворање од libkab во libkabc. +Comment[mn]=libkab-аас libkabc-руу хөрвүүлэгч +Comment[ms]=perkakasan penukaran libkab to libkabc. +Comment[mt]=Għodda għall-konverżjoni libkab għal libkabc +Comment[nb]=libkab til libkabc konverteringsverktøy. +Comment[nds]=Warktüüch för't Ümwanneln vun libkab na libkabc. +Comment[ne]=libkab to libkabc रूपान्तरण उपकरण । +Comment[nl]=Conversieprogramma van libkab naar libkabc. +Comment[nn]=Konverterer libkab til libkabc +Comment[nso]=Sebereka sa phetosetso ya libkab go libkabc +Comment[pa]=libkab ਤੋ libkabc ਤਬਦੀਲੀ ਸੰਦ। +Comment[pl]=Narzędzie do konwersji z libkab do libkabc. +Comment[pt]=Ferramenta de conversão de libkab para libkabc. +Comment[pt_BR]=Ferramenta de conversão de libkab para libkabc. +Comment[ro]=Utilitar de conversie de la "libkab" la "libkabc". +Comment[ru]=утилита преобразования libkab в libkabc. +Comment[rw]=Igikoresho cy'ihindura libkab muri libkabc. +Comment[se]=konverterenreaidu libkab:as libkabc:ai +Comment[sk]=Prevod dát z libkab do libkabc. +Comment[sl]=Orodje za pretvorbo iz libkab v libkabc +Comment[sq]=Vegla për shëndrimin e libkab në libkabc. +Comment[sr]=Алат за конверзију из libkab-а у libkabc. +Comment[sr@Latn]=Alat za konverziju iz libkab-a u libkabc. +Comment[ss]=Lithulusi lekutjintja le-libkab kuya ku-libkabc. +Comment[sv]=Konverteringsverktyg från libkab till libkabc +Comment[ta]=libkab இலிருந்து libkabc க்கு மாற்றும் கருவி. +Comment[te]=libkab నుంచి libkabc కు మార్చు పనిముట్టు +Comment[tg]=асбоби дигаргунсози libkab ба libkabc +Comment[th]=เครื่องมือเปลี่ยน libkab เป็น libkabc +Comment[tr]=libkab' tan libkabc' ye dönüştürme aracı +Comment[tt]=libkab-›libkabc äyländerü qoralı. +Comment[uk]=Засіб перетворення libkab до libkabc. +Comment[uz]=libkab'ni libkabc'ga aylantiradigan vosita. +Comment[uz@cyrillic]=libkab'ни libkabc'га айлантирадиган восита. +Comment[ven]=Tshishumiswa tsha u shandukisa libkab itshi ya kha libkabc +Comment[vi]=Công cụ chuyển đổi libkab sang libkabc. +Comment[xh]=libkab kwi libkabc isixhobo sokuguqulela. +Comment[zh_CN]=libkab 到 libkabc 的转换工具。 +Comment[zh_HK]=libkab 至 libkabc 的轉換工具 +Comment[zh_TW]=libkab 至 libkabc 轉換工具 +Comment[zu]=Ithuluzi lokuguqula le-libkab kuyaku-libkabc +Terminal=false +NoDisplay=true +X-TDE-autostart-condition=tdeab2tdeabcrc:Startup:EnableAutostart:true +OnlyShowIn=TDE; -- cgit v1.2.1