/*++

Copyright (c) 1998 Seagate Software, Inc.  All rights reserved.


Module Name:

    metaint.idl

Abstract:

    IDL source for Engine metadata (database) interfaces.

Author:


Revision History:

--*/

import "oaidl.idl";
import "wsbint.idl";
import "metadef.idl";
import "jobdef.idl";

    [
        object,
        uuid(952B2BC7-FAF6-4B14-84CD-2FA4F0156BC7),
        helpstring("ISegRec Interface"),
        pointer_default(unique)
    ]
    interface ISegRec : IWsbDbEntity
    {
    HRESULT GetSegmentRecord( [out] GUID* pBagId, [out] LONGLONG *pSegStartLoc, [out] LONGLONG *pSegLen,[out] USHORT *pSegFlags, [out] GUID *pPrimPos, [out] LONGLONG *pSecPos );
    HRESULT SetSegmentRecord( [in] GUID bagId, [in] LONGLONG segStartLoc, [in] LONGLONG segLen,[in] USHORT segFlags, [in] GUID primPos, [in] LONGLONG secPos );
    HRESULT GetSegmentFlags( [out] USHORT *pSegFlags);
    HRESULT SetSegmentFlags( [in] USHORT segFlags); 
    HRESULT GetPrimPos( [out] GUID *pPrimPos);
    HRESULT SetPrimPos( [in] GUID PrimPos); 
    HRESULT GetSecPos( [out] LONGLONG *pSecPos);
    HRESULT SetSecPos( [in] LONGLONG secPos); 
    };

    [
        object,
        uuid(450024A0-47D0-11D0-9E1E-00A0C916F120),
        helpstring("IBagHole Interface"),
        pointer_default(unique)
    ]
    interface IBagHole : IWsbDbEntity
    {
    HRESULT GetBagHole( [out] GUID* pBagId, [out] LONGLONG *pSegStartLoc, [out] LONGLONG *pSegLen );
    HRESULT SetBagHole( [in] GUID BagId, [in] LONGLONG segStartLoc, [in] LONGLONG segLen );
    };


    [
        object,
        uuid(B13FA471-4E1B-11D0-9E22-00A0C916F120),
        helpstring("IBagInfo Interface"),
        pointer_default(unique)
    ]
    interface IBagInfo : IWsbDbEntity
    {
    HRESULT GetBagInfo( [out] HSM_BAG_STATUS *pStatus, [out] GUID* pBagId, [out] FILETIME *pBirthDate, [out] LONGLONG *pLen,[out] USHORT *pType, [out] GUID *pVolId,[out] LONGLONG *pDeletedBagAmount, [out] SHORT *pRemoteDataSet);
    HRESULT SetBagInfo( [in] HSM_BAG_STATUS status, [in] GUID bagId, [in] FILETIME birthDate, [in] LONGLONG len,[in] USHORT type, [in] GUID volId, [in] LONGLONG deletedBagAmount, [in] SHORT remoteDataSet );
    };

    [
        object,
        uuid(072E876C-B1CD-4344-A038-4668E931DDAD),
        helpstring("IMediaInfo Interface"),
        pointer_default(unique)
    ]
    interface IMediaInfo : IWsbDbEntity
    {
    HRESULT GetCapacity     ([out] LONGLONG *pCapacity);

    HRESULT GetCopyDescription  ([in] USHORT copyNumber, 
                                 [out, string] OLECHAR **pDescription,
                                 [in] ULONG bufferSize); 
    HRESULT GetCopyInfo         ([in] USHORT copyNumber, 
                                 [out] GUID *pMediaSubsystemId, 
                                 [out, string] OLECHAR **pDescription, 
                                 [in] ULONG descriptionBufferSize,
                                 [out, string] OLECHAR **pName, 
                                 [in] ULONG nameBufferSize,
                                 [out] FILETIME *pUpdate, 
                                 [out] HRESULT *pLastError,
                                 [out] SHORT *pNextRemoteDataSet );
    HRESULT GetCopyLastError    ([in] USHORT copyNumber, 
                                 [out] HRESULT *pLastError);
    HRESULT GetCopyMediaSubsystemId ([in] USHORT copyNumber, 
                                     [out] GUID *pMediaSubsystemId);
    HRESULT GetCopyName         ([in] USHORT copyNumber, 
                                 [out, string] OLECHAR **pName,  
                                 [in] ULONG bufferSize); 
    HRESULT GetCopyNextRemoteDataSet ([in] USHORT copyNumber, 
                                      [out] SHORT *pNextRemoteDataSet);
    HRESULT GetCopyUpdate   ([in] USHORT copyNumber, 
                             [out] FILETIME *pUpdate); 

    HRESULT GetDescription  ([out, string] OLECHAR **pDescription,
                             [in] ULONG bufferSize);

    HRESULT GetFreeBytes    ([out] LONGLONG *pFreeBytes);
    
    HRESULT GetId           ([out] GUID *pId);
    HRESULT GetLastError    ([out] HRESULT *pLastError);
    HRESULT GetLastKnownGoodMasterInfo  ([out] GUID* pMediaId, 
                                        [out] GUID *pMediaSubsystemId, 
                                        [out] GUID *pStoragePoolId, 
                                        [out] LONGLONG *pFreeBytes, 
                                        [out] LONGLONG *pCapacity, 
                                        [out] HRESULT *pLastError, 
                                        [out, string] OLECHAR **pDescription, 
                                        [in] ULONG descriptionBufferSize,
                                        [out] HSM_JOB_MEDIA_TYPE *pType,
                                        [out, string] OLECHAR **pName,
                                        [in] ULONG nameBufferSize,
                                        [out]  BOOL *pReadOnly,
                                        [out]  FILETIME *pUpdate,
                                        [out]  SHORT *pNextRemoteDataSet);
    HRESULT GetLKGMasterNextRemoteDataSet	([out] short *pNextRemoteDataSet);
    HRESULT GetLogicalValidBytes	([out] LONGLONG *pLogicalValidBytes);
    HRESULT GetMediaInfo    ([out] GUID* pMediaId, 
                             [out] GUID *pMediaSubsystemId, 
                             [out] GUID *pStoragePoolId, 
                             [out] LONGLONG *pFreeBytes, 
                             [out] LONGLONG *pCapacity, 
                             [out] HRESULT *pLastError, 
                             [out] short *pNextRemoteDataSet, 
                             [out, string] OLECHAR **pDescription, 
                             [in] ULONG descriptionBufferSize,
                             [out] HSM_JOB_MEDIA_TYPE *pType,
                             [out, string] OLECHAR **pName,
                             [in] ULONG nameBufferSize,
                             [out]  BOOL *pReadOnly,
                             [out]  FILETIME *pUpdate,
                             [out]  LONGLONG *pLogicalValidBytes,
                             [out]  BOOL *pRecreate);
    HRESULT GetMediaSubsystemId([out] GUID *pRmsMediaId);
    HRESULT GetName             ([out,string] OLECHAR **pName, 
                                 [in] ULONG bufferSize); 
    HRESULT GetNextRemoteDataSet([out] short *pNextRemoteDataSet);
    HRESULT GetRecallOnlyStatus ( [out] BOOL *pRecallOnlyStatus );
    HRESULT GetRecreate     ([out] BOOL *pRecreate);
    HRESULT GetStoragePoolId([out] GUID *pStoragePoolId);
    HRESULT GetType     ([out] HSM_JOB_MEDIA_TYPE *pType);
    HRESULT GetUpdate   ([out] FILETIME *pUpdate);

    HRESULT SetName         ([in,string] OLECHAR *name); 
    HRESULT SetCapacity     ([in] LONGLONG capacity);
    HRESULT SetCopyName     ([in] USHORT copyNumber, 
                             [in, string] OLECHAR *name ); 
    HRESULT SetCopyNextRemoteDataSet    ([in] USHORT copyNumber, 
                                         [in] SHORT  nextRemoteDataSet ); 
    HRESULT SetCopyDescription  ([in] USHORT copyNumber, 
                                 [in, string] OLECHAR *description); 
    HRESULT SetCopyInfo     ([in] USHORT copyNumber, 
                             [in] GUID mediaSybsystemMediaId, 
                             [in, string] OLECHAR *description, 
                             [in, string] OLECHAR *name, 
                             [in] FILETIME update, 
                             [in] HRESULT lastError,
                             [in] SHORT nextRemoteDataSet);
    HRESULT SetCopyLastError([in] USHORT copyNumber, 
                             [in] HRESULT lastError );
    HRESULT SetCopyMediaSubsystemId ([in] USHORT copyNumber, 
                                    [in] GUID mediaSybsystemMediaId); 
    HRESULT SetCopyUpdate   ([in] USHORT copyNumber, 
                             [in] FILETIME update); 
    HRESULT SetDescription  ([in, string] OLECHAR *description);
    HRESULT SetId           ([in] GUID id);
    HRESULT SetFreeBytes    ([in] LONGLONG FreeBytes);
    HRESULT SetLastError    ([in] HRESULT lastError);
    HRESULT SetLastKnownGoodMasterInfo  ([in] GUID mediaId, 
                                    [in] GUID mediaSubsystemMediaId, 
                                    [in] GUID storagePoolId, 
                                    [in] LONGLONG FreeBytes, 
                                    [in] LONGLONG Capacity, 
                                    [in] HRESULT lastError, 
                                    [in, string] OLECHAR *description, 
                                    [in] HSM_JOB_MEDIA_TYPE type,
                                    [in, string] OLECHAR *name,
                                    [in]  BOOL readOnly,
                                    [in]  FILETIME update,
                                    [in]  SHORT nextRemoteDataSet);
    HRESULT SetLogicalValidBytes([in] LONGLONG logicalValidBytes);
    HRESULT SetMediaInfo    ([in] GUID mediaId, 
                             [in] GUID mediaSubsystemMediaId, 
                             [in] GUID storagePoolId, 
                             [in] LONGLONG FreeBytes, 
                             [in] LONGLONG Capacity, 
                             [in] HRESULT lastError, 
                             [in] short nextRemoteDataSet, 
                             [in, string] OLECHAR *description, 
                             [in] HSM_JOB_MEDIA_TYPE type,
                             [in, string] OLECHAR *name,
                             [in]  BOOL readOnly,
                             [in]  FILETIME update,
                             [in]  LONGLONG logicalValidBytes,
                             [in]  BOOL recreate);
    HRESULT SetMediaSubsystemId([in] GUID rmsMediaId);
    HRESULT SetNextRemoteDataSet([in] short nextRemoteDataSet);
    HRESULT SetRecallOnlyStatus ( [in] BOOL readOnlyStatus );
    HRESULT SetRecreate     ([in] BOOL recreate);
    HRESULT SetStoragePoolId([in] GUID storagePoolId);
    HRESULT SetType         ([in] HSM_JOB_MEDIA_TYPE type);
    HRESULT SetUpdate       ([in] FILETIME update);
    HRESULT DeleteCopy      ([in] USHORT copyNumber);
    HRESULT RecreateMaster  (void);
    HRESULT UpdateLastKnownGoodMaster(void);

/*++

Method Name:

    UpdateLastKnownGoodMaster

Method Description:

    Update the LastKnownGoodMaster info from the current Master info.

Arguments:

    None

Return Value:

    S_OK        - success.

--*/
    };


    [
        object,
        uuid(4A009E82-DC42-11d0-9925-00A0C9058BF6),
        helpstring("IVolAssign Interface"),
        pointer_default(unique)
    ]
    interface IVolAssign : IWsbDbEntity
    {
    HRESULT GetVolAssign( [out] GUID* pBagId, [out] LONGLONG *pSegStartLoc, 
            [out] LONGLONG *pSegLen, [out] GUID* pVolId );
    HRESULT SetVolAssign( [in] GUID BagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen, [in] GUID VolId );
    };


    [
        object,
        uuid(36A90590-3921-4C67-BAD2-CAD166E08B6D),
        helpstring("ISegDb Interface"),
        pointer_default(unique)
    ]
    interface ISegDb : IWsbDb         
    {
    HRESULT Erase();
    HRESULT Initialize( [in, string] OLECHAR* root, [in] IWsbDbSys* pDbSys, [in, out] BOOL* pCreateFlag );

/*++

Method Name:

    Initialize

Method Description:

    Initialize the Engine DB. This involved finding/creating the DB in the
    directory given in root.

Arguments:

    root        - Directory path for the DB.

    pDbSys      - The global DB System for the Engine, which represents the corresponding
                    Jet instance.

    pCreateFlag - IN: If FALSE, return WSB_E_NOTFOUND if the DB does not already exist;
                      if TRUE, create the DB if it does not already exist.
                  OUT: Left as TRUE if the DB was created; set to FALSE if the
                      DB already existed.

Return Value:

    S_OK           - success.
    WSB_E_IDB_FILE_NOT_FOUND - DB does not exist and was not created because CreateFlag was FALSE
    E_...          - Other errors

--*/
    HRESULT BagHoleAdd([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen);
    HRESULT BagHoleFind([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen, [out] IBagHole** ppIBagHole );
    HRESULT BagHoleSubtract([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen);
    HRESULT SegAdd([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen, [in] GUID MediaId, [in] LONGLONG mediaStart, 
            [in, defaultvalue(FALSE)] BOOL indirectRecord);
    HRESULT SegFind([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen, [out] ISegRec** ppISegRec );
    HRESULT SegSubtract([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen );
    HRESULT VolAssignAdd([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen, [in] GUID VolId);
    HRESULT VolAssignFind([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen, [out] IVolAssign** ppIVolAssign );
    HRESULT VolAssignSubtract([in] IWsbDbSession* pDbSession, [in] GUID bagId, [in] LONGLONG segStartLoc, 
            [in] LONGLONG segLen);
    };

