/*
 * Copyright (C) 2007 Mike McCormack
 * Copyright (C) 2007 Misha Koshelev
 *
 * 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
 */

#pragma makedep ident
#pragma makedep register
#pragma makedep regtypelib

#include "msiserver_dispids.h"
import "unknwn.idl";
import "wtypes.idl";
import "objidl.idl";
import "oaidl.idl";

[
    uuid(000c101c-0000-0000-c000-000000000046),
    oleautomation,
    object
]
interface IMsiServer : IUnknown
{
    /* FIXME: methods */
}

[
    uuid(000c101d-0000-0000-c000-000000000046),
    oleautomation,
    object
]
interface IMsiMessage : IUnknown
{
    /* FIXME: methods */
}

[
    uuid(000c1025-0000-0000-c000-000000000046),
    oleautomation,
    object
]
interface IMsiCustomAction : IUnknown
{
    /* FIXME: methods */
}

[
    uuid(000c1033-0000-0000-c000-000000000046),
    oleautomation,
    object
]
interface IMsiRemoteAPI : IUnknown
{
    /* FIXME: methods */
}

[
    helpstring("Msi install server"),
    progid("IMsiServer"),
    uuid(000c101c-0000-0000-c000-000000000046)
]
coclass MsiServer { interface IMsiServer; }

[
    helpstring("Microsoft Windows Installer Message RPC"),
    progid("WindowsInstaller.Message"),
    uuid(000c101d-0000-0000-c000-000000000046)
]
coclass MsiServerMessage { interface IMsiMessage; }

[
    threading(both),
    uuid(000c103e-0000-0000-c000-000000000046)
]
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }

[
    helpstring("Microsoft Windows Installer"),
    threading(apartment),
    progid("WindowsInstaller.Installer"),
    uuid(000c1090-0000-0000-c000-000000000046)
]
coclass MsiInstaller { interface Installer; }

[
    uuid(000c1082-0000-0000-c000-000000000046)
]
coclass MsiTransform { }

[
    uuid(000c1084-0000-0000-c000-000000000046)
]
coclass MsiDatabase { }

[
    uuid(000c1086-0000-0000-c000-000000000046)
]
coclass MsiPatch { }

[
    threading(apartment),
    uuid(000c1094-0000-0000-c000-000000000046)
]
/* FIXME: unidentified class */
coclass MsiServerX3 { interface IMsiServer; }

