| Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30105
Modified Files:
	shell.cpp 
Added Files:
	PyIAsyncOperation.cpp PyIAsyncOperation.h 
Log Message:
Add IAsyncOperation
--- NEW FILE: PyIAsyncOperation.h ---
// This file declares the IAsyncOperation Interface and Gateway for Python.
// Generated by makegw.py
// ---------------------------------------------------
//
// Interface Declaration
class PyIAsyncOperation : public PyIUnknown
{
public:
	MAKE_PYCOM_CTOR(PyIAsyncOperation);
	static IAsyncOperation *GetI(PyObject *self);
	static PyComTypeObject type;
	// The Python methods
	static PyObject *SetAsyncMode(PyObject *self, PyObject *args);
	static PyObject *GetAsyncMode(PyObject *self, PyObject *args);
	static PyObject *StartOperation(PyObject *self, PyObject *args);
	static PyObject *InOperation(PyObject *self, PyObject *args);
	static PyObject *EndOperation(PyObject *self, PyObject *args);
protected:
	PyIAsyncOperation(IUnknown *pdisp);
	~PyIAsyncOperation();
};
// ---------------------------------------------------
//
// Gateway Declaration
class PyGAsyncOperation : public PyGatewayBase, public IAsyncOperation
{
protected:
	PyGAsyncOperation(PyObject *instance) : PyGatewayBase(instance) { ; }
	PYGATEWAY_MAKE_SUPPORT2(PyGAsyncOperation, IAsyncOperation, IID_IAsyncOperation, PyGatewayBase)
	// IAsyncOperation
	STDMETHOD(SetAsyncMode)(
		BOOL fDoOpAsync);
	STDMETHOD(GetAsyncMode)(
		BOOL * pfIsOpAsync);
	STDMETHOD(StartOperation)(
		IBindCtx * pbcReserved);
	STDMETHOD(InOperation)(
		BOOL * pfInAsyncOp);
	STDMETHOD(EndOperation)(
		HRESULT hResult,
		IBindCtx * pbcReserved,
		DWORD dwEffects);
};
--- NEW FILE: PyIAsyncOperation.cpp ---
// This file implements the IAsyncOperation Interface and Gateway for Python.
// Generated by makegw.py
#include "shell_pch.h"
#include "PyIAsyncOperation.h"
// @doc - This file contains autoduck documentation
// ---------------------------------------------------
//
// Interface Implementation
PyIAsyncOperation::PyIAsyncOperation(IUnknown *pdisp):
	PyIUnknown(pdisp)
{
	ob_type = &type;
}
PyIAsyncOperation::~PyIAsyncOperation()
{
}
/* static */ IAsyncOperation *PyIAsyncOperation::GetI(PyObject *self)
{
	return (IAsyncOperation *)PyIUnknown::GetI(self);
}
// @pymethod |PyIAsyncOperation|SetAsyncMode|Description of SetAsyncMode.
PyObject *PyIAsyncOperation::SetAsyncMode(PyObject *self, PyObject *args)
{
	IAsyncOperation *pIAO = GetI(self);
	if ( pIAO == NULL )
		return NULL;
	// @pyparm int|fDoOpAsync||Description for fDoOpAsync
	BOOL fDoOpAsync;
	if ( !PyArg_ParseTuple(args, "i:SetAsyncMode", &fDoOpAsync) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAO->SetAsyncMode( fDoOpAsync );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAO, IID_IAsyncOperation );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod bool|PyIAsyncOperation|GetAsyncMode|Description of GetAsyncMode.
PyObject *PyIAsyncOperation::GetAsyncMode(PyObject *self, PyObject *args)
{
	IAsyncOperation *pIAO = GetI(self);
	if ( pIAO == NULL )
		return NULL;
	BOOL fIsOpAsync;
	if ( !PyArg_ParseTuple(args, ":GetAsyncMode") )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAO->GetAsyncMode( &fIsOpAsync );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAO, IID_IAsyncOperation );
	PyObject *rc = fIsOpAsync ? Py_True : Py_False;
	return rc;
}
// @pymethod |PyIAsyncOperation|StartOperation|Description of StartOperation.
PyObject *PyIAsyncOperation::StartOperation(PyObject *self, PyObject *args)
{
	IAsyncOperation *pIAO = GetI(self);
	if ( pIAO == NULL )
		return NULL;
	// @pyparm <o PyIBindCtx *>|pbcReserved||Description for pbcReserved
	PyObject *obpbcReserved;
	IBindCtx *pbcReserved;
	if ( !PyArg_ParseTuple(args, "O:StartOperation", &obpbcReserved) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpbcReserved, IID_IBindCtx, (void **)&pbcReserved, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAO->StartOperation( pbcReserved );
	if (pbcReserved) pbcReserved->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAO, IID_IAsyncOperation );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod |PyIAsyncOperation|InOperation|Description of InOperation.
PyObject *PyIAsyncOperation::InOperation(PyObject *self, PyObject *args)
{
	IAsyncOperation *pIAO = GetI(self);
	if ( pIAO == NULL )
		return NULL;
	BOOL fInAsyncOp;
	if ( !PyArg_ParseTuple(args, ":InOperation") )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAO->InOperation( &fInAsyncOp );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAO, IID_IAsyncOperation );
	PyObject *rc = fInAsyncOp ? Py_True : Py_False;
	return rc;
}
// @pymethod |PyIAsyncOperation|EndOperation|Description of EndOperation.
PyObject *PyIAsyncOperation::EndOperation(PyObject *self, PyObject *args)
{
	IAsyncOperation *pIAO = GetI(self);
	if ( pIAO == NULL )
		return NULL;
	// @pyparm int|hResult||Description for hResult
	// @pyparm <o PyIBindCtx *>|pbcReserved||Description for pbcReserved
	// @pyparm int|dwEffects||Description for dwEffects
	PyObject *obpbcReserved;
	HRESULT hResult;
	IBindCtx * pbcReserved;
	DWORD dwEffects;
	if ( !PyArg_ParseTuple(args, "lOl:EndOperation", &hResult, &obpbcReserved, &dwEffects) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpbcReserved, IID_IBindCtx, (void **)&pbcReserved, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAO->EndOperation( hResult, pbcReserved, dwEffects );
	if (pbcReserved) pbcReserved->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAO, IID_IAsyncOperation );
	Py_INCREF(Py_None);
	return Py_None;
}
// @object PyIAsyncOperation|Description of the interface
static struct PyMethodDef PyIAsyncOperation_methods[] =
{
	{ "SetAsyncMode", PyIAsyncOperation::SetAsyncMode, 1 }, // @pymeth SetAsyncMode|Description of SetAsyncMode
	{ "GetAsyncMode", PyIAsyncOperation::GetAsyncMode, 1 }, // @pymeth GetAsyncMode|Description of GetAsyncMode
	{ "StartOperation", PyIAsyncOperation::StartOperation, 1 }, // @pymeth StartOperation|Description of StartOperation
	{ "InOperation", PyIAsyncOperation::InOperation, 1 }, // @pymeth InOperation|Description of InOperation
	{ "EndOperation", PyIAsyncOperation::EndOperation, 1 }, // @pymeth EndOperation|Description of EndOperation
	{ NULL }
};
PyComTypeObject PyIAsyncOperation::type("PyIAsyncOperation",
		&PyIUnknown::type,
		sizeof(PyIAsyncOperation),
		PyIAsyncOperation_methods,
		GET_PYCOM_CTOR(PyIAsyncOperation));
