/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Mozilla
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corp.
 * Portions created by the Initial Developer are Copyright (C) 2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s): Rajiv Dayal (rdayal@netscape.com)
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

// This idl will be compiled by MIDL.  MS-COM is used 
// as brdige between MAPI clients and the Mozilla.

import "unknwn.idl";

// this is defined so that we can return an array of strings(i.e array of AB Description strings)
typedef struct
{
	LPTSTR lpszABName;
  LPTSTR lpszABUrl;
}nsMozABDesc, *lpnsMozABDesc;

const int kFirstTimeSyncDirFlag = 0x1;
const int kIsPabDirFlag = 0x2;

// This structure defines the data fields for MozAB based on "nsIAbCard.idl"
// This structure is used for interaction with the other AddressBook Apps
// nsIAbCard changes should be reflected here to take care of those changes
// Take care when converting nsIAbCard to this struct
typedef struct
{
    unsigned long   dwRecordId; // remote record Id for this card
    unsigned long   dwCategoryId; // remote category Id for this card
	unsigned long   dwStatus; // change status for this card

	// standard AB fields for this card
    LPTSTR          firstName;
    LPTSTR          lastName;
    LPTSTR          displayName;
    LPTSTR          nickName;
    LPTSTR          primaryEmail;
    LPTSTR          secondEmail;
    LPTSTR          workPhone;
    LPTSTR          homePhone;
    LPTSTR          faxNumber;
    LPTSTR          pagerNumber;
    LPTSTR          cellularNumber;
    LPTSTR          homeAddress;
    LPTSTR          homeAddress2;
    LPTSTR          homeCity;
    LPTSTR          homeState;
    LPTSTR          homeZipCode;
    LPTSTR          homeCountry;
    LPTSTR          workAddress;
    LPTSTR          workAddress2;
    LPTSTR          workCity;
    LPTSTR          workState;
    LPTSTR          workZipCode;
    LPTSTR          workCountry;
    LPTSTR          jobTitle;
    LPTSTR          department;
    LPTSTR          company;
    /**
     * webPage1 is work web page
     */
    LPTSTR          webPage1;
    /**
     * webPage2 is home web page
     */
    LPTSTR          webPage2;
    LPTSTR          birthYear;
    LPTSTR          birthMonth;
    LPTSTR          birthDay;
    LPTSTR          custom1;
    LPTSTR          custom2;
    LPTSTR          custom3;
    LPTSTR          custom4;
    LPTSTR          notes;
    unsigned long   lastModifiedDate;
	unsigned long   addressToUse; // home, work, ... 
    unsigned long   preferredPhoneNum; // this is displayed in the contact list
    unsigned long   preferMailFormat;
    boolean         isMailList;
    /**
     * If isMailList is true then mailListURI
     * will contain the URI of the associated
     * mail list
     */
    LPSTR           mailListURI;
}nsABCOMCardStruct, *lpnsABCOMCardStruct;

[
    object,
    uuid(C8CE6FC1-CCF1-11d6-B8A5-000064657374),
    helpstring("nsIPalmSync Inteface"),
    pointer_default(unique)
]

interface IPalmSync : IUnknown
{
    HRESULT IsValid();

    // Get the list of Address Books for the currently logged in user profile
    HRESULT nsGetABList([in] BOOL aIsUnicode, [out] short * aABListCount,
						[out, size_is(, *aABListCount)] lpnsMozABDesc * aABList,
						[out, size_is(, *aABListCount)] long ** aABCatIndexList,
						[out, size_is(, *aABListCount)] BOOL ** aFirstTimeSyncList);

    // Synchronize the Address Book represented by the aCategoryIndex and the corresponding aABName in Mozilla
    // this will take care of ABs existing on both ends.
    HRESULT nsSynchronizeAB([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] long aCategoryId, [in] LPTSTR aABName,
                        [in] int aModRemoteRecCount, [in, size_is(aModRemoteRecCount)] lpnsABCOMCardStruct aModRemoteRecList,
                        [out] int * aModMozRecCount, [out, size_is(, *aModMozRecCount)] lpnsABCOMCardStruct * aModMozRecList);

    // All records from a AB represented by aCategoryIndex and aABName into a new or existing Mozilla AB
    HRESULT nsAddAllABRecords([in] BOOL aIsUnicode, [in] BOOL aReplaceExisting, [in] long aCategoryIndex, [in] LPTSTR aABName,
							[in] int aRemoteRecCount, [in, size_is(aRemoteRecCount)] lpnsABCOMCardStruct aRemoteRecList);

    // Get All records from a Mozilla AB
    HRESULT nsGetAllABCards([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName,
                        [out] int * aMozRecCount, [out, size_is(, *aMozRecCount)] lpnsABCOMCardStruct * aMozRecList);

    // Send an ack for done and update the palm rec id for new records added
    HRESULT nsAckSyncDone([in] BOOL aIsSuccess, [in] long aCatIndex, [in] int aNewRecCount, [in, size_is(aNewRecCount)] unsigned long * aNewPalmRecIDList);

    // Update the Address Book's category id and mod time.
    HRESULT nsUpdateABSyncInfo([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName);

    // Delete an addressbook
    HRESULT nsDeleteAB([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName, [in] LPTSTR aABUrl);

    // was this address book deleted in Mozilla?
    HRESULT nsGetABDeleted([in] LPTSTR aABName, [out] BOOL *abDeleted);

    // Rename an addressbook
    HRESULT nsRenameAB([in] BOOL aIsUnicode, [in] long aCategoryIndex, [in] LPTSTR aABName, [in] LPTSTR aABUrl);

    HRESULT nsUseABHomeAddressForPalmAddress ([out] BOOL *useHomeAddress);

    HRESULT nsPreferABHomePhoneForPalmPhone ([out] BOOL * preferHomePhone);
};