[ uuid(000C1092-0000-0000-C000-000000000046), version(1.0) ]
library WindowsInstaller
{
    dispinterface Installer;
    dispinterface Record;
    dispinterface Session;
    dispinterface Database;
    dispinterface SummaryInfo;
    dispinterface View;
    dispinterface UIPreview;
    dispinterface FeatureInfo;
    dispinterface RecordList;
    dispinterface StringList;
    dispinterface Product;
    dispinterface Patch;

    typedef enum {
        msiInstallStateNotUsed = -7,
        msiInstallStateBadConfig = -6,
        msiInstallStateIncomplete = -5,
        msiInstallStateSourceAbsent = -4,
        msiInstallStateInvalidArg = -2,
        msiInstallStateUnknown = -1,
        msiInstallStateBroken = 0,
        msiInstallStateAdvertised = 1,
        msiInstallStateRemoved = 1,
        msiInstallStateAbsent = 2,
        msiInstallStateLocal = 3,
        msiInstallStateSource = 4,
        msiInstallStateDefault = 5
    } MsiInstallState;

    typedef enum {
        msiOpenDatabaseModeReadOnly = 0,
        msiOpenDatabaseModeTransact = 1,
        msiOpenDatabaseModeDirect = 2,
        msiOpenDatabaseModeCreate = 3,
        msiOpenDatabaseModeCreateDirect = 4,
        msiOpenDatabaseModePatchFile = 32
    } MsiOpenDatabaseMode;

    typedef enum {
        msiUILevelNoChange = 0,
        msiUILevelDefault = 1,
        msiUILevelNone = 2,
        msiUILevelBasic = 3,
        msiUILevelReduced = 4,
        msiUILevelFull = 5,
        msiUILevelHideCancel = 32,
        msiUILevelProgressOnly = 64,
        msiUILevelEndDialog = 128,
        msiUILevelSourceResOnly = 256
    } MsiUILevel;

    [ uuid(000C1090-0000-0000-C000-000000000046) ]
    dispinterface Installer
    {
    properties:
        [id(DISPID_INSTALLER_UILEVEL)]
            MsiUILevel UILevel;
    methods:
        [id(DISPID_INSTALLER_CREATERECORD)]
            Record *CreateRecord([in] long Count);
        [id(DISPID_INSTALLER_OPENPACKAGE)]
            Session* OpenPackage(
                [in] VARIANT PackagePath,
                [in, defaultvalue(0)] long Options);
        [id(DISPID_INSTALLER_OPENPRODUCT)]
            Session* OpenProduct(
                [in] BSTR ProductCode);
        [id(DISPID_INSTALLER_SUMMARYINFORMATION)]
            SummaryInfo* SummaryInformation(
                [in] BSTR PackagePath,
                [in, defaultvalue(0)] long UpdateCount);
        [id(DISPID_INSTALLER_OPENDATABASE)]
            Database *OpenDatabase(
                    [in] BSTR DatabasePath,
                    [in] VARIANT OpenMode);
        [id(DISPID_INSTALLER_ENABLELOG)]
            void EnableLog(
                    [in] BSTR LogMode,
                    [in] BSTR LogFile);
        [id(DISPID_INSTALLER_INSTALLPRODUCT)]
            void InstallProduct(
                [in] BSTR PackagePath,
                [in, defaultvalue("0")] BSTR PropertyValues);
        [id(DISPID_INSTALLER_VERSION)]
            BSTR Version();
        [id(DISPID_INSTALLER_LASTERRORRECORD)]
            Record* LastErrorRecord();
        [id(DISPID_INSTALLER_REGISTRYVALUE), propget]
            BSTR RegistryValue(
                [in] VARIANT Root,
                [in] BSTR Key,
                [in, optional] VARIANT Value);
        [id(DISPID_INSTALLER_ENVIRONMENT), propget]
            BSTR Environment([in] BSTR Variable);
        [id(DISPID_INSTALLER_ENVIRONMENT), propput]
            void Environment(
                [in] BSTR Variable,
                [in] BSTR rhs);
        [id(DISPID_INSTALLER_FILEATTRIBUTES)]
            long FileAttributes([in] BSTR FilePath);
        [id(DISPID_INSTALLER_FILESIZE)]
            long FileSize([in] BSTR FilePath);
        [id(DISPID_INSTALLER_FILEVERSION)]
            BSTR FileVersion(
                [in] BSTR FilePath,
                [in, optional] VARIANT Language);
        [id(DISPID_INSTALLER_PRODUCTSTATE), propget]
            MsiInstallState ProductState(
                [in] BSTR Product);
        [id(DISPID_INSTALLER_PRODUCTINFO), propget]
            BSTR ProductInfo(
                [in] BSTR Product,
                [in] BSTR Attribute);
        [id(DISPID_INSTALLER_PRODUCTS), propget]
            StringList *Products();
        [id(DISPID_INSTALLER_RELATEDPRODUCTS), propget]
            StringList *RelatedProducts(
                [in] BSTR UpgradeCode);
    }

    [ uuid(000C1093-0000-0000-C000-000000000046) ]
    dispinterface Record
    {
    properties:
    methods:
        [id(DISPID_RECORD_STRINGDATA), propget]
            BSTR StringData([in] long Field);
        [id(DISPID_RECORD_STRINGDATA), propput]
            void StringData(
                [in] long Field,
                [in] BSTR rhs);
        [id(DISPID_RECORD_INTEGERDATA), propget]
            long IntegerData([in] long Field);
        [id(DISPID_RECORD_INTEGERDATA), propput]
            void IntegerData(
                [in] long Field,
                [in] long rhs);
        [id(DISPID_RECORD_FIELDCOUNT), propget]
            long FieldCount();
    }

    [ uuid(000C1095-0000-0000-C000-000000000046) ]
    dispinterface StringList
    {
        properties:
        methods:
        [id(DISPID_LIST__NEWENUM)]
            IUnknown _NewEnum();
        [id(DISPID_LIST_ITEM), propget]
            BSTR Item(long Index);
        [id(DISPID_LIST_COUNT), propget]
            long Count();
    }

    [ uuid(000C1096-0000-0000-C000-000000000046) ]
    dispinterface RecordList
    {
        properties:
        methods:
    }

    [ uuid(000C109A-0000-0000-C000-000000000046) ]
    dispinterface UIPreview
    {
        properties:
        methods:
    }

    [ uuid(000C109B-0000-0000-C000-000000000046) ]
    dispinterface SummaryInfo
    {
        properties:
        methods:
        [id(DISPID_SUMMARYINFO_PROPERTY), propget]
            VARIANT Property([in] long Pid);
        [id(DISPID_SUMMARYINFO_PROPERTY), propput]
            void Property(
                [in] long Pid,
                [in] VARIANT rhs);
        [id(DISPID_SUMMARYINFO_PROPERTYCOUNT), propget]
            long PropertyCount();
    }

    typedef enum {
        msiViewModifySeek = -1,
        msiViewModifyRefresh = 0,
        msiViewModifyInsert = 1,
        msiViewModifyUpdate = 2,
        msiViewModifyAssign = 3,
        msiViewModifyReplace = 4,
        msiViewModifyMerge = 5,
        msiViewModifyDelete = 6,
        msiViewModifyInsertTemporary = 7,
        msiViewModifyValidate = 8,
        msiViewModifyValidateNew = 9,
        msiViewModifyValidateField = 10,
        msiViewModifyValidateDelete = 11,
    } _MsiViewModify;                                /* Added underscore to avoid conflict with function name */

    [ uuid(000C109C-0000-0000-C000-000000000046) ]
    dispinterface View
    {
        properties:
        methods:
        [id(DISPID_VIEW_EXECUTE)]
            void Execute([in, defaultvalue(0)] Record *Params);
        [id(DISPID_VIEW_FETCH)]
            Record* Fetch();
        [id(DISPID_VIEW_MODIFY)]
            void Modify(
                [in] _MsiViewModify Mode,
                Record *Record);
        [id(DISPID_VIEW_CLOSE)]
            void Close();
    }

    [ uuid(000C109D-0000-0000-C000-000000000046) ]
    dispinterface Database
    {
        properties:
        methods:
        [id(DISPID_DATABASE_OPENVIEW)]
            View* OpenView([in] BSTR Sql);
        [id(DISPID_DATABASE_SUMMARYINFORMATION), propget]
            SummaryInfo *SummaryInformation([in, defaultvalue(0)] long UpdateCount);
    }

    typedef enum {
        msiDoActionStatusNoAction = 0,
        msiDoActionStatusSuccess = 1,
        msiDoActionStatusUserExit = 2,
        msiDoActionStatusFailure = 3,
        msiDoActionStatusSuspend = 4,
        msiDoActionStatusFinished = 5,
        msiDoActionStatusWrongState = 6,
        msiDoActionStatusBadActionData = 7
    } MsiDoActionStatus;

    typedef enum {
        msiRunModeAdmin = 0,
        msiRunModeAdvertise = 1,
        msiRunModeMaintenance = 2,
        msiRunModeRollbackEnabled = 3,
        msiRunModeLogEnabled = 4,
        msiRunModeOperations = 5,
        msiRunModeRebootAtEnd = 6,
        msiRunModeRebootNow = 7,
        msiRunModeCabinet = 8,
        msiRunModeSourceShortNames = 9,
        msiRunModeTargetShortNames = 10,
        msiRunModeWindows9x = 12,
        msiRunModeZawEnabled = 13,
        msiRunModeScheduled = 16,
        msiRunModeRollback = 17,
        msiRunModeCommit = 18
    } MsiRunMode;

    typedef enum {
        msiEvaluateConditionFalse = 0,
        msiEvaluateConditionTrue = 1,
        msiEvaluateConditionNone = 2,
        msiEvaluateConditionError = 3
    } _MsiEvaluateCondition;           /* Added underscore to avoid conflict with function name */

    typedef enum {
        msiMessageStatusError = -1,
        msiMessageStatusNone = 0,
        msiMessageStatusOk = 1,
        msiMessageStatusCancel = 2,
        msiMessageStatusAbort = 3,
        msiMessageStatusRetry = 4,
        msiMessageStatusIgnore = 5,
        msiMessageStatusYes = 6,
        msiMessageStatusNo = 7
    } MsiMessageStatus;

    typedef enum {
        msiMessageTypeFatalExit = 0,
        msiMessageTypeError          = 0x01000000,
        msiMessageTypeWarning        = 0x02000000,
        msiMessageTypeUser           = 0x03000000,
        msiMessageTypeInfo           = 0x04000000,
        msiMessageTypeFilesInUse     = 0x05000000,
        msiMessageTypeResolveSource  = 0x06000000,
        msiMessageTypeOutOfDiskSpace = 0x07000000,
        msiMessageTypeActionStart    = 0x08000000,
        msiMessageTypeActionData     = 0x09000000,
        msiMessageTypeProgress       = 0x0a000000,
        msiMessageTypeCommonData     = 0x0b000000,
        msiMessageTypeOk = 0,
        msiMessageTypeOkCancel = 1,
        msiMessageTypeAbortRetryIgnore = 2,
        msiMessageTypeYesNoCancel = 3,
        msiMessageTypeYesNo = 4,
        msiMessageTypeRetryCancel = 5,
        msiMessageTypeDefault1 = 0,
        msiMessageTypeDefault2 = 256,
        msiMessageTypeDefault3 = 512
    } MsiMessageType;

    [ uuid(000C109E-0000-0000-C000-000000000046) ]
    dispinterface Session
    {
    properties:
    methods:
        [id(DISPID_SESSION_INSTALLER), propget]
            Installer *Installer();
        [id(DISPID_SESSION_PROPERTY), propget]
            BSTR Property([in] BSTR Name);
        [id(DISPID_SESSION_PROPERTY), propput]
            void Property(
                [in] BSTR Name,
                [in] BSTR rhs);
        [id(DISPID_SESSION_LANGUAGE), propget]
            long Language();
        [id(DISPID_SESSION_MODE), propget]
            VARIANT_BOOL Mode([in] MsiRunMode Flag);
        [id(DISPID_SESSION_MODE), propput]
            void Mode(
                [in] MsiRunMode Flag,
                [in] VARIANT_BOOL rhs);
        [id(DISPID_SESSION_DATABASE), propget]
            Database* Database();
        [id(DISPID_SESSION_DOACTION)]
            MsiDoActionStatus DoAction([in] BSTR Action);
        [id(DISPID_SESSION_EVALUATECONDITION)]
            _MsiEvaluateCondition EvaluateCondition([in] BSTR Expression);
        [id(DISPID_SESSION_MESSAGE)]
            MsiMessageStatus Message(
                [in] MsiMessageType Kind,
                [in] Record *Record);
        [id(DISPID_SESSION_FEATURECURRENTSTATE), propget]
            MsiInstallState FeatureCurrentState([in] BSTR Feature);
        [id(DISPID_SESSION_FEATUREREQUESTSTATE), propget]
            MsiInstallState FeatureRequestState([in] BSTR Feature);
        [id(DISPID_SESSION_FEATUREREQUESTSTATE), propput]
            void FeatureRequestState(
                [in] BSTR Feature,
                [in] MsiInstallState rhs);
        [id(DISPID_SESSION_SETINSTALLLEVEL)]
            void SetInstallLevel([in] long Level);
    }

    [ uuid(000C109F-0000-0000-C000-000000000046) ]
    dispinterface FeatureInfo
    {
        properties:
        methods:
    }

    [ uuid(000C10A0-0000-0000-C000-000000000046) ]
    dispinterface Product
    {
        properties:
        methods:
    }

    [ uuid(000C10A1-0000-0000-C000-000000000046) ]
    dispinterface Patch
    {
        properties:
        methods:
    }
}
