Ejemplo n.º 1
0
PyObject *PyITypeInfo::GetDocumentation(MEMBERID id)
{
	BSTR name, docstring, helpfile;
	unsigned long helpctx;
	ITypeInfo *pMyTypeInfo = GetI(this);
	if (pMyTypeInfo==NULL) return NULL;

	PY_INTERFACE_PRECALL;
	SCODE sc = pMyTypeInfo->GetDocumentation(id, &name, &docstring, &helpctx, &helpfile);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);

	// NOTE - These BSTR's seem not to have a reasonable length.
	// Specifically, DAO3032 leaves crap at the end if we use
	// MakeBSTRToObj.
	PyObject *obName = MakeOLECHARToObj(name);
	PyObject *obDocstring = MakeOLECHARToObj(docstring);
	PyObject *obHelpfile = MakeOLECHARToObj(helpfile);

	PyObject *ret = Py_BuildValue("(OOiO)", obName, obDocstring, helpctx, obHelpfile);

	SysFreeString(name);
	Py_XDECREF(obName);
	SysFreeString(docstring);
	Py_XDECREF(obDocstring);
	SysFreeString(helpfile);
	Py_XDECREF(obHelpfile);

	return ret;
}
Ejemplo n.º 2
0
PyObject *PyITypeLib::GetDocumentation(int pos)
{
	BSTR name, docstring, helpfile;
	unsigned long helpctx;

	ITypeLib *pMyTypeLib = GetI(this);
	if (pMyTypeLib==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	SCODE sc = pMyTypeLib->GetDocumentation(pos, &name, &docstring, &helpctx, &helpfile);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc, pMyTypeLib, IID_ITypeLib);

	PyObject *obName = MakeOLECHARToObj(name);
	PyObject *obDocstring = MakeOLECHARToObj(docstring);
	PyObject *obHelpfile = MakeOLECHARToObj(helpfile);
	PyObject *ret = Py_BuildValue("(OOiO)", obName, obDocstring, helpctx, obHelpfile);

	SysFreeString(name);
	Py_XDECREF(obName);
	SysFreeString(docstring);
	Py_XDECREF(obDocstring);
	SysFreeString(helpfile);
	Py_XDECREF(obHelpfile);
	return ret;
}
Ejemplo n.º 3
0
// IEmptyVolumeCache2
// @object PyIEmptyVolumeCache2|See also <o PyIEmptyVolumeCache>
// @pymeth PyIEmptyVolumeCache|Deactivate
// @pymethod |PyIEmptyVolumeCache2|InitializeEx|
STDMETHODIMP PyGEmptyVolumeCache2::InitializeEx(
		/* [in] */ HKEY hkRegKey,
		/* [in] */ LPCWSTR pcwszVolume,
		/* [in] */ LPCWSTR pcwszKeyName,
		/* [out] */ LPWSTR * ppwszDisplayName,
		/* [out] */ LPWSTR * ppwszDescription,
		/* [out] */ LPWSTR * ppwszBtnText,
		/* [out] */ DWORD * pdwFlags)
{
	PY_GATEWAY_METHOD;
	BOOL bPythonIsHappy = TRUE;
	ULONG dwFlags;
	HRESULT hr;
	PyObject *result;
	PyObject *obppwszDisplayName; 
	PyObject *obppwszDescription;
	PyObject *obppwszBtnText; 
	PyObject *obpcwszVolume = NULL;
	PyObject *obpcwszKeyName = NULL;
	PyObject *obhkRegKey = PyWinObject_FromHKEY(hkRegKey);
	if (!obhkRegKey) goto args_failed;
	if (!(obpcwszVolume = MakeOLECHARToObj(pcwszVolume))) goto args_failed;
	if (!(obpcwszKeyName = MakeOLECHARToObj(pcwszKeyName))) goto args_failed;
	hr=InvokeViaPolicy("InitializeEx", &result, "NNNk", obhkRegKey, obpcwszVolume, obpcwszKeyName, *pdwFlags);
	// NOTE: From here, do *not* exit via args_failed - the args have been cleaned up
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params

	if (!PyTuple_Check(result)) {
		PyErr_Format(PyExc_TypeError, 
				"Initialize must return a tuple of (unicode, unicode, unicode, long) - got '%s'",
				result->ob_type->tp_name);
		bPythonIsHappy = FALSE;
	}
	if (bPythonIsHappy && !PyArg_ParseTuple(result, "OOOl" , &obppwszDisplayName, &obppwszDescription, &obppwszBtnText, &dwFlags))
		bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsWCHAR(obppwszDisplayName, ppwszDisplayName)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsWCHAR(obppwszDescription, ppwszDescription)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsWCHAR(obppwszBtnText, ppwszBtnText)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) hr = PyCom_SetAndLogCOMErrorFromPyException("InitializeEx", IID_IEmptyVolumeCache);
	if (pdwFlags) *pdwFlags = dwFlags;

	Py_DECREF(result);
	return hr;
