Back to index

lightning-sunbird  0.9+nobinonly
nsAbIPCCard.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Created by: Rajiv Dayal <rdayal@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or 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 nsAbIPCCard_h__
00040 #define nsAbIPCCard_h__
00041 
00042 #include "nsAbMDBCardProperty.h"
00043 #include "nsIAbMDBCard.h"
00044 #include "nsISupportsArray.h"
00045 #include "nsVoidArray.h"
00046 #include "IPalmSync.h"
00047 
00048 // these are states of Palm record
00049 // as defined in the Palm CDK
00050 #define ATTR_DELETED        0x0001
00051 #define ATTR_ARCHIVED       0x0002
00052 #define ATTR_MODIFIED       0x0004
00053 #define ATTR_NEW            0x0008
00054 #define ATTR_NONE           0x0020
00055 #define ATTR_NO_REC         0x0040
00056 
00057 class nsAbIPCCard : public nsAbMDBCardProperty
00058 {
00059 public:
00060     NS_DECL_ISUPPORTS_INHERITED
00061     
00062     // this checks for all card data fields
00063     NS_IMETHOD Equals(nsIAbCard *card, PRBool *_retval);
00064     PRBool Equals(nsABCOMCardStruct * card, nsStringArray & differingAttrs);
00065     PRBool EqualsAfterUnicodeConversion(nsABCOMCardStruct * card, nsStringArray & differingAttrs);
00066     
00067     // this check names attribs: first name + last name + display name + nickname
00068     PRBool Same(nsABCOMCardStruct * card, PRBool isUnicode=PR_TRUE);
00069     PRBool Same(nsIAbCard *card);
00070 
00071     NS_IMETHOD Copy(nsIAbCard *srcCard);
00072     nsresult Copy(nsABCOMCardStruct * srcCard);
00073     nsresult ConvertToUnicodeAndCopy(nsABCOMCardStruct * srcCard);
00074 
00075     // this function will allocate new memory for the passed in card struct data members
00076     // the caller needs to CoTaskMemFree once it is done using the card struct
00077     nsresult GetABCOMCardStruct(PRBool isUnicode, nsABCOMCardStruct * card);
00078 
00079     nsAbIPCCard();
00080     nsAbIPCCard(nsIAbCard *card);
00081     nsAbIPCCard(nsABCOMCardStruct *card, PRBool isUnicode=PR_TRUE);
00082     virtual ~nsAbIPCCard();
00083 
00084     void SetStatus(PRUint32 status) { mStatus = status; }
00085     PRUint32 GetStatus() { return mStatus; }
00086     void SetRecordId(PRUint32 recID) { mRecordId = recID; }
00087     PRUint32 GetRecordId() { return mRecordId; }
00088     void SetCategoryId(PRUint32 catID) { mCategoryId = catID; }
00089     PRUint32 GetCategoryId() { return mCategoryId; }
00090 
00091 private:
00092     PRUint32 mRecordId;
00093     PRUint32 mCategoryId;
00094     PRUint32 mStatus;
00095 
00096     void CopyValue(PRBool isUnicode, nsString & attribValue, LPTSTR * result);
00097     PRBool CompareValue(PRBool isUnicode, LPTSTR cardValue, nsString & attribValue);
00098     void SplitHomeAndWorkAddresses(nsABCOMCardStruct * card, PRBool isUnicode);
00099     void SplitAddresses(PRBool isUnicode, LPTSTR homeAddress, LPTSTR workAddress);
00100     void JoinHomeAndWorkAddresses(PRBool isUnicode, nsABCOMCardStruct * card);
00101     void JoinAddress(PRBool isUnicode, LPTSTR *ptrAddress, nsString &address1, nsString &address2);
00102 };
00103 
00104 #endif