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

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

[ 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;

    [ uuid(000C1090-0000-0000-C000-000000000046) ]
    dispinterface Installer
    {
    properties:
    methods:
        [id(DISPID_INSTALLER_OPENPACKAGE)]
            Session* OpenPackage(
                [in] VARIANT PackagePath,
                [in, optional, defaultvalue(0)] long Options);
        [id(DISPID_INSTALLER_REGISTRYVALUE), propget]
            BSTR RegistryValue(
                [in] VARIANT Root,
                [in] BSTR Key,
                [in, optional] VARIANT Value);
        [id(DISPID_INSTALLER_PRODUCTSTATE), propget]
            MsiInstallState ProductState(
                [in] BSTR Product);
        [id(DISPID_INSTALLER_PRODUCTS), propget]
            StringList *Products();
    }

    [ 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);
    }

    [ uuid(000C1095-0000-0000-C000-000000000046) ]
    dispinterface StringList
    {
        properties:
        methods:
        [id(DISPID_STRINGLIST_ITEM), propget]
            BSTR Item(long Index);
        [id(DISPID_STRINGLIST_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:
    }

    [ uuid(000C109C-0000-0000-C000-000000000046) ]
    dispinterface View
    {
        properties:
        methods:
        [id(DISPID_VIEW_EXECUTE)]
            void Execute([in, optional, defaultvalue(0)] Record *Params);
        [id(DISPID_VIEW_FETCH)]
            Record* Fetch();
        [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);
    }

    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;

    [ 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_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:
    }
}