args_failed:
	// only hit on error convering input args, not normal exit.
	Py_XDECREF(obhkRegKey);
	Py_XDECREF(obpcwszVolume);
	Py_XDECREF(obpcwszKeyName);
	return MAKE_PYCOM_GATEWAY_FAILURE_CODE("InitializeEx");
}
Ejemplo n.º 4
0
// @pymethod |PyIDocHostUIHandler|TranslateUrl|Description of TranslateUrl.
PyObject *PyIDocHostUIHandler::TranslateUrl(PyObject *self, PyObject *args)
{
	IDocHostUIHandler *pIDHUIH = GetI(self);
	if ( pIDHUIH == NULL )
		return NULL;
	// @pyparm int|dwTranslate||Description for dwTranslate
	// @pyparm <o unicode>|pchURLIn||Description for pchURLIn
	PyObject *obpchURLIn;
	DWORD dwTranslate;
	OLECHAR *pchURLIn;
	OLECHAR *pchURLOut = 0;
	if ( !PyArg_ParseTuple(args, "lO:TranslateUrl", &dwTranslate, &obpchURLIn) )
		return NULL;
	if (!PyWinObject_AsWCHAR(obpchURLIn, &pchURLIn))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDHUIH->TranslateUrl( dwTranslate, pchURLIn, &pchURLOut);
	PyWinObject_FreeWCHAR(pchURLIn);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler );
	PyObject *pyretval = MakeOLECHARToObj(pchURLOut);
	CoTaskMemFree(pchURLOut);
	return pyretval;
}
Ejemplo n.º 5
0
// @pymethod |PyIOleObject|GetUserType|Description of GetUserType.
PyObject *PyIOleObject::GetUserType(PyObject *self, PyObject *args)
{
	IOleObject *pIOO = GetI(self);
	if ( pIOO == NULL )
		return NULL;
	// @pyparm int|dwFormOfType||Description for dwFormOfType
	DWORD dwFormOfType;
	LPOLESTR pszUserType;
	if ( !PyArg_ParseTuple(args, "i:GetUserType", &dwFormOfType) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIOO->GetUserType( dwFormOfType, &pszUserType );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return OleSetOleError(hr);
	PyObject *obpszUserType;

	obpszUserType = MakeOLECHARToObj(pszUserType);
	PyObject *pyretval = Py_BuildValue("O", obpszUserType);
	CoTaskMemFree(pszUserType);
	Py_XDECREF(obpszUserType);
	return pyretval;
}
STDMETHODIMP PyGInternetSecurityManager::GetSecurityId(
		/* [in] */ LPCWSTR pwszUrl,
		/* [size_is][out] */ BYTE * pbSecurityId,
		/* [out][in] */ DWORD * pcbSecurityId,
		/* [in] */ DWORD_PTR dwReserved)
{
	PY_GATEWAY_METHOD;
	PyObject *obdwReserved = PyWinObject_FromDWORD_PTR(dwReserved);
	if (obdwReserved==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetSecurityId");
	PyObject *obpwszUrl;
	obpwszUrl = MakeOLECHARToObj(pwszUrl);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetSecurityId", &result, "OlO", obpwszUrl, *pcbSecurityId, obdwReserved);
	Py_XDECREF(obpwszUrl);
	Py_DECREF(obdwReserved);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	void *buf;
	DWORD buf_len;
	if (!PyWinObject_AsReadBuffer(result, &buf, &buf_len)) {
		Py_DECREF(result);
		return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetSecurityId");
	}
	*pcbSecurityId = min(buf_len, *pcbSecurityId);
	memcpy(pbSecurityId, buf, *pcbSecurityId);
	Py_DECREF(result);
	return hr;
}
Ejemplo n.º 7
0
STDMETHODIMP PyGPersistFile::SaveCompleted(
		/* [unique][in] */ LPCOLESTR pszFileName)
{
	PY_GATEWAY_METHOD;
	PyObject *obpszFileName;
	obpszFileName = MakeOLECHARToObj(pszFileName);
	HRESULT hr=InvokeViaPolicy("SaveCompleted", NULL, "O", obpszFileName);
	Py_XDECREF(obpszFileName);
	return hr;
}
Ejemplo n.º 8
0
STDMETHODIMP PyGShellBrowser::SetStatusTextSB(
		/* [unique][in] */ LPCOLESTR pszStatusText)
{
	PY_GATEWAY_METHOD;
	PyObject *obpszStatusText;
	obpszStatusText = MakeOLECHARToObj(pszStatusText);
	HRESULT hr=InvokeViaPolicy("SetStatusTextSB", NULL, "O", obpszStatusText);
	Py_XDECREF(obpszStatusText);
	return hr;
}
Ejemplo n.º 9
0
// @pymethod |PyIDocHostUIHandler|GetHostInfo|Description of GetHostInfo.
PyObject *PyIDocHostUIHandler::GetHostInfo(PyObject *self, PyObject *args)
{
	IDocHostUIHandler *pIDHUIH = GetI(self);
	if ( pIDHUIH == NULL )
		return NULL;
	DOCHOSTUIINFO info;
	memset(&info, 0, sizeof(info));
	info.cbSize = sizeof(info);
	if ( !PyArg_ParseTuple(args, ":GetHostInfo"))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDHUIH->GetHostInfo(&info);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler);
	return Py_BuildValue("iiNN", info.dwFlags, info.dwDoubleClick,
			     MakeOLECHARToObj(info.pchHostCss),
			     MakeOLECHARToObj(info.pchHostNS));
}
Ejemplo n.º 10
0
STDMETHODIMP PyGPersistFile::Save(
		/* [unique][in] */ LPCOLESTR pszFileName,
		/* [in] */ BOOL fRemember)
{
	PY_GATEWAY_METHOD;
	PyObject *obpszFileName;
	obpszFileName = MakeOLECHARToObj(pszFileName);
	HRESULT hr=InvokeViaPolicy("Save", NULL, "Oi", obpszFileName, fRemember);
	Py_XDECREF(obpszFileName);
	return hr;
}
Ejemplo n.º 11
0
STDMETHODIMP PyGPersistFile::Load(
		/* [in] */ LPCOLESTR pszFileName,
		/* [in] */ DWORD dwMode)
{
	PY_GATEWAY_METHOD;
	PyObject *obpszFileName;
	obpszFileName = MakeOLECHARToObj(pszFileName);
	HRESULT hr=InvokeViaPolicy("Load", NULL, "Ol", obpszFileName, dwMode);
	Py_XDECREF(obpszFileName);
	return hr;
}
STDMETHODIMP PyGInternetSecurityManager::SetZoneMapping(
		/* [in] */ DWORD dwZone,
		/* [in] */ LPCWSTR lpszPattern,
		/* [in] */ DWORD dwFlags)
{
	PY_GATEWAY_METHOD;
	return InvokeViaPolicy("SetZoneMapping", NULL, "lNl",
			       dwZone,
			       MakeOLECHARToObj(lpszPattern),
			       dwFlags);
}
STDMETHODIMP PyGInternetSecurityManager::MapUrlToZone(
		/* [in] */ LPCWSTR pwszUrl,
		/* [out] */ DWORD * pdwZone,
		/* [in] */ DWORD dwFlags)
{
	PY_GATEWAY_METHOD;
	PyObject *obpwszUrl;
	obpwszUrl = MakeOLECHARToObj(pwszUrl);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("MapUrlToZone", &result, "Ol", obpwszUrl, dwFlags);
	Py_XDECREF(obpwszUrl);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	if (!PyArg_Parse(result, "l" , pdwZone))
		return MAKE_PYCOM_GATEWAY_FAILURE_CODE("MapUrlToZone");
	Py_DECREF(result);
	return hr;
}
// ---------------------------------------------------
//
// Gateway Implementation
STDMETHODIMP PyGShellIconOverlayManager::GetFileOverlayInfo(
		/* [unique][in] */ LPCWSTR path,
		/* [unique][in] */ DWORD attrib,
		/* [out] */ int __RPC_FAR * index,
		/* [in] */ DWORD flags)
{
	PY_GATEWAY_METHOD;
	PyObject *obpath;
	obpath = MakeOLECHARToObj(path);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetFileOverlayInfo", &result, "Oll", obpath, attrib, flags);
	Py_XDECREF(obpath);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	if (!PyArg_Parse(result, "i" , index)) return PyCom_SetAndLogCOMErrorFromPyException("GetFileOverlayInfo", GetIID());
	Py_DECREF(result);
	return hr;
}
Ejemplo n.º 15
0
STDMETHODIMP PyGDocHostUIHandler::TranslateUrl(
		/* [in] */ DWORD dwTranslate,
		/* [in] */ OLECHAR * pchURLIn,
		/* [out] */ OLECHAR ** ppchURLOut)
{
	PY_GATEWAY_METHOD;
	if (ppchURLOut==NULL) return E_POINTER;
	PyObject *obpchURLIn;
	obpchURLIn = MakeOLECHARToObj(pchURLIn);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("TranslateUrl", &result, "lO", dwTranslate, obpchURLIn);
	Py_XDECREF(obpchURLIn);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	if (!PyWinObject_AsTaskAllocatedWCHAR(result, ppchURLOut, FALSE, NULL))
		hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("TranslateUrl");
	Py_DECREF(result);
	return hr;
}
Ejemplo n.º 16
0
// @pymethod str|PyIPersistFile|GetCurFile|Gets the current name of the file associated with the object.
PyObject *PyIPersistFile::GetCurFile(PyObject *self, PyObject *args)
{
	IPersistFile *pIPF = GetI(self);
	if ( pIPF == NULL )
		return NULL;
	LPOLESTR ppszFileName;
	if ( !PyArg_ParseTuple(args, ":GetCurFile") )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIPF->GetCurFile( &ppszFileName );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile);
	PyObject *pyretval = MakeOLECHARToObj(ppszFileName);
	CoTaskMemFree(ppszFileName);
	return pyretval;
}
Ejemplo n.º 17
0
// @pymethod |PyIDocHostUIHandler|GetOptionKeyPath|Description of GetOptionKeyPath.
PyObject *PyIDocHostUIHandler::GetOptionKeyPath(PyObject *self, PyObject *args)
{
	IDocHostUIHandler *pIDHUIH = GetI(self);
	if ( pIDHUIH == NULL )
		return NULL;
	// @pyparm int|dw||Description for dw
	LPOLESTR pchKey;
	DWORD dw;
	if ( !PyArg_ParseTuple(args, "l:GetOptionKeyPath", &dw) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDHUIH->GetOptionKeyPath( &pchKey, dw );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler );
	PyObject *pyretval = MakeOLECHARToObj(pchKey);
	CoTaskMemFree(pchKey);
	return pyretval;
}
STDMETHODIMP PyGInternetSecurityManager::ProcessUrlAction(
		/* [in] */ LPCWSTR pwszUrl,
		/* [in] */ DWORD dwAction,
		/* [size_is][out] */ BYTE * pPolicy,
		/* [in] */ DWORD cbPolicy,
		/* [in] */ BYTE * pContext,
		/* [in] */ DWORD cbContext,
		/* [in] */ DWORD dwFlags,
		/* [in] */ DWORD dwReserved)
{
	PY_GATEWAY_METHOD;
	PyObject *obpwszUrl;
	PyObject *obContext;
	obpwszUrl = MakeOLECHARToObj(pwszUrl);
	// pContext is documented as being a GUID - but markh has seen IE
	// call this with 78 and 54 bytes in some unusual cases.  So
	// just use 'bytes' and the Python code must use magic to get a GUID.
	if (pContext==NULL) {
		obContext = Py_None;
		Py_INCREF(Py_None);
	} else
		obContext = PyString_FromStringAndSize((char *)pContext, cbContext);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("ProcessUrlAction", &result, "OlOll", obpwszUrl, dwAction, obContext, dwFlags, dwReserved);
	Py_XDECREF(obpwszUrl);
	Py_XDECREF(obContext);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	if (cbPolicy==sizeof(DWORD)) {
		*((DWORD *)pPolicy) = PyInt_AsLong(result);
		if (*((DWORD *)pPolicy)==-1)
			hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("ProcessUrlAction");
	} else {
		PyCom_LoggerWarning(NULL, "PyGInternetSecurityManager::ProcessUrlAction has %d bytes for policy - what is that?", cbPolicy);
		hr = E_UNEXPECTED;
	}
	return hr;
}
Ejemplo n.º 19
0
/**********88
PyObject *PyITypeInfo::GetIDsOfNames(OLECHAR FAR* FAR* names, int count)
{
	ITypeInfo *pMyTypeInfo = GetI(this);
	if (pMyTypeInfo==NULL) return NULL;

	MEMBERID *ids = new MEMBERID[count];
	SCODE sc = pMyTypeInfo->GetIDsOfNames(names, count, ids);
	if (FAILED(sc))
	{
		delete [] ids;
		return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);
	}

	PyObject *ret = PyTuple_New(count);
	for (int i = 0; i < count; i++)
		PyTuple_SetItem(ret, i, PyInt_FromLong(ids[i]));
	
	delete [] ids;
	return ret;
}
**********/
PyObject *PyITypeInfo::GetNames(MEMBERID id)
{
	BSTR names[256];
	unsigned len = 0;
	ITypeInfo *pMyTypeInfo = GetI(this);
	if (pMyTypeInfo==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	SCODE sc = pMyTypeInfo->GetNames(id, names, 256, &len);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);

	PyObject *ret = PyTuple_New(len);
	for (unsigned i = 0; i < len; i++)
	{
		// Again, MAkeBSTRToObj occasionally gives crap at EOS.
		PyObject *obString = MakeOLECHARToObj(names[i]);
		PyTuple_SetItem(ret, i, obString);
		SysFreeString(names[i]);
	}
	
	return ret;
}