Back to index

lightning-sunbird  0.9+nobinonly
MozABConduitSync.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation
00018  *
00019  * Portions created by the Initial Developer are Copyright (C) 2002
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *       Rajiv Dayal <rdayal@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef _MOZABCONDUIT_SYNC_H_
00040 #define _MOZABCONDUIT_SYNC_H_
00041 
00042 #include <Cpalmrec.h>
00043 #include <Pgenerr.h>
00044 
00045 #include "MozABHHManager.h"
00046 #include "MozABPCManager.h"
00047 
00048 #define PERSONAL_ADDRBOOK_URL   "moz-abmdbdirectory://abook.mab"
00049 #define COLLECTED_ADDRBOOK_URL  "moz-abmdbdirectory://history.mab"
00050 
00051 #define ENV_VAR_CONDUTI_LOG "MOZ_CONDUIT_LOG"
00052 
00053 #define CONDUIT_LOG0(fd, format) \
00054   if (fd) \
00055     {fprintf(fd, format); fflush(fd);}
00056 #define CONDUIT_LOG1(fd, format, arg1) \
00057   if (fd) \
00058     {fprintf(fd, format, arg1); fflush(fd);}
00059 #define CONDUIT_LOG2(fd, format, arg1, arg2) \
00060   if (fd) \
00061     {fprintf(fd, format, arg1, arg2); fflush(fd);}
00062 #define CONDUIT_LOG3(fd, format, arg1, arg2, arg3) \
00063   if (fd) \
00064     {fprintf(fd, format, arg1, arg2, arg3); fflush(fd);}
00065 #define CONDUIT_LOG4(fd, format, arg1, arg2, arg3, arg4) \
00066   if (fd) \
00067     {fprintf(fd, format, arg1, arg2, arg3, arg4); fflush(fd);}
00068 #define CONDUIT_LOG5(fd, format, arg1, arg2, arg3, arg4, arg5) \
00069   if (fd) \
00070     {fprintf(fd, format, arg1, arg2, arg3, arg4, arg5); fflush(fd);}
00071 
00072 extern FILE *gFD; // logging.
00073 
00074 class CMozABConduitSync
00075 {
00076 public:
00077     // OpenConduit creates a new object using this constructor
00078        CMozABConduitSync(CSyncProperties& rProps);
00079     // destructor    
00080     ~CMozABConduitSync();
00081 
00082     // OpenConduit calls this function to begin the sync process
00083     long Perform();
00084 
00085     friend DWORD WINAPI DoFastSync(LPVOID lpParameter);
00086 
00087 protected:
00088     // default constructor
00089     CMozABConduitSync();
00090     
00091     // initialization method
00092     long GetRemoteDBInfo(int iIndex);
00093 
00094     // synchronization methods
00095     long PerformFastSync();
00096     long PerformSlowSync();
00097     long CopyHHtoPC();
00098     long CopyPCtoHH();
00099     // utility methods
00100     BOOL CategoryExists(CPString &mozABName, BOOL isPAB);
00101     BOOL CategoryNameMatches(CPString &catName, CPString &cutOffMozABName, BOOL isPAB);
00102 
00103 private:
00104     CSyncProperties m_rSyncProperties;
00105 
00106     MozABHHManager *m_dbHH;
00107     MozABPCManager *m_dbPC;
00108     CDbList        *m_remoteDB; 
00109     short           m_TotRemoteDBs;
00110     CSystemInfo     m_SystemInfo;
00111     CONDHANDLE      m_ConduitHandle;
00112 };
00113 
00114 #endif