/*
 * Copyright 2018 Nikolay Sivov for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#if 0
#pragma makedep install
#endif

interface IOpcPartUri;
interface IOpcUri;
interface IOpcRelationship;
interface IOpcRelationshipSet;

typedef [v1_enum] enum
{
    OPC_READ_DEFAULT = 0,
    OPC_VALIDATE_ON_LOAD = 1,
    OPC_CACHE_ON_ACCESS = 2,
} OPC_READ_FLAGS;

typedef [v1_enum] enum
{
    OPC_WRITE_DEFAULT = 0,
    OPC_WRITE_FORCE_ZIP32 = 1,
} OPC_WRITE_FLAGS;

[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee71),
    pointer_default(ref)
]
interface IOpcPart : IUnknown
{
    HRESULT GetRelationshipSet(
        [out, retval] IOpcRelationshipSet **relationship_set
    );

    HRESULT GetContentStream(
        [out, retval] IStream **stream
    );

    HRESULT GetName(
        [out, retval] IOpcPartUri **name
    );

    HRESULT GetContentType(
        [out, string, retval] LPWSTR *type
    );

    HRESULT GetCompressionOptions(
        [out, retval] OPC_COMPRESSION_OPTIONS *options
    );
}

[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee75),
    pointer_default(ref)
]
interface IOpcPartEnumerator : IUnknown
{
    HRESULT MoveNext(
        [out, retval] BOOL *has_next
    );

    HRESULT MovePrevious(
        [out, retval] BOOL *has_previous
    );

    HRESULT GetCurrent(
        [out, retval] IOpcPart **part
    );

    HRESULT Clone(
        [out, retval] IOpcPartEnumerator **enumerator
    );
}

[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee76),
    pointer_default(ref)
]
interface IOpcRelationshipEnumerator : IUnknown
{
    HRESULT MoveNext(
        [out, retval] BOOL *has_next
    );

    HRESULT MovePrevious(
        [out, retval] BOOL *has_previous
    );

    HRESULT GetCurrent(
        [out, retval] IOpcRelationship **relationship
    );

    HRESULT Clone(
        [out, retval] IOpcRelationshipEnumerator **enumerator
    );
}

[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee73),
    pointer_default(ref)
]
interface IOpcPartSet : IUnknown
{
    HRESULT GetPart(
        [in] IOpcPartUri *name,
        [out, retval] IOpcPart **part
    );

    HRESULT CreatePart(
        [in] IOpcPartUri *name,
        [in, string] LPCWSTR content_type,
        [in] OPC_COMPRESSION_OPTIONS compression_options,
        [out, retval] IOpcPart **part
    );

    HRESULT DeletePart(
        [in] IOpcPartUri *name
    );

    HRESULT PartExists(
        [in] IOpcPartUri *name,
        [out, retval] BOOL *exists
    );

    HRESULT GetEnumerator(
        [out, retval] IOpcPartEnumerator **enumerator
    );
}

[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee72),
    pointer_default(ref)
]
interface IOpcRelationship : IUnknown
{
    HRESULT GetId(
        [out, string, retval] LPWSTR *id
    );

    HRESULT GetRelationshipType(
        [out, string, retval] LPWSTR *type
    );

    HRESULT GetSourceUri(
        [out, retval] IOpcUri **uri
    );

    HRESULT GetTargetUri(
        [out, retval] IUri **target
    );

    HRESULT GetTargetMode(
        [out, retval] OPC_URI_TARGET_MODE *target_mode
    );
}


[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee74),
    pointer_default(ref)
]
interface IOpcRelationshipSet : IUnknown
{
    HRESULT GetRelationship(
        [in, string] LPCWSTR id,
        [out, retval] IOpcRelationship **relationship
    );

    HRESULT CreateRelationship(
        [in, string, unique] LPCWSTR id,
        [in, string] LPCWSTR type,
        [in] IUri *target_uri,
        [in] OPC_URI_TARGET_MODE target_mode,
        [out, retval] IOpcRelationship **relationship
    );

    HRESULT DeleteRelationship(
        [in, string] LPCWSTR id
    );

    HRESULT RelationshipExists(
        [in, string] LPCWSTR id,
        [out, retval] BOOL *exists
    );

    HRESULT GetEnumerator(
        [out, retval] IOpcRelationshipEnumerator **enumerator
    );

    HRESULT GetEnumeratorForType(
        [in, string] LPCWSTR type,
        [out, retval] IOpcRelationshipEnumerator **enumerator
    );

    HRESULT GetRelationshipsContentStream(
        [out, retval] IStream **stream
    );
}

[
    object,
    uuid(42195949-3b79-4fc8-89c6-fc7fb979ee70),
    pointer_default(ref)
]
interface IOpcPackage : IUnknown
{
    HRESULT GetPartSet(
        [out, retval] IOpcPartSet **part_set
    );

    HRESULT GetRelationshipSet(
        [out, retval] IOpcRelationshipSet **relationship_set
    );
}