From dd324e7f343a56d3c520a3300b81821143364816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 3 Sep 2013 19:58:01 +0200 Subject: Additional k => tde renaming and fixes --- AUTHORS | 2 +- Documentation/ConduitProgrammingTutorial/index.tex | 2 +- admin | 2 +- conduits/abbrowserconduit/CMakeLists.txt | 4 +- conduits/abbrowserconduit/Makefile.am | 6 +- conduits/abbrowserconduit/abbrowser-conduit.cc | 22 +- conduits/abbrowserconduit/abbrowser-conduit.h | 2 +- conduits/abbrowserconduit/kabcRecord.cc | 710 --------------------- conduits/abbrowserconduit/kabcRecord.h | 263 -------- conduits/abbrowserconduit/tdeabcRecord.cc | 710 +++++++++++++++++++++ conduits/abbrowserconduit/tdeabcRecord.h | 263 ++++++++ conduits/configure.in.in | 2 +- conduits/docconduit/CMakeLists.txt | 2 +- conduits/docconduit/Makefile.am | 2 +- conduits/notepadconduit/Makefile.am | 2 +- conduits/popmail/Makefile.am | 2 +- conduits/sysinfoconduit/Makefile.am | 2 +- kpilot/CMakeLists.txt | 6 +- kpilot/Makefile.am | 10 +- lib/CMakeLists.txt | 2 +- lib/Makefile.am | 2 +- lib/kpilotlink.h | 2 +- tests/CMakeLists.txt | 2 +- 23 files changed, 1011 insertions(+), 1011 deletions(-) delete mode 100644 conduits/abbrowserconduit/kabcRecord.cc delete mode 100644 conduits/abbrowserconduit/kabcRecord.h create mode 100644 conduits/abbrowserconduit/tdeabcRecord.cc create mode 100644 conduits/abbrowserconduit/tdeabcRecord.h diff --git a/AUTHORS b/AUTHORS index 6d1d418..5d5dc88 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,7 +12,7 @@ o Philipp Hullmann fixed many bugs in the todo conduit. o David Bishop converted most of the UI to Qt Designer .ui. o Reinhold Kainhofer fixed and extended the VCal conduits when it was really needed. -o The addressbook conduit was rewritten by R. Kainhofer to use libkabc +o The addressbook conduit was rewritten by R. Kainhofer to use libtdeabc o The time conduit, the MAL conduit (AvantGo) and the PalmDOC conduit were also written by R. Kainhofer o Aaron J. Seigo, Jorg Habenicht, and others contributed too. diff --git a/Documentation/ConduitProgrammingTutorial/index.tex b/Documentation/ConduitProgrammingTutorial/index.tex index 89dd599..35bdc00 100644 --- a/Documentation/ConduitProgrammingTutorial/index.tex +++ b/Documentation/ConduitProgrammingTutorial/index.tex @@ -1572,7 +1572,7 @@ point of view > 1) Do I understand it right from the ksync proposal on pim.kde.org that > kitchensync is the application that does all the communication with the -> "devices" (korganizer, palm, opie, kabc, local files etc.), while ksync is +> "devices" (korganizer, palm, opie, tdeabc, local files etc.), while ksync is > just the abstract library with the sync algorithm framework? It's a bit more. diff --git a/admin b/admin index b4d585c..6b7f722 160000 --- a/admin +++ b/admin @@ -1 +1 @@ -Subproject commit b4d585c643d92787bfa17b935ce00b09960ee360 +Subproject commit 6b7f7225eff4c49b2dd71804d5fdacb03efcf461 diff --git a/conduits/abbrowserconduit/CMakeLists.txt b/conduits/abbrowserconduit/CMakeLists.txt index 07b65e1..e89c097 100644 --- a/conduits/abbrowserconduit/CMakeLists.txt +++ b/conduits/abbrowserconduit/CMakeLists.txt @@ -6,7 +6,7 @@ set(conduit_abbrowser_SRCS resolutionDialog.cc abbrowser-factory.cc abbrowser-setup.cc - kabcRecord.cc + tdeabcRecord.cc abbrowser-conduit.cc ) @@ -23,7 +23,7 @@ kde3_add_kcfg_files(conduit_abbrowser_SRCS ${conduit_abbrowser_KCFGS}) trinity_add_ui_files(conduit_abbrowser_SRCS ${conduit_abbrowser_UIS}) trinity_automoc(${conduit_abbrowser_SRCS}) add_library(conduit_address SHARED ${conduit_abbrowser_SRCS}) -target_link_libraries(conduit_address kabc_file kabc) +target_link_libraries(conduit_address tdeabc_file tdeabc) set_target_properties(conduit_address PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR} INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib PREFIX "" diff --git a/conduits/abbrowserconduit/Makefile.am b/conduits/abbrowserconduit/Makefile.am index 708a0ee..8aaf6a1 100644 --- a/conduits/abbrowserconduit/Makefile.am +++ b/conduits/abbrowserconduit/Makefile.am @@ -9,7 +9,7 @@ conduit_address_la_SOURCES = \ resolutionDialog.cc \ abbrowser-factory.cc \ abbrowser-setup.cc \ - kabcRecord.cc \ + tdeabcRecord.cc \ abbrowser-conduit.cc conduit_address_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) $(PISOCK_LIB) $(LIB_QT) -ltdecore -ltdeio -ltdeui conduit_address_la_LIBADD = ../../lib/libkpilot.la -ltdeabc -ltdeabc_file @@ -18,7 +18,7 @@ servicedir = $(kde_servicesdir) service_DATA = abbrowser_conduit.desktop kde_kcfg_DATA = abbrowserconduit.kcfg -kabcustompagedir = $(kde_datadir)/kaddressbook/contacteditorpages -kabcustompage_DATA = KPilotCustomFieldEditor.ui +tdeabcustompagedir = $(kde_datadir)/kaddressbook/contacteditorpages +tdeabcustompage_DATA = KPilotCustomFieldEditor.ui METASOURCES = AUTO diff --git a/conduits/abbrowserconduit/abbrowser-conduit.cc b/conduits/abbrowserconduit/abbrowser-conduit.cc index f89e78f..c4441b1 100644 --- a/conduits/abbrowserconduit/abbrowser-conduit.cc +++ b/conduits/abbrowserconduit/abbrowser-conduit.cc @@ -5,7 +5,7 @@ ** Copyright (C) 2007 by Adriaan de Groot ** ** The abbrowser conduit copies addresses from the Pilot's address book to -** the KDE addressbook maintained via the kabc library. +** the KDE addressbook maintained via the tdeabc library. */ /* @@ -49,7 +49,7 @@ #include "resolutionDialog.h" #include "resolutionTable.h" #include "abbrowserSettings.h" -#include "kabcRecord.h" +#include "tdeabcRecord.h" #include "abbrowser-conduit.moc" @@ -765,7 +765,7 @@ void AbbrowserConduit::slotDeletedRecord() Addressee e = aBook->findByUid(uid); DEBUGKPILOT << fname << ": now looking at palm id: [" - << id << "], kabc uid: [" << uid << "]." << endl; + << id << "], tdeabc uid: [" << uid << "]." << endl; PilotAddress*backupAddr=0L; if (backupRec) @@ -1234,13 +1234,13 @@ bool AbbrowserConduit::_savePCAddr(Addressee &pcAddr, PilotAddress*, long pilotIdL = pilotId.toLong(); if(!pilotId.isEmpty()) { - // because we maintain a mapping between pilotId -> kabc uid, whenever we add + // because we maintain a mapping between pilotId -> tdeabc uid, whenever we add // a new relationship, we have to remove any old mapping that would tie a different - // pilot id -> this kabc uid + // pilot id -> this tdeabc uid TQMap < recordid_t, TQString>::iterator it; for ( it = addresseeMap.begin(); it != addresseeMap.end(); ++it ) { - TQString kabcUid = it.data(); - if (kabcUid == pcAddr.uid()) { + TQString tdeabcUid = it.data(); + if (tdeabcUid == pcAddr.uid()) { addresseeMap.remove(it); break; } @@ -1348,7 +1348,7 @@ bool AbbrowserConduit::_equal(const PilotAddress *piAddress, const Addressee &ab for (TQStringList::Iterator it = piEmails.begin(); it != piEmails.end(); it++) { if (!abEmails.contains(*it)) { - DEBUGKPILOT << fname << ": kabc e-mail missing" << endl; + DEBUGKPILOT << fname << ": tdeabc e-mail missing" << endl; return false; } } @@ -1359,7 +1359,7 @@ bool AbbrowserConduit::_equal(const PilotAddress *piAddress, const Addressee &ab PhoneNumber::List abPhones(abEntry.phoneNumbers()); PhoneNumber::List piPhones = TDEABCSync::getPhoneNumbers(*piAddress); - // first make sure that all of the pilot phone numbers are in kabc + // first make sure that all of the pilot phone numbers are in tdeabc for (PhoneNumber::List::Iterator it = piPhones.begin(); it != piPhones.end(); it++) { PhoneNumber piPhone = *it; bool found=false; @@ -1375,11 +1375,11 @@ bool AbbrowserConduit::_equal(const PilotAddress *piAddress, const Addressee &ab } } if (!found) { - DEBUGKPILOT << fname << ": not equal because kabc phone not found." << endl; + DEBUGKPILOT << fname << ": not equal because tdeabc phone not found." << endl; return false; } } - // now the other way. *cringe* kabc has the capacity to store way more addresses + // now the other way. *cringe* tdeabc has the capacity to store way more addresses // than the Pilot, so this might give false positives more than we'd want.... for (PhoneNumber::List::Iterator it = abPhones.begin(); it != abPhones.end(); it++) { PhoneNumber abPhone = *it; diff --git a/conduits/abbrowserconduit/abbrowser-conduit.h b/conduits/abbrowserconduit/abbrowser-conduit.h index 652915c..3f017eb 100644 --- a/conduits/abbrowserconduit/abbrowser-conduit.h +++ b/conduits/abbrowserconduit/abbrowser-conduit.h @@ -35,7 +35,7 @@ #include #include -#include "kabcRecord.h" +#include "tdeabcRecord.h" class ResolutionTable; diff --git a/conduits/abbrowserconduit/kabcRecord.cc b/conduits/abbrowserconduit/kabcRecord.cc deleted file mode 100644 index dae2539..0000000 --- a/conduits/abbrowserconduit/kabcRecord.cc +++ /dev/null @@ -1,710 +0,0 @@ -/* KPilot -** -** Copyright (C) 2000,2001 by Dan Pilone -** Copyright (C) 2002-2003 by Reinhold Kainhofer -** Copyright (C) 2007 by Adriaan de Groot -** -** The abbrowser conduit copies addresses from the Pilot's address book to -** the KDE addressbook maintained via the kabc library. This file -** deals with the actual copying of HH addresses to KABC addresses -** and back again. -*/ - -/* -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program in a file called COPYING; if not, write to -** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -** MA 02110-1301, USA. -*/ - -/* -** Bug reports and questions can be sent to kde-pim@kde.org. -*/ - -#include "options.h" - -#include - -#include -#include - -#include "kabcRecord.h" - -/** - * Okay, this is so that we can map the Pilot phone types to Phone Number - * types. Email addresses are NOT included in this map, and are handled - * separately (not in PhoneNumber at all). The Pilot has 8 different kinds - * of phone numbers (which may be *labeled* however you like). These - * need to be mapped to the things that TDEABC::PhoneNumber handles. - * - * From TDEABC::PhoneNumber - * enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, - * Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, - * Isdn = 2048, Pcs = 4096, Pager = 8192 }; - * - * - * From PilotAddress: - * enum EPhoneType { - * eWork=0, eHome, eFax, eOther, eEmail, eMain, - * ePager, eMobile - * }; - * - * This array must have as many elements as PilotAddress::PhoneType - * and its elements must be TDEABC::PhoneNumber::Types. - */ - -static TDEABC::PhoneNumber::Types pilotToPhoneMap[8] = { - TDEABC::PhoneNumber::Work, // eWork - TDEABC::PhoneNumber::Home, // eHome, - TDEABC::PhoneNumber::Fax, // eFax, - (TDEABC::PhoneNumber::Types)0, // eOther -> wasn't mapped properly, - (TDEABC::PhoneNumber::Types)0, // eEmail -> shouldn't occur, - TDEABC::PhoneNumber::Home, // eMain - TDEABC::PhoneNumber::Pager, // ePager, - TDEABC::PhoneNumber::Cell // eMobile -} ; - -TDEABC::PhoneNumber::List TDEABCSync::getPhoneNumbers(const PilotAddress &a) -{ - FUNCTIONSETUP; - - TDEABC::PhoneNumber::List list; - TQString test; - - PhoneSlot shownPhone = a.getShownPhone(); - - DEBUGKPILOT << fname << ": preferred pilot index is: [" - << shownPhone << "], preferred phone number is: [" - << a.getField(shownPhone) << "]" << endl; - - for (PhoneSlot i = PhoneSlot::begin(); i.isValid(); ++i) - { - // skip email entries - if ( a.getPhoneType(i) == PilotAddressInfo::eEmail ) - { - continue; - } - - test = a.getField(i); - // only look at this if the field is populated - if (test.isEmpty()) - { - continue; - } - - int phoneType = pilotToPhoneMap[a.getPhoneType(i)]; - - // only populate a PhoneNumber if we have a corresponding type - if (phoneType >=0) - { - // if this is the preferred phone number, set it as such - if (shownPhone == i) - { - phoneType |= TDEABC::PhoneNumber::Pref; - DEBUGKPILOT << fname << ": found preferred pilot index: [" - << i << "], text: [" << test << "]" << endl; - } - TDEABC::PhoneNumber ph(test, phoneType); - list.append(ph); - } - else - { - DEBUGKPILOT << fname << ": whoopsie. pilot phone number: [" - << test << "], index: [" << i << "], type: [" - << phoneType << "], has no corresponding PhoneNumber type." << endl; - } - } - - DEBUGKPILOT << fname << ": returning: [" - << list.count() << "] phone numbers." << endl; - - return list; -} - -void TDEABCSync::setPhoneNumbers(const PilotAddressInfo &info, - PilotAddress &a, - const TDEABC::PhoneNumber::List &list) -{ - FUNCTIONSETUP; - TQString test; - - // clear all phone numbers (not e-mails) first - for ( PhoneSlot i = PhoneSlot::begin(); i.isValid() ; ++i ) - { - PilotAddressInfo::EPhoneType ind = a.getPhoneType( i ); - if (ind != PilotAddressInfo::eEmail) - { - a.setField(i, TQString()); - } - } - - // now iterate through the list and for each PhoneNumber in the list, - // iterate through our phone types using our map and set the first one - // we find as the type of address for the Pilot - for(TDEABC::PhoneNumber::List::ConstIterator listIter = list.begin(); - listIter != list.end(); ++listIter) - { - TDEABC::PhoneNumber phone = *listIter; - - PilotAddressInfo::EPhoneType phoneType = PilotAddressInfo::eHome; - - for ( int pilotPhoneType = PilotAddressInfo::eWork; - pilotPhoneType <= PilotAddressInfo::eMobile; - ++pilotPhoneType) - { - int phoneKey = pilotToPhoneMap[pilotPhoneType]; - if ( phone.type() & phoneKey) - { - DEBUGKPILOT << fname << ": found pilot type: [" - << pilotPhoneType << "] (" - << info.phoneLabel( (PilotAddressInfo::EPhoneType)pilotPhoneType) - << ") for PhoneNumber: [" - << phone.number() << "]" << endl; - - phoneType = (PilotAddressInfo::EPhoneType) pilotPhoneType; - break; - } - } - PhoneSlot fieldSlot = - a.setPhoneField(phoneType, phone.number(), PilotAddress::NoFlags); - - // if this is the preferred phone number, then set it as such - if (fieldSlot.isValid() && (phone.type() & TDEABC::PhoneNumber::Pref)) - { - DEBUGKPILOT << fname << ": found preferred PhoneNumber. " - << "setting showPhone to index: [" - << fieldSlot << "], PhoneNumber: [" - << phone.number() << "]" << endl; - a.setShownPhone( fieldSlot ); - } - - if (!fieldSlot.isValid()) - { - DEBUGKPILOT << fname << ": Phone listing overflowed." << endl; - } - } - - DEBUGKPILOT << fname << ": Pilot's showPhone now: [" - << a.getShownPhone() << "]." << endl; - - // after setting the numbers, make sure that something sensible is set as the - // shownPhone on the Pilot if nothing is yet... - TQString pref = a.getField(a.getShownPhone()); - if (!a.getShownPhone().isValid() || pref.isEmpty()) - { - DEBUGKPILOT << fname << ": Pilot's showPhone: [" - << a.getShownPhone() - << "] not properly set to a default." - << endl; - - for (PhoneSlot i = PhoneSlot::begin(); i.isValid(); ++i) - { - pref = a.getField(i); - if (!pref.isEmpty()) - { - a.setShownPhone( i ); - DEBUGKPILOT << fname << ": Pilot's showPhone now: [" - << a.getShownPhone() - << "], and that's final." << endl; - break; - } - } - } -} - -unsigned int TDEABCSync::bestMatchedCategory(const TQStringList &pccategories, - const PilotAddressInfo &info, - unsigned int hhcategory) -{ - FUNCTIONSETUP; - // No categories in list, must be unfiled - if (pccategories.size()<1) - { - return Pilot::Unfiled; - } - - // See if the suggested hhcategory is in the list, and if - // so that is the best match. - if (Pilot::validCategory(hhcategory) && - pccategories.contains(info.categoryName(hhcategory))) - { - return hhcategory; - } - - // Look for the first category from the list which is available on - // the handheld as well. - for(TQStringList::ConstIterator it = pccategories.begin(); it != pccategories.end(); ++it) - { - // Do not map unknown to unfiled when looking for category - int c = info.findCategory( *it, false ); - if ( c >= 0) - { - Q_ASSERT(Pilot::validCategory(c)); - return c; - } - } - - // didn't find anything. return null - return Pilot::Unfiled; -} - -void TDEABCSync::setCategory(TDEABC::Addressee & abEntry, const TQString &cat) -{ - if ( (!cat.isEmpty())) - { - abEntry.insertCategory(cat); - } -} - - -TQString TDEABCSync::getFieldForHHCustom( - const unsigned int index, - const TDEABC::Addressee &abEntry, - const TDEABCSync::Settings &settings) -{ - FUNCTIONSETUPL(4); - - TQString retval; - - if (index>3) - { - WARNINGKPILOT << "Bad index number " << index << endl; - retval = TQString(); - } - if (settings.customMapping().count() != 4) - { - WARNINGKPILOT << "Mapping does not have 4 elements." << index << endl; - retval = TQString(); - } - - switch (settings.custom(index)) - { - case eCustomBirthdate: - if (settings.dateFormat().isEmpty()) - { - retval = TDEGlobal::locale()->formatDate(abEntry.birthday().date()); - } - else - { - TQString tmpfmt(TDEGlobal::locale()->dateFormat()); - TDEGlobal::locale()->setDateFormat(settings.dateFormat()); - TQString ret(TDEGlobal::locale()->formatDate(abEntry.birthday().date())); - TDEGlobal::locale()->setDateFormat(tmpfmt); - retval = ret; - } - break; - case eCustomURL: - retval = abEntry.url().url(); - break; - case eCustomIM: - retval = abEntry.custom(CSL1("KADDRESSBOOK"), CSL1("X-IMAddress")); - break; - case eCustomField: - default: - retval = abEntry.custom(appString, CSL1("CUSTOM")+TQString::number(index)); - break; - } - - return retval; -} - -void TDEABCSync::setFieldFromHHCustom( - const unsigned int index, - TDEABC::Addressee &abEntry, - const TQString &value, - const TDEABCSync::Settings &settings) -{ - FUNCTIONSETUPL(4); - - if (index>3) - { - WARNINGKPILOT << "Bad index number " << index << endl; - return; - } - if (settings.customMapping().count() != 4) - { - WARNINGKPILOT << "Mapping does not have 4 elements." << index << endl; - return; - } - - switch (settings.custom(index)) - { - case eCustomBirthdate: - { - TQDate bdate; - bool ok=false; - if (settings.dateFormat().isEmpty()) - { - // empty format means use locale setting - bdate=TDEGlobal::locale()->readDate(value, &ok); - } - else - { - // use given format - bdate=TDEGlobal::locale()->readDate(value, settings.dateFormat(), &ok); - } - - if (!ok) - { - TQString format = TDEGlobal::locale()->dateFormatShort(); - TQRegExp re(CSL1("%[yY][^%]*")); - format.remove(re); // Remove references to year and following punctuation - bdate = TDEGlobal::locale()->readDate(value, format, &ok); - } - DEBUGKPILOT << "Birthdate from " << index << "-th custom field: " - << TQString(bdate.toString()) << endl; - DEBUGKPILOT << "Is Valid: " << bdate.isValid() << endl; - if (bdate.isValid()) - { - abEntry.setBirthday(bdate); - } - else - { - abEntry.insertCustom(CSL1("KADDRESSBOOK"), CSL1("X-Birthday"), value); - } - break; - } - case eCustomURL: - abEntry.setUrl(value); - break; - case eCustomIM: - abEntry.insertCustom(CSL1("KADDRESSBOOK"), CSL1("X-IMAddress"), value); - break; - case eCustomField: - default: - abEntry.insertCustom(appString, CSL1("CUSTOM")+TQString::number(index), value); - break; - } -} - - -/** First search for a preferred address. If we don't have one, search - * for home or work as specified in the config dialog. If we don't have - * such one, either, search for the other type. If we still have no luck, - * return an address with preferred + home/work flag (from config dlg). */ -TDEABC::Address TDEABCSync::getAddress(const TDEABC::Addressee &abEntry, const TDEABCSync::Settings &s) -{ - // preferhome == (AbbrowserSettings::pilotStreet==0) - - // Check for preferred address first - TDEABC::Address ad(abEntry.address(TDEABC::Address::Pref)); - if (!ad.isEmpty()) return ad; - - // Look for home or work, whichever is preferred - int type = s.preferHome() ? TDEABC::Address::Home : TDEABC::Address::Work; - ad=abEntry.address(type); - if (!ad.isEmpty()) return ad; - - // Switch preference if still none found - type = !s.preferHome() ? TDEABC::Address::Home : TDEABC::Address::Work; - ad=abEntry.address(type); - if (!ad.isEmpty()) return ad; - - // Last-ditch attempt; see if there is a preferred home or work address - type = s.preferHome() ? TDEABC::Address::Home : TDEABC::Address::Work; - return abEntry.address(type | TDEABC::Address::Pref); -} - - -TQString TDEABCSync::getFieldForHHOtherPhone(const TDEABC::Addressee & abEntry, const TDEABCSync::Settings &s) -{ - switch(s.fieldForOtherPhone()) - { - case eOtherPhone: - return abEntry.phoneNumber(0).number(); - case eAssistant: - return abEntry.custom(CSL1("KADDRESSBOOK"), CSL1("AssistantsName")); - case eBusinessFax: - return abEntry.phoneNumber(TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Work).number(); - case eCarPhone: - return abEntry.phoneNumber(TDEABC::PhoneNumber::Car).number(); - case eEmail2: - return abEntry.emails().first(); - case eHomeFax: - return abEntry.phoneNumber(TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Home).number(); - case eTelex: - return abEntry.phoneNumber(TDEABC::PhoneNumber::Bbs).number(); - case eTTYTTDPhone: - return abEntry.phoneNumber(TDEABC::PhoneNumber::Pcs).number(); - default: - return TQString(); - } -} - -void TDEABCSync::setFieldFromHHOtherPhone(TDEABC::Addressee & abEntry, const TQString &nr, const TDEABCSync::Settings &s) -{ - int phoneType = 0; - switch (s.fieldForOtherPhone()) - { - // One very special case which doesn't even map to a real phone type in KABC - case eAssistant: - abEntry.insertCustom(CSL1("KADDRESSBOOK"), CSL1("AssistantsName"), nr); - return; - // Special case: map phone to email, needs different handling. - case eEmail2: - abEntry.insertEmail(nr); - return; - // Remaining cases all map to various phone types - case eOtherPhone: - phoneType = 0; - break; - case eBusinessFax: - phoneType = TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Work; - break; - case eHomeFax: - phoneType = TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Home; - break; - case eCarPhone: - phoneType = TDEABC::PhoneNumber::Car; - break; - case eTelex: - phoneType = TDEABC::PhoneNumber::Bbs; - break; - case eTTYTTDPhone: - phoneType = TDEABC::PhoneNumber::Pcs; - break; - default: - WARNINGKPILOT << "Unknown phone mapping " << s.fieldForOtherPhone() << endl; - phoneType = 0; - } - TDEABC::PhoneNumber phone = abEntry.phoneNumber(phoneType); - phone.setNumber(nr); - phone.setType(phoneType); // Double-check in case there was no phonenumber of given type - abEntry.insertPhoneNumber(phone); -} - -void TDEABCSync::setAddress(PilotAddress &toPilotAddr, - const TDEABC::Address & abAddress) -{ - toPilotAddr.setField(entryAddress, abAddress.street()); - toPilotAddr.setField(entryCity, abAddress.locality()); - toPilotAddr.setField(entryState, abAddress.region()); - toPilotAddr.setField(entryZip, abAddress.postalCode()); - toPilotAddr.setField(entryCountry, abAddress.country()); -} - - -bool TDEABCSync::isArchived(const TDEABC::Addressee &addr) -{ - return addr.custom(TDEABCSync::appString, TDEABCSync::flagString) == TQString::number(SYNCDEL); -} - -void TDEABCSync::makeArchived(TDEABC::Addressee &addr) -{ - FUNCTIONSETUP; - addr.insertCustom(TDEABCSync::appString, TDEABCSync::flagString, TQString::number(SYNCDEL)); - addr.removeCustom(TDEABCSync::appString, TDEABCSync::idString); -} - - - - -void TDEABCSync::copy(PilotAddress &toPilotAddr, - const TDEABC::Addressee &fromAbEntry, - const PilotAddressInfo &appInfo, - const TDEABCSync::Settings &syncSettings) -{ - FUNCTIONSETUP; - - toPilotAddr.setDeleted(false); - - // don't do a reset since this could wipe out non copied info - //toPilotAddr.reset(); - toPilotAddr.setField(entryLastname, fromAbEntry.familyName()); - toPilotAddr.setField(entryFirstname, fromAbEntry.givenName()); - toPilotAddr.setField(entryCompany, fromAbEntry.organization()); - toPilotAddr.setField(entryTitle, fromAbEntry.prefix()); - toPilotAddr.setField(entryNote, fromAbEntry.note()); - - // do email first, to ensure they get stored - toPilotAddr.setEmails(fromAbEntry.emails()); - - // now in one fell swoop, set all phone numbers from the Addressee. Note, - // we don't need to differentiate between Fax numbers here--all Fax numbers - // (Home Fax or Work Fax or just plain old Fax) will get synced to the Pilot - TDEABCSync::setPhoneNumbers(appInfo,toPilotAddr,fromAbEntry.phoneNumbers()); - - // Other field is an oddball and if the user has more than one field set - // as "Other" then only one will be carried over. - TQString oth = TDEABCSync::getFieldForHHOtherPhone(fromAbEntry,syncSettings); - DEBUGKPILOT << fname << ": putting: ["< &customMapping() const - { - return fCustomMapping; - } - void setCustomMapping(const TQValueVector &v) - { - if (v.count()==4) - { - fCustomMapping = v; - } - } - int custom(int index) const - { - if ( (index<0) || (index>3) ) - { - return 0; - } - else - { - return fCustomMapping[index]; - } - } - - int fieldForOtherPhone() const - { - return fOtherPhone; - } - void setFieldForOtherPhone(int v) - { - fOtherPhone = v; - } - - bool preferHome() const - { - return fPreferHome; - } - void setPreferHome(bool v) - { - fPreferHome = v; - } - - int faxTypeOnPC() const - { - return fFaxTypeOnPC; - } - void setFaxTypeOnPC(int v) - { - fFaxTypeOnPC = v; - } - private: - TQString fDateFormat; - TQValueVector fCustomMapping; - int fOtherPhone; - bool fPreferHome; - int fFaxTypeOnPC; - } ; - - - /** Return a list of all the phone numbers (max. 8) set in this - * handheld entry @p a . Email entries are ignored. - */ - TDEABC::PhoneNumber::List getPhoneNumbers(const PilotAddress &a); - - /** Set the phone numbers from @p list in the handheld entry - * @p a (with info block @p info providing the mapping of category - * names and some other fiddly stuff) as far as possible. - * @em No overflow handling is done at all. If the desktop has - * more than 5 phone entries, the remainder are dropped. - */ - void setPhoneNumbers(const PilotAddressInfo &info, - PilotAddress &a, - const TDEABC::PhoneNumber::List &list); - - /** Given a list of category names from the KDE side (e.g. attached - * to a PC-based Addressee) @p categorynames , look for the - * category @em best matching the category @p category - * in the appinfo block @p info . Here, best is defined as follows: - * - if the name of category @p category is in the list, use it - * - otherwise use the first category from the list that is a valid - * category on the handheld. - * - use Pilot::Unfiled if none match. - * - * @return Category index that best matches. - * @return Pilot::Unfiled if no best match. - */ - unsigned int bestMatchedCategory(const TQStringList &categorynames, - const PilotAddressInfo &info, - unsigned int category); - - /** As above, but return the name of the category. */ - inline TQString bestMatchedCategoryName(const TQStringList &categorynames, - const PilotAddressInfo &info, - unsigned int category) - { - return info.categoryName( - bestMatchedCategory(categorynames, info, category)); - } - - /** Give the addressee @p abEntry the category @p cat (leaving - * existing category assignments intact). - */ - void setCategory(TDEABC::Addressee &abEntry, const TQString &cat); - - /* These are string identifiers used for custom properties in the addressees, - * used to store KPilot-specific settings. - */ - const TQString appString=CSL1("KPILOT"); ///< Identifier for the application - const TQString flagString=CSL1("Flag"); ///< Flags: synced or not - const TQString idString=CSL1("RecordID"); ///< Record ID on HH for this addressee - - - /** Get the string value for HH custom field @p index (0..3) from the addressee - * @p abEntry . Which @em actual field this is depends on the mapping - * of custom HH fields to PC fields. This mapping is given by the @p customMapping - * which may be created from the conduit settings or by hand. Since one of the - * possible actual fields is "birthday," which needs formatting, use the date format - * string @p dateFormat. If this is empty, use the locale setting. - * - * @return String value for HH custom field @p index - * @return Null TQString on error (is also a valid return value) - */ - TQString getFieldForHHCustom( - unsigned int index, - const TDEABC::Addressee &abEntry, - const Settings &settings); - - /** Set a field of the PC @p abEntry address from the custom HH field. - * Use value @p value . The value comes from custom field @p index - * using the interpretation of custom fields @p customMapping . Because - * one of the interpretations includes the birthday, use the date format - * @p dateFormat ; if empty, use the local format when setting dates from the HH. - */ - void setFieldFromHHCustom( - const unsigned int index, - TDEABC::Addressee &abEntry, - const TQString &value, - const Settings &settings); - - /** The HH has a phone type "other" which may be mapped to any one of - * several PC side phone numbers. Return the right one depending in the mapping. - * - * @note @p mappingForOther should come from AbbrowserSettings::pilotOther() - */ - TQString getFieldForHHOtherPhone(const TDEABC::Addressee &abEntry, const Settings &s); - - /** The HH has a phone type "other" which may be mapped to any one - * of several PC side phone numbers. Store the number @p nr in the - * PC side phone field indicated by @p mappingForOther . - * - * @note @p mappingForOther should come from AbbrowserSettings::pilotOther() - */ - void setFieldFromHHOtherPhone(TDEABC::Addressee &abEntry, const TQString &nr, const Settings &s); - - /** Returns the address portion of an addressee. Since the HH can only store - * one address, we return the preferred address (if the Addressee @p abEntry - * has one) and then either home or business depending on @p preferHome - * and if that doesn't exist, the other one and if @em that doesn't exist, - * return the preferred home or work address if it exists. - */ - TDEABC::Address getAddress(const TDEABC::Addressee &abEntry, const Settings &); - - /** Set the address fields of the HH record from the @p abAddress . */ - void setAddress(PilotAddress &toPilotAddr, const TDEABC::Address &abAddress); - - bool isArchived(const TDEABC::Addressee &); - void makeArchived(TDEABC::Addressee &); - - void copy(PilotAddress &toPilotAddr, - const TDEABC::Addressee &fromAbEntry, - const PilotAddressInfo &appInfo, - const Settings &syncSettings); - void copy(TDEABC::Addressee &toAbEntry, - const PilotAddress &fromPiAddr, - const PilotAddressInfo &appInfo, - const Settings &syncSettings); - - void showAddressee(const TDEABC::Addressee &); -} - -#endif - diff --git a/conduits/abbrowserconduit/tdeabcRecord.cc b/conduits/abbrowserconduit/tdeabcRecord.cc new file mode 100644 index 0000000..275450d --- /dev/null +++ b/conduits/abbrowserconduit/tdeabcRecord.cc @@ -0,0 +1,710 @@ +/* KPilot +** +** Copyright (C) 2000,2001 by Dan Pilone +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2007 by Adriaan de Groot +** +** The abbrowser conduit copies addresses from the Pilot's address book to +** the KDE addressbook maintained via the tdeabc library. This file +** deals with the actual copying of HH addresses to KABC addresses +** and back again. +*/ + +/* +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program 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 General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org. +*/ + +#include "options.h" + +#include + +#include +#include + +#include "tdeabcRecord.h" + +/** + * Okay, this is so that we can map the Pilot phone types to Phone Number + * types. Email addresses are NOT included in this map, and are handled + * separately (not in PhoneNumber at all). The Pilot has 8 different kinds + * of phone numbers (which may be *labeled* however you like). These + * need to be mapped to the things that TDEABC::PhoneNumber handles. + * + * From TDEABC::PhoneNumber + * enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, + * Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, + * Isdn = 2048, Pcs = 4096, Pager = 8192 }; + * + * + * From PilotAddress: + * enum EPhoneType { + * eWork=0, eHome, eFax, eOther, eEmail, eMain, + * ePager, eMobile + * }; + * + * This array must have as many elements as PilotAddress::PhoneType + * and its elements must be TDEABC::PhoneNumber::Types. + */ + +static TDEABC::PhoneNumber::Types pilotToPhoneMap[8] = { + TDEABC::PhoneNumber::Work, // eWork + TDEABC::PhoneNumber::Home, // eHome, + TDEABC::PhoneNumber::Fax, // eFax, + (TDEABC::PhoneNumber::Types)0, // eOther -> wasn't mapped properly, + (TDEABC::PhoneNumber::Types)0, // eEmail -> shouldn't occur, + TDEABC::PhoneNumber::Home, // eMain + TDEABC::PhoneNumber::Pager, // ePager, + TDEABC::PhoneNumber::Cell // eMobile +} ; + +TDEABC::PhoneNumber::List TDEABCSync::getPhoneNumbers(const PilotAddress &a) +{ + FUNCTIONSETUP; + + TDEABC::PhoneNumber::List list; + TQString test; + + PhoneSlot shownPhone = a.getShownPhone(); + + DEBUGKPILOT << fname << ": preferred pilot index is: [" + << shownPhone << "], preferred phone number is: [" + << a.getField(shownPhone) << "]" << endl; + + for (PhoneSlot i = PhoneSlot::begin(); i.isValid(); ++i) + { + // skip email entries + if ( a.getPhoneType(i) == PilotAddressInfo::eEmail ) + { + continue; + } + + test = a.getField(i); + // only look at this if the field is populated + if (test.isEmpty()) + { + continue; + } + + int phoneType = pilotToPhoneMap[a.getPhoneType(i)]; + + // only populate a PhoneNumber if we have a corresponding type + if (phoneType >=0) + { + // if this is the preferred phone number, set it as such + if (shownPhone == i) + { + phoneType |= TDEABC::PhoneNumber::Pref; + DEBUGKPILOT << fname << ": found preferred pilot index: [" + << i << "], text: [" << test << "]" << endl; + } + TDEABC::PhoneNumber ph(test, phoneType); + list.append(ph); + } + else + { + DEBUGKPILOT << fname << ": whoopsie. pilot phone number: [" + << test << "], index: [" << i << "], type: [" + << phoneType << "], has no corresponding PhoneNumber type." << endl; + } + } + + DEBUGKPILOT << fname << ": returning: [" + << list.count() << "] phone numbers." << endl; + + return list; +} + +void TDEABCSync::setPhoneNumbers(const PilotAddressInfo &info, + PilotAddress &a, + const TDEABC::PhoneNumber::List &list) +{ + FUNCTIONSETUP; + TQString test; + + // clear all phone numbers (not e-mails) first + for ( PhoneSlot i = PhoneSlot::begin(); i.isValid() ; ++i ) + { + PilotAddressInfo::EPhoneType ind = a.getPhoneType( i ); + if (ind != PilotAddressInfo::eEmail) + { + a.setField(i, TQString()); + } + } + + // now iterate through the list and for each PhoneNumber in the list, + // iterate through our phone types using our map and set the first one + // we find as the type of address for the Pilot + for(TDEABC::PhoneNumber::List::ConstIterator listIter = list.begin(); + listIter != list.end(); ++listIter) + { + TDEABC::PhoneNumber phone = *listIter; + + PilotAddressInfo::EPhoneType phoneType = PilotAddressInfo::eHome; + + for ( int pilotPhoneType = PilotAddressInfo::eWork; + pilotPhoneType <= PilotAddressInfo::eMobile; + ++pilotPhoneType) + { + int phoneKey = pilotToPhoneMap[pilotPhoneType]; + if ( phone.type() & phoneKey) + { + DEBUGKPILOT << fname << ": found pilot type: [" + << pilotPhoneType << "] (" + << info.phoneLabel( (PilotAddressInfo::EPhoneType)pilotPhoneType) + << ") for PhoneNumber: [" + << phone.number() << "]" << endl; + + phoneType = (PilotAddressInfo::EPhoneType) pilotPhoneType; + break; + } + } + PhoneSlot fieldSlot = + a.setPhoneField(phoneType, phone.number(), PilotAddress::NoFlags); + + // if this is the preferred phone number, then set it as such + if (fieldSlot.isValid() && (phone.type() & TDEABC::PhoneNumber::Pref)) + { + DEBUGKPILOT << fname << ": found preferred PhoneNumber. " + << "setting showPhone to index: [" + << fieldSlot << "], PhoneNumber: [" + << phone.number() << "]" << endl; + a.setShownPhone( fieldSlot ); + } + + if (!fieldSlot.isValid()) + { + DEBUGKPILOT << fname << ": Phone listing overflowed." << endl; + } + } + + DEBUGKPILOT << fname << ": Pilot's showPhone now: [" + << a.getShownPhone() << "]." << endl; + + // after setting the numbers, make sure that something sensible is set as the + // shownPhone on the Pilot if nothing is yet... + TQString pref = a.getField(a.getShownPhone()); + if (!a.getShownPhone().isValid() || pref.isEmpty()) + { + DEBUGKPILOT << fname << ": Pilot's showPhone: [" + << a.getShownPhone() + << "] not properly set to a default." + << endl; + + for (PhoneSlot i = PhoneSlot::begin(); i.isValid(); ++i) + { + pref = a.getField(i); + if (!pref.isEmpty()) + { + a.setShownPhone( i ); + DEBUGKPILOT << fname << ": Pilot's showPhone now: [" + << a.getShownPhone() + << "], and that's final." << endl; + break; + } + } + } +} + +unsigned int TDEABCSync::bestMatchedCategory(const TQStringList &pccategories, + const PilotAddressInfo &info, + unsigned int hhcategory) +{ + FUNCTIONSETUP; + // No categories in list, must be unfiled + if (pccategories.size()<1) + { + return Pilot::Unfiled; + } + + // See if the suggested hhcategory is in the list, and if + // so that is the best match. + if (Pilot::validCategory(hhcategory) && + pccategories.contains(info.categoryName(hhcategory))) + { + return hhcategory; + } + + // Look for the first category from the list which is available on + // the handheld as well. + for(TQStringList::ConstIterator it = pccategories.begin(); it != pccategories.end(); ++it) + { + // Do not map unknown to unfiled when looking for category + int c = info.findCategory( *it, false ); + if ( c >= 0) + { + Q_ASSERT(Pilot::validCategory(c)); + return c; + } + } + + // didn't find anything. return null + return Pilot::Unfiled; +} + +void TDEABCSync::setCategory(TDEABC::Addressee & abEntry, const TQString &cat) +{ + if ( (!cat.isEmpty())) + { + abEntry.insertCategory(cat); + } +} + + +TQString TDEABCSync::getFieldForHHCustom( + const unsigned int index, + const TDEABC::Addressee &abEntry, + const TDEABCSync::Settings &settings) +{ + FUNCTIONSETUPL(4); + + TQString retval; + + if (index>3) + { + WARNINGKPILOT << "Bad index number " << index << endl; + retval = TQString(); + } + if (settings.customMapping().count() != 4) + { + WARNINGKPILOT << "Mapping does not have 4 elements." << index << endl; + retval = TQString(); + } + + switch (settings.custom(index)) + { + case eCustomBirthdate: + if (settings.dateFormat().isEmpty()) + { + retval = TDEGlobal::locale()->formatDate(abEntry.birthday().date()); + } + else + { + TQString tmpfmt(TDEGlobal::locale()->dateFormat()); + TDEGlobal::locale()->setDateFormat(settings.dateFormat()); + TQString ret(TDEGlobal::locale()->formatDate(abEntry.birthday().date())); + TDEGlobal::locale()->setDateFormat(tmpfmt); + retval = ret; + } + break; + case eCustomURL: + retval = abEntry.url().url(); + break; + case eCustomIM: + retval = abEntry.custom(CSL1("KADDRESSBOOK"), CSL1("X-IMAddress")); + break; + case eCustomField: + default: + retval = abEntry.custom(appString, CSL1("CUSTOM")+TQString::number(index)); + break; + } + + return retval; +} + +void TDEABCSync::setFieldFromHHCustom( + const unsigned int index, + TDEABC::Addressee &abEntry, + const TQString &value, + const TDEABCSync::Settings &settings) +{ + FUNCTIONSETUPL(4); + + if (index>3) + { + WARNINGKPILOT << "Bad index number " << index << endl; + return; + } + if (settings.customMapping().count() != 4) + { + WARNINGKPILOT << "Mapping does not have 4 elements." << index << endl; + return; + } + + switch (settings.custom(index)) + { + case eCustomBirthdate: + { + TQDate bdate; + bool ok=false; + if (settings.dateFormat().isEmpty()) + { + // empty format means use locale setting + bdate=TDEGlobal::locale()->readDate(value, &ok); + } + else + { + // use given format + bdate=TDEGlobal::locale()->readDate(value, settings.dateFormat(), &ok); + } + + if (!ok) + { + TQString format = TDEGlobal::locale()->dateFormatShort(); + TQRegExp re(CSL1("%[yY][^%]*")); + format.remove(re); // Remove references to year and following punctuation + bdate = TDEGlobal::locale()->readDate(value, format, &ok); + } + DEBUGKPILOT << "Birthdate from " << index << "-th custom field: " + << TQString(bdate.toString()) << endl; + DEBUGKPILOT << "Is Valid: " << bdate.isValid() << endl; + if (bdate.isValid()) + { + abEntry.setBirthday(bdate); + } + else + { + abEntry.insertCustom(CSL1("KADDRESSBOOK"), CSL1("X-Birthday"), value); + } + break; + } + case eCustomURL: + abEntry.setUrl(value); + break; + case eCustomIM: + abEntry.insertCustom(CSL1("KADDRESSBOOK"), CSL1("X-IMAddress"), value); + break; + case eCustomField: + default: + abEntry.insertCustom(appString, CSL1("CUSTOM")+TQString::number(index), value); + break; + } +} + + +/** First search for a preferred address. If we don't have one, search + * for home or work as specified in the config dialog. If we don't have + * such one, either, search for the other type. If we still have no luck, + * return an address with preferred + home/work flag (from config dlg). */ +TDEABC::Address TDEABCSync::getAddress(const TDEABC::Addressee &abEntry, const TDEABCSync::Settings &s) +{ + // preferhome == (AbbrowserSettings::pilotStreet==0) + + // Check for preferred address first + TDEABC::Address ad(abEntry.address(TDEABC::Address::Pref)); + if (!ad.isEmpty()) return ad; + + // Look for home or work, whichever is preferred + int type = s.preferHome() ? TDEABC::Address::Home : TDEABC::Address::Work; + ad=abEntry.address(type); + if (!ad.isEmpty()) return ad; + + // Switch preference if still none found + type = !s.preferHome() ? TDEABC::Address::Home : TDEABC::Address::Work; + ad=abEntry.address(type); + if (!ad.isEmpty()) return ad; + + // Last-ditch attempt; see if there is a preferred home or work address + type = s.preferHome() ? TDEABC::Address::Home : TDEABC::Address::Work; + return abEntry.address(type | TDEABC::Address::Pref); +} + + +TQString TDEABCSync::getFieldForHHOtherPhone(const TDEABC::Addressee & abEntry, const TDEABCSync::Settings &s) +{ + switch(s.fieldForOtherPhone()) + { + case eOtherPhone: + return abEntry.phoneNumber(0).number(); + case eAssistant: + return abEntry.custom(CSL1("KADDRESSBOOK"), CSL1("AssistantsName")); + case eBusinessFax: + return abEntry.phoneNumber(TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Work).number(); + case eCarPhone: + return abEntry.phoneNumber(TDEABC::PhoneNumber::Car).number(); + case eEmail2: + return abEntry.emails().first(); + case eHomeFax: + return abEntry.phoneNumber(TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Home).number(); + case eTelex: + return abEntry.phoneNumber(TDEABC::PhoneNumber::Bbs).number(); + case eTTYTTDPhone: + return abEntry.phoneNumber(TDEABC::PhoneNumber::Pcs).number(); + default: + return TQString(); + } +} + +void TDEABCSync::setFieldFromHHOtherPhone(TDEABC::Addressee & abEntry, const TQString &nr, const TDEABCSync::Settings &s) +{ + int phoneType = 0; + switch (s.fieldForOtherPhone()) + { + // One very special case which doesn't even map to a real phone type in KABC + case eAssistant: + abEntry.insertCustom(CSL1("KADDRESSBOOK"), CSL1("AssistantsName"), nr); + return; + // Special case: map phone to email, needs different handling. + case eEmail2: + abEntry.insertEmail(nr); + return; + // Remaining cases all map to various phone types + case eOtherPhone: + phoneType = 0; + break; + case eBusinessFax: + phoneType = TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Work; + break; + case eHomeFax: + phoneType = TDEABC::PhoneNumber::Fax | TDEABC::PhoneNumber::Home; + break; + case eCarPhone: + phoneType = TDEABC::PhoneNumber::Car; + break; + case eTelex: + phoneType = TDEABC::PhoneNumber::Bbs; + break; + case eTTYTTDPhone: + phoneType = TDEABC::PhoneNumber::Pcs; + break; + default: + WARNINGKPILOT << "Unknown phone mapping " << s.fieldForOtherPhone() << endl; + phoneType = 0; + } + TDEABC::PhoneNumber phone = abEntry.phoneNumber(phoneType); + phone.setNumber(nr); + phone.setType(phoneType); // Double-check in case there was no phonenumber of given type + abEntry.insertPhoneNumber(phone); +} + +void TDEABCSync::setAddress(PilotAddress &toPilotAddr, + const TDEABC::Address & abAddress) +{ + toPilotAddr.setField(entryAddress, abAddress.street()); + toPilotAddr.setField(entryCity, abAddress.locality()); + toPilotAddr.setField(entryState, abAddress.region()); + toPilotAddr.setField(entryZip, abAddress.postalCode()); + toPilotAddr.setField(entryCountry, abAddress.country()); +} + + +bool TDEABCSync::isArchived(const TDEABC::Addressee &addr) +{ + return addr.custom(TDEABCSync::appString, TDEABCSync::flagString) == TQString::number(SYNCDEL); +} + +void TDEABCSync::makeArchived(TDEABC::Addressee &addr) +{ + FUNCTIONSETUP; + addr.insertCustom(TDEABCSync::appString, TDEABCSync::flagString, TQString::number(SYNCDEL)); + addr.removeCustom(TDEABCSync::appString, TDEABCSync::idString); +} + + + + +void TDEABCSync::copy(PilotAddress &toPilotAddr, + const TDEABC::Addressee &fromAbEntry, + const PilotAddressInfo &appInfo, + const TDEABCSync::Settings &syncSettings) +{ + FUNCTIONSETUP; + + toPilotAddr.setDeleted(false); + + // don't do a reset since this could wipe out non copied info + //toPilotAddr.reset(); + toPilotAddr.setField(entryLastname, fromAbEntry.familyName()); + toPilotAddr.setField(entryFirstname, fromAbEntry.givenName()); + toPilotAddr.setField(entryCompany, fromAbEntry.organization()); + toPilotAddr.setField(entryTitle, fromAbEntry.prefix()); + toPilotAddr.setField(entryNote, fromAbEntry.note()); + + // do email first, to ensure they get stored + toPilotAddr.setEmails(fromAbEntry.emails()); + + // now in one fell swoop, set all phone numbers from the Addressee. Note, + // we don't need to differentiate between Fax numbers here--all Fax numbers + // (Home Fax or Work Fax or just plain old Fax) will get synced to the Pilot + TDEABCSync::setPhoneNumbers(appInfo,toPilotAddr,fromAbEntry.phoneNumbers()); + + // Other field is an oddball and if the user has more than one field set + // as "Other" then only one will be carried over. + TQString oth = TDEABCSync::getFieldForHHOtherPhone(fromAbEntry,syncSettings); + DEBUGKPILOT << fname << ": putting: ["< &customMapping() const + { + return fCustomMapping; + } + void setCustomMapping(const TQValueVector &v) + { + if (v.count()==4) + { + fCustomMapping = v; + } + } + int custom(int index) const + { + if ( (index<0) || (index>3) ) + { + return 0; + } + else + { + return fCustomMapping[index]; + } + } + + int fieldForOtherPhone() const + { + return fOtherPhone; + } + void setFieldForOtherPhone(int v) + { + fOtherPhone = v; + } + + bool preferHome() const + { + return fPreferHome; + } + void setPreferHome(bool v) + { + fPreferHome = v; + } + + int faxTypeOnPC() const + { + return fFaxTypeOnPC; + } + void setFaxTypeOnPC(int v) + { + fFaxTypeOnPC = v; + } + private: + TQString fDateFormat; + TQValueVector fCustomMapping; + int fOtherPhone; + bool fPreferHome; + int fFaxTypeOnPC; + } ; + + + /** Return a list of all the phone numbers (max. 8) set in this + * handheld entry @p a . Email entries are ignored. + */ + TDEABC::PhoneNumber::List getPhoneNumbers(const PilotAddress &a); + + /** Set the phone numbers from @p list in the handheld entry + * @p a (with info block @p info providing the mapping of category + * names and some other fiddly stuff) as far as possible. + * @em No overflow handling is done at all. If the desktop has + * more than 5 phone entries, the remainder are dropped. + */ + void setPhoneNumbers(const PilotAddressInfo &info, + PilotAddress &a, + const TDEABC::PhoneNumber::List &list); + + /** Given a list of category names from the KDE side (e.g. attached + * to a PC-based Addressee) @p categorynames , look for the + * category @em best matching the category @p category + * in the appinfo block @p info . Here, best is defined as follows: + * - if the name of category @p category is in the list, use it + * - otherwise use the first category from the list that is a valid + * category on the handheld. + * - use Pilot::Unfiled if none match. + * + * @return Category index that best matches. + * @return Pilot::Unfiled if no best match. + */ + unsigned int bestMatchedCategory(const TQStringList &categorynames, + const PilotAddressInfo &info, + unsigned int category); + + /** As above, but return the name of the category. */ + inline TQString bestMatchedCategoryName(const TQStringList &categorynames, + const PilotAddressInfo &info, + unsigned int category) + { + return info.categoryName( + bestMatchedCategory(categorynames, info, category)); + } + + /** Give the addressee @p abEntry the category @p cat (leaving + * existing category assignments intact). + */ + void setCategory(TDEABC::Addressee &abEntry, const TQString &cat); + + /* These are string identifiers used for custom properties in the addressees, + * used to store KPilot-specific settings. + */ + const TQString appString=CSL1("KPILOT"); ///< Identifier for the application + const TQString flagString=CSL1("Flag"); ///< Flags: synced or not + const TQString idString=CSL1("RecordID"); ///< Record ID on HH for this addressee + + + /** Get the string value for HH custom field @p index (0..3) from the addressee + * @p abEntry . Which @em actual field this is depends on the mapping + * of custom HH fields to PC fields. This mapping is given by the @p customMapping + * which may be created from the conduit settings or by hand. Since one of the + * possible actual fields is "birthday," which needs formatting, use the date format + * string @p dateFormat. If this is empty, use the locale setting. + * + * @return String value for HH custom field @p index + * @return Null TQString on error (is also a valid return value) + */ + TQString getFieldForHHCustom( + unsigned int index, + const TDEABC::Addressee &abEntry, + const Settings &settings); + + /** Set a field of the PC @p abEntry address from the custom HH field. + * Use value @p value . The value comes from custom field @p index + * using the interpretation of custom fields @p customMapping . Because + * one of the interpretations includes the birthday, use the date format + * @p dateFormat ; if empty, use the local format when setting dates from the HH. + */ + void setFieldFromHHCustom( + const unsigned int index, + TDEABC::Addressee &abEntry, + const TQString &value, + const Settings &settings); + + /** The HH has a phone type "other" which may be mapped to any one of + * several PC side phone numbers. Return the right one depending in the mapping. + * + * @note @p mappingForOther should come from AbbrowserSettings::pilotOther() + */ + TQString getFieldForHHOtherPhone(const TDEABC::Addressee &abEntry, const Settings &s); + + /** The HH has a phone type "other" which may be mapped to any one + * of several PC side phone numbers. Store the number @p nr in the + * PC side phone field indicated by @p mappingForOther . + * + * @note @p mappingForOther should come from AbbrowserSettings::pilotOther() + */ + void setFieldFromHHOtherPhone(TDEABC::Addressee &abEntry, const TQString &nr, const Settings &s); + + /** Returns the address portion of an addressee. Since the HH can only store + * one address, we return the preferred address (if the Addressee @p abEntry + * has one) and then either home or business depending on @p preferHome + * and if that doesn't exist, the other one and if @em that doesn't exist, + * return the preferred home or work address if it exists. + */ + TDEABC::Address getAddress(const TDEABC::Addressee &abEntry, const Settings &); + + /** Set the address fields of the HH record from the @p abAddress . */ + void setAddress(PilotAddress &toPilotAddr, const TDEABC::Address &abAddress); + + bool isArchived(const TDEABC::Addressee &); + void makeArchived(TDEABC::Addressee &); + + void copy(PilotAddress &toPilotAddr, + const TDEABC::Addressee &fromAbEntry, + const PilotAddressInfo &appInfo, + const Settings &syncSettings); + void copy(TDEABC::Addressee &toAbEntry, + const PilotAddress &fromPiAddr, + const PilotAddressInfo &appInfo, + const Settings &syncSettings); + + void showAddressee(const TDEABC::Addressee &); +} + +#endif + diff --git a/conduits/configure.in.in b/conduits/configure.in.in index db7d8d7..ae2359d 100644 --- a/conduits/configure.in.in +++ b/conduits/configure.in.in @@ -23,7 +23,7 @@ dnl dnl dnl Questions and comments can be sent to kde-pim@kde.org dnl -dnl This was copied and adapted from kabc's ldap configure.in.in +dnl This was copied and adapted from tdeabc's ldap configure.in.in AC_DEFUN([KPILOT_CHECK_MAL], diff --git a/conduits/docconduit/CMakeLists.txt b/conduits/docconduit/CMakeLists.txt index 8793b28..72e6445 100644 --- a/conduits/docconduit/CMakeLists.txt +++ b/conduits/docconduit/CMakeLists.txt @@ -58,7 +58,7 @@ kde3_add_kcfg_files(kpalmdoc_SRCS kpalmdocSettings.kcfgc) trinity_add_ui_files(kpalmdoc_SRCS kpalmdoc_dlgbase.ui) trinity_automoc(${kpalmdoc_SRCS}) add_executable(kpalmdoc ${kpalmdoc_SRCS}) -target_link_libraries(kpalmdoc ${QT_LIBRARIES} kpilot tdeui kio) +target_link_libraries(kpalmdoc ${QT_LIBRARIES} kpilot tdeui tdeio) kpilot_rpath(kpalmdoc) install( diff --git a/conduits/docconduit/Makefile.am b/conduits/docconduit/Makefile.am index 617df41..2e1f79c 100644 --- a/conduits/docconduit/Makefile.am +++ b/conduits/docconduit/Makefile.am @@ -28,7 +28,7 @@ conduit_doc_la_LIBADD = ../../lib/libkpilot.la libpalmdoc_shared.la \ ##libpalmdoc_shared.la kpalmdoc_SOURCES = kpalmdocSettings.kcfgc kpalmdoc_dlgbase.ui kpalmdoc_dlg.cc kpalmdoc.cpp -kpalmdoc_LDFLAGS = $(PISOCK_LDFLAGS) $(PISOCK_LIB) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +kpalmdoc_LDFLAGS = $(PISOCK_LDFLAGS) $(PISOCK_LIB) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kpalmdoc_LDADD = $(LIB_TDEFILE) $(PISOCK_LDFLAGS) $(PISOCK_LIB) ../../lib/libkpilot.la libpalmdoc_shared.la xdg_apps_DATA = kpalmdoc.desktop diff --git a/conduits/notepadconduit/Makefile.am b/conduits/notepadconduit/Makefile.am index 1e2c35c..33ab473 100644 --- a/conduits/notepadconduit/Makefile.am +++ b/conduits/notepadconduit/Makefile.am @@ -10,5 +10,5 @@ kde_module_LTLIBRARIES = conduit_notepad.la conduit_notepad_la_SOURCES = notepadconduit.kcfgc notepad-setup.ui \ notepad-conduit.cc notepad-factory.cc conduit_notepad_la_LDFLAGS= -module $(KDE_PLUGIN) $(all_libraries) $(PISOCK_LIB) $(LIB_QT) -ltdecore -ltdeio -ltdeui -conduit_notepad_la_LIBADD= ../../lib/libkpilot.la $(LIB_TDEUI) $(LIB_KIO) +conduit_notepad_la_LIBADD= ../../lib/libkpilot.la $(LIB_TDEUI) $(LIB_TDEIO) diff --git a/conduits/popmail/Makefile.am b/conduits/popmail/Makefile.am index 3a87f22..cc1e444 100644 --- a/conduits/popmail/Makefile.am +++ b/conduits/popmail/Makefile.am @@ -17,7 +17,7 @@ conduit_popmail_la_SOURCES = popmailSettings.kcfgc setup-dialog.ui \ popmail-factory.cc setupDialog.cc \ popmail-conduit.cc conduit_popmail_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) $(PISOCK_LIB) $(LIB_QT) -ltdecore -ltdeio -ltdeui -lDCOP -conduit_popmail_la_LIBADD = ../../lib/libkpilot.la $(LIB_KIO) +conduit_popmail_la_LIBADD = ../../lib/libkpilot.la $(LIB_TDEIO) # this option you can leave out. Just, if you use "make dist", you need it noinst_HEADERS = popmail-conduit.h setupDialog.h diff --git a/conduits/sysinfoconduit/Makefile.am b/conduits/sysinfoconduit/Makefile.am index b1f87be..d8f48ae 100644 --- a/conduits/sysinfoconduit/Makefile.am +++ b/conduits/sysinfoconduit/Makefile.am @@ -16,7 +16,7 @@ conduit_sysinfo_la_SOURCES = sysinfoSettings.kcfgc \ sysinfo-conduit.cc \ sysinfo-setup_dialog.ui conduit_sysinfo_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) $(PISOCK_LIB) $(LIB_QT) -ltdecore -ltdeio -ltdeui -conduit_sysinfo_la_LIBADD = ../../lib/libkpilot.la $(LIB_TDEUI) $(LIB_KIO) +conduit_sysinfo_la_LIBADD = ../../lib/libkpilot.la $(LIB_TDEUI) $(LIB_TDEIO) kpilot_sysinfo_data_DATA = Template.html Template.txt kpilot_sysinfo_datadir = $(kde_datadir)/kpilot/sysinfoconduit diff --git a/kpilot/CMakeLists.txt b/kpilot/CMakeLists.txt index 8f10499..5144077 100644 --- a/kpilot/CMakeLists.txt +++ b/kpilot/CMakeLists.txt @@ -79,7 +79,7 @@ kde3_add_dcop_skels(kpilotTest_SRCS loggerDCOP.h) trinity_automoc(${kpilotTest_SRCS}) add_executable(kpilotTest ${kpilotTest_SRCS}) -target_link_libraries(kpilotTest ${QT_LIBRARIES} kpilot tdeui kio) +target_link_libraries(kpilotTest ${QT_LIBRARIES} kpilot tdeui tdeio) kpilot_rpath(kpilotTest) ### @@ -99,7 +99,7 @@ kde3_add_dcop_skels(kpilotDaemon_SRCS loggerDCOP.h pilotDaemonDCOP.h) kde3_add_dcop_stubs(kpilotDaemon_SRCS loggerDCOP.h kpilotDCOP.h) trinity_automoc(${kpilotDaemon_SRCS}) add_executable(kpilotDaemon ${kpilotDaemon_SRCS}) -target_link_libraries(kpilotDaemon ${QT_LIBRARIES} kpilot tdeui kio) +target_link_libraries(kpilotDaemon ${QT_LIBRARIES} kpilot tdeui tdeio) kpilot_rpath(kpilotDaemon) ### @@ -137,7 +137,7 @@ kde3_add_dcop_skels(kpilot_SRCS loggerDCOP.h kpilotDCOP.h) kde3_add_dcop_stubs(kpilot_SRCS pilotDaemonDCOP.h) trinity_automoc(${kpilot_SRCS}) add_executable(kpilot_bin ${kpilot_SRCS}) -target_link_libraries(kpilot_bin ${QT_LIBRARIES} kpilot tdeutils tdeui kio) +target_link_libraries(kpilot_bin ${QT_LIBRARIES} kpilot tdeutils tdeui tdeio) kpilot_rpath(kpilot_bin) set_target_properties(kpilot_bin PROPERTIES OUTPUT_NAME kpilot diff --git a/kpilot/Makefile.am b/kpilot/Makefile.am index 6e71abc..e715651 100644 --- a/kpilot/Makefile.am +++ b/kpilot/Makefile.am @@ -18,7 +18,7 @@ METASOURCES = AUTO INCLUDES= $(PISOCK_INCLUDE) -I$(top_srcdir)/lib $(all_includes) libconfiguration_la_SOURCES = kpilotConfig.cc kpilotSettings.kcfgc -libconfiguration_la_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +libconfiguration_la_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kcm_kpilot_la_SOURCES = pilotDaemonDCOP.stub kpilotConfigDialog.cc \ kpilotConfigDialog_device.ui \ @@ -35,7 +35,7 @@ kcm_kpilot_la_SOURCES = pilotDaemonDCOP.stub kpilotConfigDialog.cc \ kpilotConfigWizard_app.ui \ kpilotConfigWizard.cc \ dbSelectionDialog.cc dbSelection_base.ui -kcm_kpilot_la_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -module -avoid-version -no-undefined +kcm_kpilot_la_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor -module -avoid-version -no-undefined kcm_kpilot_la_LIBADD = $(LIB_TDEFILE) $(PISOCK_LIB) \ ../lib/libkpilot.la \ libconfiguration.la @@ -68,9 +68,9 @@ kpilotTest_SOURCES = \ main-test.cc -kpilot_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -kpilotDaemon_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -kpilotTest_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +kpilot_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +kpilotDaemon_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +kpilotTest_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor # the libraries to link against. Be aware of the order. First the libraries, diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 27378f4..ff15f2f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -55,7 +55,7 @@ set(lib_SRCS trinity_automoc(${lib_SRCS}) kde3_add_kcfg_files(lib_SRCS kpilotlibSettings.kcfgc) add_library(kpilot SHARED ${lib_SRCS}) -target_link_libraries(kpilot ${PILOTLINK_LIBRARY} ${QT_LIBRARIES} tdeui kio) +target_link_libraries(kpilot ${PILOTLINK_LIBRARY} ${QT_LIBRARIES} tdeui tdeio) kpilot_rpath(kpilot) #---------- INSTALL -----------------------* diff --git a/lib/Makefile.am b/lib/Makefile.am index dba5780..2da70b3 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -29,7 +29,7 @@ libkpilot_la_SOURCES = kpilotlibSettings.kcfgc \ pilotTodoEntry.cc libkpilot_la_LDFLAGS = $(PISOCK_LDFLAGS) -no-undefined $(all_libraries) $(KDE_EXTRA_RPATH) $(KDE_RPATH) -libkpilot_la_LIBADD = $(PISOCK_LIB) $(LIB_TDEUI) $(LIB_TDEABC) -lkcal $(LIB_QT) $(LIB_TDECORE) -lDCOP $(LIB_KIO) +libkpilot_la_LIBADD = $(PISOCK_LIB) $(LIB_TDEUI) $(LIB_TDEABC) -lkcal $(LIB_QT) $(LIB_TDECORE) -lDCOP $(LIB_TDEIO) kpilotincludedir = $(includedir)/kpilot kpilotinclude_HEADERS = \ diff --git a/lib/kpilotlink.h b/lib/kpilotlink.h index bfb8e92..c2fde40 100644 --- a/lib/kpilotlink.h +++ b/lib/kpilotlink.h @@ -118,7 +118,7 @@ class PilotDatabase; * Sometimes, however, periods of inactivity cannot be avoided -- * for instance, if you _have_ to ask the user something during a * sync, or if you are fetching a large amount of data from a slow -* source (libkabc can do that, if your addressbook is on an LDAP +* source (libtdeabc can do that, if your addressbook is on an LDAP * server). During these periods of inactivity (as far as the Pilot * can tell), you can "tickle" the Pilot to keep it awake. This * prevents the communications from being shut down. It's not diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8ad47a8..eaad4db 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -50,6 +50,6 @@ endif (HAVE_CALENDARLOCAL_H) set(importaddresses_SRCS importaddresses.cc) trinity_add_executable(importaddresses ${importaddresses_SRCS}) -target_link_libraries(importaddresses kpilot ${QT_LIBRARIES} kabc kabc_file) +target_link_libraries(importaddresses kpilot ${QT_LIBRARIES} tdeabc tdeabc_file) add_test(importaddresses ${EXECUTABLE_OUTPUT_PATH}/importaddresses) -- cgit v1.2.1