00001 #ifndef _ABBROWSER_CONDUIT_H
00002 #define _ABBROWSER_CONDUIT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <kabc/addressbook.h>
00034
00035 #include <pilotAddress.h>
00036 #include <plugin.h>
00037
00038 #include "kabcRecord.h"
00039
00040
00041 class ResolutionTable;
00042 namespace KABC
00043 {
00044 class Addressee;
00045 class Address;
00046 class PhoneNumber;
00047 class Ticket;
00048 }
00049
00050 using namespace KABC;
00051
00052 typedef QValueList<recordid_t> RecordIDList;
00053
00054 class AbbrowserConduit : public ConduitAction
00055 {
00056 Q_OBJECT
00057 public:
00058 AbbrowserConduit(KPilotLink *o,const char *n = 0L,
00059 const QStringList &a = QStringList() );
00060 virtual ~AbbrowserConduit();
00061
00062
00063
00064
00065 virtual bool exec();
00066 protected slots:
00067 void slotPalmRecToPC();
00068 void slotPCRecToPalm();
00069 void slotDeletedRecord();
00070 void slotDeleteUnsyncedPCRecords();
00071 void slotDeleteUnsyncedHHRecords();
00072 void slotCleanup();
00073
00074 void slotTestRecord();
00075
00076 private:
00077
00078
00079
00080
00081
00082
00083
00084 void readConfig();
00085
00086 void showPilotAddress(const PilotAddress *pilotAddress);
00087 void showAddresses(
00088 const Addressee &pcAddr,
00089 const PilotAddress *backupAddr,
00090 const PilotAddress *palmAddr);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 void _mapContactsToPilot( QMap < recordid_t, QString> &idContactMap);
00101
00102
00103 bool _prepare();
00104
00105
00106 bool _loadAddressBook();
00107
00108
00109 bool _saveAddressBook();
00110 void _getAppInfo();
00111 void _setAppInfo();
00112
00113 void _cleanupAddressBookPointer();
00114
00115
00116
00117
00118
00119
00120
00121 bool syncAddressee(Addressee &pcAddr, PilotAddress*backupAddr,
00122 PilotAddress*palmAddr);
00123 bool _copyToHH(Addressee &pcAddr, PilotAddress*backupAddr,
00124 PilotAddress*palmAddr);
00125 bool _copyToPC(Addressee &pcAddr, PilotAddress*backupAddr,
00126 PilotAddress*palmAddr);
00127 bool _writeBackup(PilotAddress *backup);
00128 bool _deleteAddressee(Addressee &pcAddr, PilotAddress*backupAddr,
00129 PilotAddress*palmAddr);
00130
00131
00132
00133
00134
00135
00136 bool _savePalmAddr(PilotAddress *palmAddr, Addressee &pcAddr);
00137 bool _savePCAddr(Addressee &pcAddr, PilotAddress*backupAddr,
00138 PilotAddress*palmAddr);
00139
00140
00141
00142
00143
00144 inline bool _equal(const QString & str1, const QString & str2) const
00145 {
00146 return (str1.isEmpty() && str2.isEmpty()) || (str1 == str2);
00147 } ;
00148 typedef enum eqFlagsType
00149 {
00150 eqFlagsName=0x1,
00151 eqFlagsAdress=0x2,
00152 eqFlagsPhones=0x4,
00153 eqFlagsNote=0x8,
00154 eqFlagsCategory=0x10,
00155 eqFlagsFlags=0x20,
00156 eqFlagsCustom=0x40,
00157 eqFlagsAll=0xFFFF,
00158 eqFlagsAlmostAll=eqFlagsName|eqFlagsAdress|eqFlagsPhones|eqFlagsNote|eqFlagsCustom
00159 };
00160 bool _equal(const PilotAddress *piAddress, const Addressee &abEntry,
00161 enum eqFlagsType flags=eqFlagsAll) const;
00162
00163
00164
00165
00171 QString _smartMergeString(const QString &pc, const QString & backup,
00172 const QString & palm, ConflictResolution confRes);
00173 bool _buildResolutionTable(ResolutionTable*tab, const Addressee &pcAddr,
00174 PilotAddress *backupAddr, PilotAddress *palmAddr);
00175 bool _applyResolutionTable(ResolutionTable*tab, Addressee &pcAddr,
00176 PilotAddress *backupAddr, PilotAddress *palmAddr);
00177 bool _smartMergeTable(ResolutionTable*tab);
00185 bool _smartMergeAddressee(Addressee &pcAddr, PilotAddress *backupAddr,
00186 PilotAddress *palmAddr);
00187 Addressee _findMatch(const PilotAddress & pilotAddress) const;
00188
00189
00190
00191
00192
00193
00194 AddressBook* aBook;
00195
00196 PilotAddressInfo *fAddressAppInfo;
00197
00198 KABCSync::Settings fSyncSettings;
00199
00200 int pilotindex;
00201 bool abChanged;
00203 QMap < recordid_t, QString> addresseeMap;
00204 RecordIDList syncedIds, allIds;
00205 QString fABookFile;
00206 AddressBook::Iterator abiter;
00211 Ticket *fTicket;
00212 bool fCreatedBook;
00213
00217 KABC::Resource *fBookResource;
00218
00219
00220 } ;
00221
00222 #endif