///*M*
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a licence agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 1997 Intel Corporation. All Rights Reserved.
//
// Filename : CBTimer.idl
// Purpose  : Defines the ICBTimer interface in IDL to compile to .h files.
// Contents : ICBTimer interface specification.
//            ICBCallback interface specification.
//*M*/

//*I*
//  Name    : ICBTimer
//  Purpose : Defines this interface, which is used to register an
//            object for callbacks, setup callbacks, and delay callbacks.
//  Context : This interface is used by any COM object that wishes to
//            schedule callbacks.
//  Notes   : All of the methods exposed by this interface are
//            backed by a mutex which may timeout. This avoids
//            potential deadlock problems. An application using
//            a CBTimer object should be prepared for methods
//            to return unsuccessfully due to such timeouts.
//*I*/
[
	object,
	uuid(CD117003-7004-11D0-9CCF-00A0C9081C19),
	helpstring("ICBTimer Interface"),
	pointer_default(unique)
]
interface ICBTimer : IUnknown
{
	import "oaidl.idl";
        
    // This method is used to register an object to receive callbacks from
    // the CBTimer object. An IUnknown for the object is passed in as well as
    // a context variable which is returned with all callbacks. A CBTimer object
    // can only track one registered object at a time, so if an object wishes to
    // change the dwObjectContext value, it needs to call UnRegisterObject()
    // first, followed by RegisterObject() again.
    HRESULT RegisterObject(
        [in]  IUnknown      *pIUnknown, // Pointer to the IUnknown of the object
                                        // which wishes to receive callbacks.
                                        // Will be QI'd for the ICBTimerCallback interface
                                        // defined below.
        [in]  DWORD        *pdwObjectContext); // This is an uninterpreted context
                                        // value that is returned with all callbacks
                                        // to this address.

    // Request a callback for the object registered via RegisterObject().
    // Multiple callbacks may be registered.
    HRESULT RequestCallback(
        [in]  DWORD         dwDelay,    // Delay, in milliseconds, from the current
                                        // time, after which a callback is requested to occur.
        [in]  DWORD        *pdwCallbackContext, // This is an uninterpreted context
                                        // value that is returned with the callback
                                        // returned for this particular duration.
        [out] DWORD        **ppdwCallbackID); // A nonce which identifies this callback,
                                        // which can be used by the app to cancel the callback.

    // Cancel the indicated callback.                                            
    HRESULT CancelCallback(
        [in]  DWORD        *pdwCallbackID); // Cancel a callback previously requested
                                        // via RequestCallback().

    // Change the delay and context value for this callback.
    HRESULT DelayCallback(
        [in]  DWORD        *pdwCallbackID, // A nonce which identifies this callback
        [in]  DWORD         dwDelay,    // New delay, in milliseconds, from the current
                                        // time, after which a callback is requested to occur.
        [in]  DWORD        *pdwCallbackContext); // This is an uninterpreted context
                                        // value that is returned with the callback
                                        // returned for this particular duration.

    // Cancel all callbacks for this object and release any interfaces held.
    HRESULT UnRegisterObject(void);     
}; // End interface ICBTimer.


//*I*
//  Name    : ICBCallback
//  Purpose : Defines this interface, which is used to deliver
//            callbacks registered via the ICBTimer interface.
//  Context : This interface is queried for the by the CBTimer
//            COM object in response to a call to ICBTimer::RegisterObject().
//            This interface is called when a callback scheduled via
//            ICBTimer::RequestCallback() occurs.
//*I*/
[
	object,
	uuid(CD117008-7004-11D0-9CCF-00A0C9081C19),
	helpstring("ICBCallback Interface"),
	pointer_default(unique)
]
interface ICBCallback : IUnknown
{
	import "oaidl.idl";
        
    // This method is used to deliver a callback after a timeout occurs.
    HRESULT Callback(
        [in]  DWORD        *pdwObjectContext,    // This is the uninterpreted context
                                                // value that is set in RegisterObject().
        [in]  DWORD        *pdwCallbackContext); // This is the uninterpreted context
                                                // value that is set in RequestCallback().
}; // ICBCallback Interface definition


[
	uuid(C8801950-AC9D-11d0-82A1-00AA00B5CA1B),
	version(1.0),
	helpstring("CBTimer 1.0 Type Library")
]
library CBTIMERLib
{
	importlib("stdole2.tlb");

	[
		uuid(CD117007-7004-11D0-9CCF-00A0C9081C19),
		helpstring("CBTimer Class")
	]
	coclass CCBTimer
	{
		[default] interface ICBTimer;
   		[default, source] interface ICBCallback;
	};

};

