kpilot Library API Documentation

abbrowser-conduit.h

00001 #ifndef _ABBROWSER_CONDUIT_H
00002 #define _ABBROWSER_CONDUIT_H
00003 /* abbrowser-conduit.h                           KPilot
00004 **
00005 ** Copyright (C) 2000,2001 by Dan Pilone
00006 ** Copyright (C) 2000 Gregory Stern
00007 ** Copyright (C) 2002-2003 by Reinhold Kainhofer
00008 **
00009 */
00010 
00011 /*
00012 ** This program is free software; you can redistribute it and/or modify
00013 ** it under the terms of the GNU General Public License as published by
00014 ** the Free Software Foundation; either version 2 of the License, or
00015 ** (at your option) any later version.
00016 **
00017 ** This program is distributed in the hope that it will be useful,
00018 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 ** GNU General Public License for more details.
00021 **
00022 ** You should have received a copy of the GNU General Public License
00023 ** along with this program in a file called COPYING; if not, write to
00024 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00025 ** MA 02111-1307, USA.
00026 */
00027 
00028 /*
00029 ** Bug reports and questions can be sent to kde-pim@kde.org
00030 */
00031 
00032 
00033 #include <qmap.h>
00034 
00035 #include <kabc/addressbook.h>
00036 #include <kabc/addressee.h>
00037 
00038 #include <pilotAddress.h>
00039 #include <plugin.h>
00040 
00041 
00042 
00043 #define SYNCNONE 0
00044 #define SYNCMOD 1
00045 #define SYNCDEL 3
00046 
00047 #define SYNC_FULL 1
00048 #define SYNC_FAST 0
00049 #define SYNC_FIRST 2
00050 
00051 #define CHANGED_NONE 0
00052 #define CHANGED_PC 1
00053 #define CHANGED_PALM 2
00054 #define CHANGED_BOTH CHANGED_PC|CHANGED_PALM
00055 #define CHANGED_ADD  0x100
00056 #define CHANGED_NORES 0x200
00057 #define CHANGED_DUPLICATE CHANGED_ADD|CHANGED_NORES|CHANGED_BOTH
00058 
00059 
00060 using namespace KABC;
00061 
00062 class AbbrowserConduit : public ConduitAction
00063 {
00064 Q_OBJECT
00065 public:
00066         AbbrowserConduit(
00067                 KPilotDeviceLink *o,
00068                 const char *n = 0L,
00069                 const QStringList &a = QStringList() );
00070         virtual ~AbbrowserConduit();
00071         virtual bool exec();
00072 
00073 protected slots:
00074         void syncDeletedRecord();
00075         void syncPCRecToPalm();
00076         void syncPalmRecToPC();
00077         void cleanup();
00078 
00079 private:
00080         enum EConflictResolution {
00081                 eUserChoose=0,
00082                 eDoNotResolve,
00083                 ePilotOverides,
00084                 eAbbrowserOverides,
00085                 eRevertToBackup,
00086                 eKeepBothInAbbrowser
00087         };
00088         EConflictResolution getResolveConflictOption() const { return fConflictResolution; }
00089         bool doSmartMerge() const { return fSmartMerge; }
00090         
00091         EConflictResolution getEntryResolution(const KABC::Addressee & abEntry, const PilotAddress &backupAddress, const PilotAddress & pilotAddress);
00092         EConflictResolution getFieldResolution(const QString &entry, const QString &field, const QString &palm, const QString &backup, const QString &pc);
00093         EConflictResolution ResolutionDialog(QString Title, 
00094                 QString Text, 
00095                 QStringList &lst, 
00096                 QString remember=QString::null, bool*rem=0L) const;
00097 
00098         int _conflict(const QString &entry, const QString &field, const QString &pc, const QString &backup, 
00099                         const QString &palm, bool & mergeNeeded, QString & mergedStr);
00100         int _compare(const QString &str1, const QString &str2) const;
00101 
00106         static bool isPilotStreetHome()  { return fPilotStreetHome; }
00107         static bool isPilotFaxHome()  { return fPilotFaxHome; }
00108 
00109 
00110 
00115         bool _prepare();
00116 
00121         void readConfig();
00122 
00127         bool _loadAddressBook();
00132         bool _saveAddressBook();
00133         
00134         static QString getOtherField(const KABC::Addressee&abEntry);
00135         static void setOtherField(KABC::Addressee&abEntry, QString nr);
00136         static KABC::PhoneNumber getFax(const KABC::Addressee &abEntry);
00137         static KABC::Address getAddress(const KABC::Addressee &abEntry);
00138         
00139 
00140         void _setAppInfo();
00141         KABC::Addressee _addToAbbrowser(const PilotAddress & address);
00142         int _mergeEntries(PilotAddress &pilotAddress, PilotAddress &backupAddress, KABC::Addressee &abEntry);
00143         int _handleConflict(PilotAddress &piAddress, PilotAddress &backup, KABC::Addressee &abEntry);
00144         int _smartMerge(PilotAddress & outPilotAddress, const PilotAddress & backupAddress, KABC::Addressee & outAbEntry);
00145         int _smartMergePhone(KABC::Addressee &abEntry, const PilotAddress &backupAddress, 
00146                 PilotAddress &pilotAddress, PilotAddress::EPhoneType PalmFlag, KABC::PhoneNumber phone, QString
00147                  thisName, QString name);
00148         int _smartMergeEntry(QString abEntry, const PilotAddress &backupAddress, PilotAddress &pilotAddress, int PalmFlag, QString thisName, QString name, QString &mergedString);
00149         int _smartMergeCategories(KABC::Addressee &abAddress, const PilotAddress &backupAddress, PilotAddress &pilotAddress, QString thisName, QString name, QString &mergedString);
00150 
00151         void _removePilotAddress(PilotAddress &address);
00152         void _removeAbEntry(KABC::Addressee addressee);
00153         KABC::Addressee _saveAbEntry(KABC::Addressee &abEntry);
00154         void _checkDelete(PilotRecord *r, PilotRecord *s);
00155 
00159         bool _savePilotAddress(PilotAddress &address, KABC::Addressee &abEntry);
00160         bool _saveBackupAddress(PilotAddress & backup);
00161         
00162         void _copyPhone(KABC::Addressee &toAbEntry, KABC::PhoneNumber phone, QString palmphone);
00163         void _copy(PilotAddress &toPilotAddr, KABC::Addressee &fromAbEntry);
00164         void _copy(KABC::Addressee &toAbEntry, const PilotAddress &fromPilotAddr);
00165         void _setPilotAddress(PilotAddress &toPilotAddr, const KABC::Address &abAddress);
00166         bool _equal(const PilotAddress &piAddress, KABC::Addressee &abEntry) const;
00167         KABC::Addressee _findMatch(const PilotAddress & pilotAddress) const;
00168         int _getCat(const QStringList cats) const ;
00169         void _setCategory(KABC::Addressee &abEntry, QString cat);
00170 
00175    void _mapContactsToPilot( QMap < recordid_t, QString> &idContactMap) const;
00176 
00177 #ifdef DEBUG
00178 
00181         static void showAddressee(const KABC::Addressee &abAddress);
00185         static void showPilotAddress(const PilotAddress &pilotAddress);
00186 #endif
00187 
00188         KABC::Addressee _addToPC(PilotRecord *r);
00189         KABC::Addressee _changeOnPC(PilotRecord*rec, PilotRecord*backup);
00190         bool _deleteOnPC(PilotRecord*rec,PilotRecord*backup);
00191 
00192         void _addToPalm(KABC::Addressee &entry);
00193         void _changeOnPalm(PilotRecord *rec, PilotRecord* backuprec, KABC::Addressee &ad);
00194         void _deleteFromPalm(PilotRecord*rec);
00195 
00196         struct AddressAppInfo fAddressAppInfo;
00197 
00198         bool fSmartMerge;
00199         EConflictResolution fConflictResolution, fEntryResolution;
00200         static bool fPilotStreetHome, fPilotFaxHome;
00201         bool fFullSync, fFirstTime, fArchive;
00202    static enum  ePilotOtherEnum
00203         {
00204                 eOtherPhone,
00205                 eAssistant,
00206 //              eBusiness2,
00207                 eBusinessFax,
00208                 eCarPhone,
00209                 eEmail2,
00210                 eHomeFax,
00211 //              eHomePhone2,
00212                 eTelex,
00213                 eTTYTTDPhone
00214         } ePilotOther;
00215         int syncAction; 
00216         int pilotindex;
00217         bool abChanged;
00218         static const QString appString;
00219         static const QString flagString;
00220         static const QString idString;
00221         QMap < recordid_t, QString> addresseeMap;
00222         QValueList <recordid_t> syncedIds;
00223         KABC::AddressBook* aBook;
00224         KABC::AddressBook::Iterator abiter;
00225         
00226         
00227         
00228         
00229         
00230         
00231         void showAdresses(PilotAddress & pilotAddress, const PilotAddress & backupAddress, KABC::Addressee & abEntry);
00232 } ;
00233 
00234 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:43 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001