// ---------------------------------------------------
//
// Gateway Implementation
STDMETHODIMP PyGAsyncOperation::SetAsyncMode(
		/* [in] */ BOOL fDoOpAsync)
{
	PY_GATEWAY_METHOD;
	HRESULT hr=InvokeViaPolicy("SetAsyncMode", NULL, "i", fDoOpAsync);
	return hr;
}
STDMETHODIMP PyGAsyncOperation::GetAsyncMode(
		/* [out] */ BOOL * pfIsOpAsync)
{
	if (!pfIsOpAsync)
		return E_POINTER;
	PY_GATEWAY_METHOD;
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetAsyncMode", &result);
	if (FAILED(hr)) return hr;
	if (!PyInt_Check(result)) {
		PyErr_Format(PyExc_TypeError,
					 "Result for GetAsyncMode must be a bool (got '%s')",
					 result->ob_type->tp_name);
		hr = PyCom_HandlePythonFailureToCOM();
	} else
		// NOTE: MSDN says "VARIANT_TRUE/VARIANT_FALSE, but fails to work!
		*pfIsOpAsync = PyInt_AsLong(result) ? TRUE : FALSE;
	Py_DECREF(result);
	return hr;
}
STDMETHODIMP PyGAsyncOperation::StartOperation(
		/* [optional][unique][in] */ IBindCtx * pbcReserved)
{
	PY_GATEWAY_METHOD;
	PyObject *obpbcReserved;
	obpbcReserved = PyCom_PyObjectFromIUnknown(pbcReserved, IID_IBindCtx, TRUE);
	HRESULT hr=InvokeViaPolicy("StartOperation", NULL, "O", obpbcReserved);
	Py_XDECREF(obpbcReserved);
	return hr;
}
STDMETHODIMP PyGAsyncOperation::InOperation(
		/* [out] */ BOOL * pfInAsyncOp)
{
	if (!pfInAsyncOp)
		return E_POINTER;
	PY_GATEWAY_METHOD;
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("InOperation", &result);
	if (FAILED(hr)) return hr;
	if (!PyInt_Check(result)) {
		PyErr_Format(PyExc_TypeError,
					 "Result for InOperation must be a bool (got '%s')",
					 result->ob_type->tp_name);
		hr = PyCom_HandlePythonFailureToCOM();
	} else
		// NOTE: MSDN says "VARIANT_TRUE/VARIANT_FALSE, but fails to work!
		*pfInAsyncOp = PyInt_AsLong(result) ? TRUE : FALSE;
	Py_DECREF(result);
	return hr;
}
STDMETHODIMP PyGAsyncOperation::EndOperation(
		/* [in] */ HRESULT hResult,
		/* [unique][in] */ IBindCtx * pbcReserved,
		/* [in] */ DWORD dwEffects)
{
	PY_GATEWAY_METHOD;
	PyObject *obpbcReserved;
	obpbcReserved = PyCom_PyObjectFromIUnknown(pbcReserved, IID_IBindCtx, TRUE);
	HRESULT hr=InvokeViaPolicy("EndOperation", NULL, "lOl", hResult, obpbcReserved, dwEffects);
	Py_XDECREF(obpbcReserved);
	return hr;
}
Index: shell.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** shell.cpp	12 Jun 2004 13:27:35 -0000	1.27
--- shell.cpp	2 Jul 2004 04:11:44 -0000	1.28
***************
*** 29,32 ****
--- 29,33 ----
  #include "PyIColumnProvider.h"
  #include "PyIDropTargetHelper.h"
