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 #include <kabc/address.h> 00038 00039 #include <pilotAddress.h> 00040 #include <plugin.h> 00041 #include <kcrash.h> 00042 00043 00044 #define SYNCNONE 0 00045 #define SYNCMOD 1 00046 #define SYNCDEL 3 00047 00048 using namespace KABC; 00049 class ResolutionTable; 00050 00051 typedef QValueList<recordid_t> RecordIDList; 00052 00053 class AbbrowserConduit : public ConduitAction 00054 { 00055 Q_OBJECT 00056 public: 00057 AbbrowserConduit(KPilotDeviceLink *o,const char *n = 0L, 00058 const QStringList &a = QStringList() ); 00059 virtual ~AbbrowserConduit(); 00060 00061 /********************************************************************* 00062 S Y N C S T R U C T U R E 00063 *********************************************************************/ 00064 virtual bool exec(); 00065 protected slots: 00066 void slotPalmRecToPC(); 00067 void slotPCRecToPalm(); 00068 void slotDeletedRecord(); 00069 void slotDeleteUnsyncedPCRecords(); 00070 void slotDeleteUnsyncedHHRecords(); 00071 void slotCleanup(); 00072 00073 private: 00074 00075 /********************************************************/ 00076 /* Handle the configuration */ 00077 /********************************************************/ 00078 00079 /* Read the global KPilot config file for settings 00080 * particular to the AbbrowserConduit conduit. */ 00081 void readConfig(); 00086 static bool isPilotStreetHome() { return fPilotStreetHome; }; 00087 static bool isPilotFaxHome() { return fPilotFaxHome; }; 00088 static bool isDeleted(const PilotAddress*addr); 00089 static bool isArchived(const PilotAddress*addr); 00090 static bool isArchived(const Addressee &addr); 00091 static bool makeArchived(Addressee &addr); 00092 00093 00094 00095 /********************************************************/ 00096 /* Loading and saving the addressbook and database */ 00097 /********************************************************/ 00098 00099 00100 /* Given a list of contacts, creates the pilot id to contact key map 00101 * and a list of new contacts in O(n) time (single pass) */ 00102 void _mapContactsToPilot( QMap < recordid_t, QString> &idContactMap) const; 00103 /* Do the preperations before doSync or doBackup. 00104 * Load contacts, set the pilot */ 00105 bool _prepare(); 00106 /* Load the contacts from the addressbook. 00107 * @return true if successful, false if not */ 00108 bool _loadAddressBook(); 00109 /* Save the contacts back to the addressbook. 00110 * @return true if successful, false if not */ 00111 bool _saveAddressBook(); 00112 void _getAppInfo(); 00113 void _setAppInfo(); 00114 00115 00116 00117 /********************************************************/ 00118 /* Handle special fields of the Addressees */ 00119 /********************************************************/ 00120 static QString getCustomField(const Addressee &abEntry, const int index); 00121 static void setCustomField(Addressee &abEntry, int index, QString cust); 00122 static QString getOtherField(const Addressee&abEntry); 00123 static void setOtherField(Addressee&abEntry, QString nr); 00124 static PhoneNumber getFax(const Addressee &abEntry); 00125 static void setFax(Addressee &abEntry, QString fax); 00126 static KABC::Address getAddress(const Addressee &abEntry); 00127 QString _getCatForHH(const QStringList cats, const QString curr) const; 00128 void _setCategory(Addressee &abEntry, QString cat); 00129 00130 00131 00132 /********************************************************************* 00133 D E B U G O U T P U T 00134 *********************************************************************/ 00135 #ifdef DEBUG 00136 00139 static void showAddressee(const Addressee &abAddress); 00143 static void showPilotAddress(PilotAddress *pilotAddress); 00144 #endif 00145 void showAdresses(Addressee &pcAddr, PilotAddress *backupAddr, 00146 PilotAddress *palmAddr); 00147 00148 00149 00150 /********************************************************************* 00151 G E N E R A L S Y N C F U N C T I O N 00152 These functions modify the Handheld and the addressbook 00153 *********************************************************************/ 00154 bool syncAddressee(Addressee &pcAddr, PilotAddress*backupAddr, 00155 PilotAddress*palmAddr); 00156 bool _copyToHH(Addressee &pcAddr, PilotAddress*backupAddr, 00157 PilotAddress*palmAddr); 00158 bool _copyToPC(Addressee &pcAddr, PilotAddress*backupAddr, 00159 PilotAddress*palmAddr); 00160 bool _writeBackup(PilotAddress *backup); 00161 bool _deleteAddressee(Addressee &pcAddr, PilotAddress*backupAddr, 00162 PilotAddress*palmAddr); 00163 00164 00165 /********************************************************************* 00166 l o w - l e v e l f u n c t i o n s f o r 00167 adding / removing palm/pc records 00168 *********************************************************************/ 00169 bool _savePalmAddr(PilotAddress *palmAddr, Addressee &pcAddr); 00170 bool _savePCAddr(Addressee &pcAddr, PilotAddress*backupAddr, 00171 PilotAddress*palmAddr); 00172 00173 00174 /********************************************************************* 00175 C O P Y R E C O R D S 00176 *********************************************************************/ 00177 int _compare(const QString & str1, const QString & str2) const; 00178 typedef enum eqFlagsType 00179 { 00180 eqFlagsName=0x1, 00181 eqFlagsAdress=0x2, 00182 eqFlagsPhones=0x4, 00183 eqFlagsNote=0x8, 00184 eqFlagsCategory=0x10, 00185 eqFlagsFlags=0x20, 00186 eqFlagsCustom=0x40, 00187 eqFlagsAll=0xFFFF, 00188 eqFlagsAlmostAll=eqFlagsName|eqFlagsAdress|eqFlagsPhones|eqFlagsNote|eqFlagsCustom 00189 }; 00190 bool _equal(const PilotAddress *piAddress, const Addressee &abEntry, 00191 enum eqFlagsType flags=eqFlagsAll) const; 00192 void _copy(PilotAddress *toPilotAddr, Addressee &fromAbEntry); 00193 void _setPilotAddress(PilotAddress *toPilotAddr, const KABC::Address & abAddress); 00194 void _copyPhone(Addressee &toAbEntry, PhoneNumber phone, QString palmphone); 00195 void _copy(Addressee &toAbEntry, PilotAddress *fromPiAddr); 00196 00197 /********************************************************************* 00198 C O N F L I C T R E S O L U T I O N a n d M E R G I N G 00199 *********************************************************************/ 00205 QString _smartMergeString(const QString &pc, const QString & backup, 00206 const QString & palm, eConflictResolution confRes); 00207 bool _buildResolutionTable(ResolutionTable*tab, const Addressee &pcAddr, 00208 PilotAddress *backupAddr, PilotAddress *palmAddr); 00209 bool _applyResolutionTable(ResolutionTable*tab, Addressee &pcAddr, 00210 PilotAddress *backupAddr, PilotAddress *palmAddr); 00211 bool _smartMergeTable(ResolutionTable*tab); 00219 bool _smartMergeAddressee(Addressee &pcAddr, PilotAddress *backupAddr, 00220 PilotAddress *palmAddr); 00221 Addressee _findMatch(const PilotAddress & pilotAddress) const; 00222 00223 00224 /********************************************************/ 00225 /* D A T A M E M B E R S , S E T T I N G S */ 00226 /********************************************************/ 00227 00228 struct AddressAppInfo fAddressAppInfo; 00229 00230 /* eConflictResolution fEntryResolution;*/ 00231 static bool fPilotStreetHome, fPilotFaxHome; 00232 static bool fArchive; 00233 static enum ePilotOtherEnum 00234 { 00235 eOtherPhone, 00236 eAssistant, 00237 eBusinessFax, 00238 eCarPhone, 00239 eEmail2, 00240 eHomeFax, 00241 eTelex, 00242 eTTYTTDPhone 00243 } ePilotOther; 00244 int pilotindex; 00245 bool abChanged; 00246 static const QString appString; 00247 static const QString flagString; 00248 static const QString idString; 00250 QMap < recordid_t, QString> addresseeMap; 00251 RecordIDList syncedIds, allIds; 00252 static AddressBook* aBook; 00253 AddressBook::Iterator abiter; 00254 // for a local file, we need to obtain a saveTicket when opening the abook 00255 Ticket*ticket; 00256 00257 QString fAbookFile; 00258 enum eAbookTypeEnum { 00259 eAbookResource=0, 00260 eAbookLocal 00261 } fAbookType; 00262 00263 static enum eCustomEnum { 00264 eCustomField, 00265 eCustomBirthdate, 00266 eCustomURL, 00267 eCustomIM 00268 } eCustom[4]; 00269 static QString fCustomFmt; 00270 00271 } ; 00272 00273 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:48 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003