Back to index

lightning-sunbird  0.9+nobinonly
MozABConduitRecord.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_RECORD_H_
00040 #define __MOZABCONDUIT_RECORD_H_
00041 
00042 #include <syncmgr.h>
00043 #include "CPString.h"
00044 #include "CPalmRec.h"
00045 #include <PGenErr.h>
00046 #include <tables.h>
00047 
00048 #include "IPalmSync.h"
00049 
00050 // these identify the types of phone numbers in Palm record
00051 #define PHONE_LABEL_WORK        0
00052 #define PHONE_LABEL_HOME        1
00053 #define PHONE_LABEL_FAX         2
00054 #define PHONE_LABEL_OTHER       3
00055 #define PHONE_LABEL_EMAIL       4
00056 #define PHONE_LABEL_MAIN        5
00057 #define PHONE_LABEL_PAGER       6
00058 #define PHONE_LABEL_MOBILE      7
00059 
00060 // these are flags which says if a field in Palm record exist or not
00061 struct AddrDBRecordFlags {
00062     unsigned name               :1;
00063     unsigned firstName          :1;
00064     unsigned company            :1;
00065     unsigned phone1             :1;
00066     unsigned phone2             :1;
00067     unsigned phone3             :1;
00068     unsigned phone4             :1;
00069     unsigned phone5             :1;
00070     unsigned address            :1;
00071     unsigned city               :1;
00072     unsigned state              :1;
00073     unsigned zipCode            :1;
00074     unsigned country            :1;
00075     unsigned title              :1;
00076     unsigned custom1            :1;
00077     unsigned custom2            :1;
00078     unsigned custom3            :1;
00079     unsigned custom4            :1;
00080     unsigned note               :1;
00081     unsigned reserved           :13;
00082 };
00083 
00084 // these are the flag that identify the type of phone #s in Palm record
00085 struct AddrOptionsType {
00086     unsigned phone1             :4;
00087     unsigned phone2             :4;
00088     unsigned phone3             :4;
00089     unsigned phone4             :4;
00090     unsigned phone5             :4;
00091     unsigned displayPhone       :4;
00092     unsigned reserved           :8;
00093 };
00094 
00095 // class implementation that represents the Mozilla AB Record type 
00096 // used along with Palm record type
00097 class CMozABConduitRecord {
00098     
00099 public:
00100     CMozABConduitRecord(void);
00101     CMozABConduitRecord(CPalmRecord &rec);
00102     CMozABConduitRecord(nsABCOMCardStruct &rec);
00103     virtual ~CMozABConduitRecord();
00104 
00105 public:
00106     // Mozilla AB card data structure member
00107     nsABCOMCardStruct m_nsCard;
00108 
00109     // the following data members are for Palm Record
00110     DWORD m_dwRecordID;
00111     DWORD m_dwStatus;
00112     DWORD m_dwPosition;
00113     CPString m_csName;
00114     CPString m_csFirst;
00115     CPString m_csDisplayName;
00116     CPString m_csTitle;
00117     CPString m_csCompany;
00118     DWORD m_dwPhone1LabelID;
00119     CPString m_csPhone1;
00120     DWORD m_dwPhone2LabelID;
00121     CPString m_csPhone2;
00122     DWORD m_dwPhone3LabelID;
00123     CPString m_csPhone3;
00124     DWORD m_dwPhone4LabelID;
00125     CPString m_csPhone4;
00126     DWORD m_dwPhone5LabelID;
00127     CPString m_csPhone5;
00128     CPString m_csAddress;
00129     CPString m_csCity;
00130     CPString m_csState;
00131     CPString m_csZipCode;
00132     CPString m_csCountry;
00133     CPString m_csNote;
00134     DWORD m_dwPrivate;
00135     DWORD m_dwCategoryID;
00136     CPString m_csCustom1;
00137     CPString m_csCustom2;
00138     CPString m_csCustom3;
00139     CPString m_csCustom4;
00140     DWORD m_dwDisplayPhone; 
00141 
00142 protected:
00143 
00144     // internal utility functions
00145     long CopyFromHHBuffer(TCHAR* pSrc, TCHAR* pDest, int len, int iBufSize);
00146     long CopyFromHHBuffer(TCHAR* pSrc, TCHAR* pDest, int len);
00147     int  StripCRs(TCHAR* pDest, const TCHAR* pSrc, int len);
00148 
00149     void AssignPhoneToMozData(DWORD labelID, LPTSTR buf);
00150 
00151 public:
00152     // rests the data in this record object   
00153     void Reset(void);
00154     // compares with another record object
00155     eRecCompare Compare(const CMozABConduitRecord &rec);
00156 
00157     // converts from Palm record type to self(Mozilla AB) type
00158     long ConvertFromGeneric(CPalmRecord &rec);
00159     // converts from self(Mozilla AB) type to Palm record type
00160     long ConvertToGeneric(CPalmRecord &rec);
00161 
00162     static void CleanUpABCOMCardStruct(nsABCOMCardStruct * card);
00163 
00164 };
00165 
00166 #endif