+ #include "PyIAsyncOperation.h"
  
  #include "PythonCOMRegister.h" // For simpler registration of IIDs etc.
***************
*** 402,406 ****
  {
  	PyObject *obVerb;
! 	if (!PyArg_ParseTuple(ob, "iiOzziii", &pci->fMask, &pci->hwnd, 
  	                                 &obVerb, &pci->lpParameters, &pci->lpDirectory, 
  	                                 &pci->nShow, &pci->dwHotKey, &pci->hIcon))
--- 403,407 ----
  {
  	PyObject *obVerb;
! 	if (!PyArg_ParseTuple(ob, "iiOzziii:CMINVOKECOMMANDINFO tuple", &pci->fMask, &pci->hwnd, 
  	                                 &obVerb, &pci->lpParameters, &pci->lpDirectory, 
  	                                 &pci->nShow, &pci->dwHotKey, &pci->hIcon))
***************
*** 810,813 ****
--- 811,816 ----
  }
  
+ #if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+
+ 
  // Callback for BrowseForFolder
  struct PyCallback {
***************
*** 816,819 ****
--- 819,823 ----
  };
  
+ 
  static int CALLBACK PyBrowseCallbackProc(
      HWND hwnd, 
***************
*** 850,853 ****
--- 854,858 ----
  }
  
+ #endif // PY_VERSION_HEX
  //////////////////////////////////////////////////////////////
  //
***************
*** 868,872 ****
--- 873,879 ----
  	bi.pszDisplayName = retPath;
  	LPITEMIDLIST pl = NULL;
+ #if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+
  	PyCallback pycb;
+ #endif
  
  	if(!PyArg_ParseTuple(args, "|lOOlOO:SHBrowseForFolder",
***************
*** 880,883 ****
--- 887,891 ----
  
  	if (obcb != Py_None) {
+ #if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+
  		if (!PyCallable_Check(obcb)) {
  			PyErr_SetString(PyExc_TypeError, "Callback item must None or a callable object");
***************
*** 888,891 ****
--- 896,905 ----
  		bi.lParam = (LPARAM)&pycb;
  		bi.lpfn = PyBrowseCallbackProc;
+ #else // PY_VERSION_HEX
+ 		PyErr_SetString(PyExc_NotImplementedError,
+ 						"Callbacks can only be specified in Python 2.3+");
+ 		return NULL;
+ #endif // PY_VERSION_HEX
+ 		
  	} // else bi.lParam/lpfn remains 0
  	if (!PyObject_AsPIDL(obPIDL, (LPITEMIDLIST *)&bi.pidlRoot, TRUE))
***************
*** 1964,1967 ****
--- 1978,1982 ----
  	PYCOM_INTERFACE_CLSID_ONLY		  (ShellLink),
  	PYCOM_INTERFACE_IID_ONLY		  (ShellLinkW),
+ 	PYCOM_INTERFACE_FULL(AsyncOperation),
  	PYCOM_INTERFACE_FULL(ContextMenu),
  	PYCOM_INTERFACE_FULL(ExtractIcon),
 |