Exemplo n.º 1
0
// ---------------------------------------------------
//
// Gateway Implementation
STDMETHODIMP PyGShellItem::BindToHandler(
		/* [unique][in] */ IBindCtx * pbc,
		/* [in] */ REFGUID bhid,
		/* [in] */ REFIID riid,
		/* [iid_is][out] */ void ** ppv)
{
	PY_GATEWAY_METHOD;
	PyObject *obpbc;
	PyObject *obbhid;
	PyObject *obriid;
	obpbc = PyCom_PyObjectFromIUnknown(pbc, IID_IBindCtx, TRUE);
	obbhid = PyWinObject_FromIID(bhid);
	obriid = PyWinObject_FromIID(riid);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("BindToHandler", &result, "OOO", obpbc, obbhid, obriid);
	Py_XDECREF(obpbc);
	Py_XDECREF(obbhid);
	Py_XDECREF(obriid);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	PyObject *obppv;
	if (!PyArg_Parse(result, "O" , &obppv))
		return MAKE_PYCOM_GATEWAY_FAILURE_CODE("BindToHandler");
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obppv, riid, (void **)ppv, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("BindToHandler");
	Py_DECREF(result);
	return hr;
}
Exemplo n.º 2
0
// @pymethod tuple|PyACL|GetAce|Gets an Ace from the ACL
// @rdesc Conventional ACE's (types ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE, SYSTEM_AUDIT_ACE) are returned
// as a tuple of:
// @tupleitem 0|(int, int)|aceType, AceFlags|
// @tupleitem 1|int|Mask|
// @tupleitem 2|<o PySID>|sid|
// <nl>Object ACE's (types ACCESS_ALLOWED_OBJECT_ACE, ACCESS_DENIED_OBJECT_ACE, SYSTEM_AUDIT_OBJECT_ACE)
// are returned as a tuple:
// @tupleitem 0|(int, int)|aceType, AceFlags|
// @tupleitem 1|int|mask|
// @tupleitem 2|<o PyIID>|ObjectType|
// @tupleitem 3|<o PyIID>|InheritedObjectType|
// @tupleitem 4|<o PySID>|sid|
// <nl>For details see the API documentation.
PyObject *PyACL::GetAce(PyObject *self, PyObject *args)
{
	DWORD index;
	ACE_HEADER *pAceHeader;
	LPVOID p;
	PyACL *This = (PyACL *)self;
	// @pyparm int|index||Zero-based index of the ACE to retrieve.
	if (!PyArg_ParseTuple(args, "l:GetAce", &index))
		return NULL;
	if (!::GetAce(This->GetACL(), index, &p))
		return PyWin_SetAPIError("GetAce");
	pAceHeader=(ACE_HEADER *)p;
	switch (pAceHeader->AceType){
		case ACCESS_ALLOWED_ACE_TYPE:
		case ACCESS_DENIED_ACE_TYPE:
		case SYSTEM_AUDIT_ACE_TYPE:
		#ifdef _WIN32_WINNT_LONGHORN
		case SYSTEM_MANDATORY_LABEL_ACE_TYPE:
		#endif
			{
			ACCESS_ALLOWED_ACE *pAce=(ACCESS_ALLOWED_ACE *)p;
			return Py_BuildValue("(ll)lN", pAceHeader->AceType, pAceHeader->AceFlags, pAce->Mask, PyWinObject_FromSID((PSID)(&pAce->SidStart)));
			}
		case ACCESS_ALLOWED_OBJECT_ACE_TYPE:
		case ACCESS_DENIED_OBJECT_ACE_TYPE:
		case SYSTEM_AUDIT_OBJECT_ACE_TYPE:{
			PyObject *obSID, *obObjectType=NULL, *obInheritedObjectType=NULL;
			ACCESS_ALLOWED_OBJECT_ACE *pObjectAce=(ACCESS_ALLOWED_OBJECT_ACE *)p;

			if (!(pObjectAce->Flags&ACE_OBJECT_TYPE_PRESENT)){
				Py_INCREF(Py_None);
				obObjectType=Py_None;
				}
			if (!(pObjectAce->Flags&ACE_INHERITED_OBJECT_TYPE_PRESENT)){
				Py_INCREF(Py_None);
				obInheritedObjectType=Py_None;
				}
			// Struct members float depending on presence of GUIDs !
			if ((obObjectType==Py_None) && (obInheritedObjectType==Py_None))  // neither GUID present, SID will be in first GUID position
				obSID=PyWinObject_FromSID((PSID)&pObjectAce->ObjectType);
			else if ((obObjectType==NULL) && (obInheritedObjectType==NULL)){  // both present, SID in normal place
				obObjectType=PyWinObject_FromIID(pObjectAce->ObjectType);
				obInheritedObjectType=PyWinObject_FromIID(pObjectAce->InheritedObjectType);
				obSID=PyWinObject_FromSID((PSID)&pObjectAce->SidStart);
				}
			else{    // one present in position of first GUID, SID with be in position of second GUID
				obSID=PyWinObject_FromSID((PSID)&pObjectAce->InheritedObjectType);
				if (obObjectType==NULL)
					obObjectType=PyWinObject_FromIID(pObjectAce->ObjectType);
				else
					obInheritedObjectType=PyWinObject_FromIID(pObjectAce->ObjectType);
				}
			return Py_BuildValue("(ll)lNNN", pAceHeader->AceType, pAceHeader->AceFlags, pObjectAce->Mask, 
				obObjectType, obInheritedObjectType, obSID);
			}
		default:
			PyErr_Format(PyExc_NotImplementedError, "Ace type %d is not supported yet", pAceHeader->AceType);
			return NULL;
		}
}
Exemplo n.º 3
0
static PyObject *PyRecord_reduce(PyObject *self, PyObject *args)
{
	PyObject *ret = NULL;
	PyRecord *pyrec = (PyRecord *)self;
	PyObject *obModule = NULL, *obModDict = NULL, *obFunc = NULL;
	ITypeInfo *pti = NULL;
	TYPEATTR *pta = NULL;
	ULONG cb;
	HRESULT hr;
	GUID structguid;
	if (!PyArg_ParseTuple(args, ":reduce"))
		return NULL;
	hr = pyrec->pri->GetTypeInfo(&pti);
	if (FAILED(hr)||pti==NULL) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	hr = pti->GetTypeAttr(&pta);
	if (FAILED(hr)||pta==NULL) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	hr = pyrec->pri->GetGuid(&structguid);
	if (FAILED(hr)) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	hr = pyrec->pri->GetSize(&cb);
	if (FAILED(hr)) {
		PyCom_BuildPyException(hr);
		goto done;
	}
	obModule = PyImport_ImportModule("pythoncom");
	if (obModule)
		obModDict = PyModule_GetDict(obModule); // no ref added!
	if (obModDict)
		obFunc = PyDict_GetItemString(obModDict, "GetRecordFromGuids"); // no ref added!
	if (!obFunc) {
		PyErr_Clear();
		PyErr_SetString(PyExc_RuntimeError, "pythoncom.GetRecordFromGuids() can't be located!");
		goto done;
	}
	ret = Py_BuildValue("O(NHHiNN)",
						obFunc,
						PyWinObject_FromIID(pta->guid),
						pta->wMajorVerNum,
						pta->wMinorVerNum,
						pta->lcid,
						PyWinObject_FromIID(structguid),
						PyString_FromStringAndSize((char *)pyrec->pdata, cb));

done:
	if (pta&& pti)
		pti->ReleaseTypeAttr(pta);
	if (pti) pti->Release();
	Py_XDECREF(obModule);
	// obModDict and obFunc have no new reference.
	return ret;
}
Exemplo n.º 4
0
PyObject *PyMAPIObject_FromMAPINAMEIDArray(MAPINAMEID **pp, ULONG numEntries)
{
    PyObject *ret = PyList_New(numEntries);
    if (ret==NULL) return NULL;
    for (int i=0; (ULONG)i<numEntries; i++) {
        MAPINAMEID *pLook = pp[i];
        PyObject *value, *guid;
        if (pLook==NULL) {
            value = Py_None;
            Py_INCREF(Py_None);
            guid = Py_None;
            Py_INCREF(Py_None);
        } else {
            value = pLook->ulKind==MNID_STRING ?
                    PyWinObject_FromOLECHAR(pLook->Kind.lpwstrName) :
                    PyInt_FromLong(pLook->Kind.lID);
            guid = PyWinObject_FromIID(*pLook->lpguid);
        }
        PyObject *newItem = PyTuple_New(2);
        PyTuple_SetItem(newItem, 0, guid);
        PyTuple_SetItem(newItem, 1, value);
        PyList_SetItem(ret, i, newItem);
    }
    return ret;
}
Exemplo n.º 5
0
// @pymethod <o PyIID>|pythoncom|PropStgNameToFmtId|Converts a property set name to its format id (GUID)
PyObject *pythoncom_PropStgNameToFmtId(PyObject *self, PyObject *args)
{
	// @pyparm string/unicode|Name||Storage stream name
	FMTID fmtid;
	WCHAR *oszName=NULL;
	HRESULT err;
	PyObject *obName=NULL;

	typedef HRESULT (WINAPI * PFNPropStgNameToFmtId)(const LPOLESTR, FMTID*);
	static PFNPropStgNameToFmtId pfnPropStgNameToFmtId=NULL;
	static BOOL pfnchecked=FALSE;
	if (!pfnchecked){
		if (ole32==NULL)
			ole32=GetModuleHandle(_T("Ole32.dll"));
		if (ole32!=NULL)
			pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(ole32, "PropStgNameToFmtId");
		pfnchecked=TRUE;
		}
	if (pfnPropStgNameToFmtId==NULL)
		return PyErr_Format(PyExc_NotImplementedError,"PropStgNameToFmtId is not available on this platform");

	if (!PyArg_ParseTuple(args, "O:PropStgNameToFmtId", &obName))
		return NULL;
	if (!PyWinObject_AsWCHAR(obName,&oszName))
		return NULL;

	PY_INTERFACE_PRECALL;
	err = (*pfnPropStgNameToFmtId)(oszName, &fmtid);
	PY_INTERFACE_POSTCALL;

	PyWinObject_FreeWCHAR(oszName);
	if (err!=S_OK)
		return PyCom_BuildPyException(err);
	return PyWinObject_FromIID(fmtid);
}
Exemplo n.º 6
0
// @object TLIBATTR|Type library attributes are represented as a tuple of:
PyObject *PyITypeLib::GetLibAttr()
{
	TLIBATTR *attr;
	ITypeLib *pMyTypeLib = GetI(this);
	if (pMyTypeLib==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	SCODE sc = pMyTypeLib->GetLibAttr(&attr);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc, pMyTypeLib, IID_ITypeLib);

	PyObject *obIID = PyWinObject_FromIID(attr->guid);
	PyObject *ret = NULL;
	if (obIID!=NULL) {
		ret = Py_BuildValue("Oiiiii",
			obIID,              // @tupleitem 0|<o PyIID>|IID|The IID for the library
			attr->lcid,         // @tupleitem 1|int|lcid|The default locale ID for the library
			attr->syskind,      // @tupleitem 2|int|syskind|Identifies the target operating system platform
			attr->wMajorVerNum,	// @tupleitem 3|int|majorVersion|The major version number of the library
			attr->wMinorVerNum,	// @tupleitem 4|int|minorVersion|The minor version number of the library
			attr->wLibFlags);	// @tupleitem 5|int|flags|Flags for the library.

		Py_DECREF(obIID);
	}
	{
	PY_INTERFACE_PRECALL;
	pMyTypeLib->ReleaseTLibAttr(attr);
	PY_INTERFACE_POSTCALL;
	}
	return ret;
}
Exemplo n.º 7
0
STDMETHODIMP PyGShellItemArray::GetPropertyDescriptionList(
		/* [in] */ REFPROPERTYKEY keyType,
		/* [in] */ REFIID riid,
		/* [iid_is][out] */ void ** ppv)
{
	PY_GATEWAY_METHOD;
	PyObject *obkeyType = PyObject_FromSHCOLUMNID(&keyType);
	if (obkeyType==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetPropertyDescriptionList");
	PyObject *obriid;
	obriid = PyWinObject_FromIID(riid);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetPropertyDescriptionList", &result, "OO", obkeyType, obriid);
	Py_DECREF(obkeyType);
	Py_XDECREF(obriid);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	PyObject *obppv;
	if (!PyArg_Parse(result, "O" , &obppv))
		return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetPropertyDescriptionList");
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obppv, riid, (void **)ppv, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetPropertyDescriptionList");
	Py_DECREF(result);
	return hr;
}
Exemplo n.º 8
0
// @pymethod (<o PyIID>,...)|PyIKnownFolderManager|GetFolderIds|Retrieves all known folder ids.
PyObject *PyIKnownFolderManager::GetFolderIds(PyObject *self, PyObject *args)
{
	IKnownFolderManager *pIKFM = GetI(self);
	if ( pIKFM == NULL )
		return NULL;
	UINT count = 0;
	IID *kfids;
	if ( !PyArg_ParseTuple(args, ":GetFolderIds"))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIKFM->GetFolderIds(&kfids, &count);
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIKFM, IID_IKnownFolderManager );
	PyObject *ret = PyTuple_New(count);
	if (ret){
		for (UINT i=0; i<count; i++){
			PyObject *pyiid = PyWinObject_FromIID(kfids[i]);
			if (pyiid == NULL){
				Py_DECREF(ret);
				ret = NULL;
				break;
				}
			PyTuple_SET_ITEM(ret, i, pyiid);
			}
		}
	CoTaskMemFree(kfids);
	return ret;
}
Exemplo n.º 9
0
static int AddIID(PyObject *dict, const char *key, REFGUID guid)
{
	PyObject *obiid = PyWinObject_FromIID(guid);
	if (!obiid) return 1;
	int rc = PyDict_SetItemString(dict, (char*)key, obiid);
	Py_DECREF(obiid);
	return rc;
}
Exemplo n.º 10
0
// @pymethod <o PyIID>|pywintypes|CreateGuid|Creates a new, unique GUIID.
static PyObject *PyWin_CreateGuid(PyObject *self, PyObject *args)
{
	if (!PyArg_ParseTuple(args, ":CreateGuid"))
		return NULL;
	GUID guid;
	CoCreateGuid(&guid);
	return PyWinObject_FromIID(guid);
}
Exemplo n.º 11
0
STDMETHODIMP PyGPropertyStorage::SetClass(
		/* [in] */ REFCLSID clsid)
{
	PY_GATEWAY_METHOD;
	PyObject *obclsid;
	obclsid = PyWinObject_FromIID(clsid);
	HRESULT hr=InvokeViaPolicy("SetClass", NULL, "O", obclsid);
	Py_XDECREF(obclsid);
	return hr;
}
Exemplo n.º 12
0
// Determine if a gateway has been registered.
int PyCom_IsGatewayRegistered(REFIID iid)
{
	PyObject *keyObject = PyWinObject_FromIID(iid);
	if (!keyObject) 
	{
		return 0;
	}
	int rc = PyMapping_HasKey(g_obPyCom_MapServerIIDToGateway, keyObject);
	Py_DECREF(keyObject);
	return rc;
}
Exemplo n.º 13
0
STDMETHODIMP PyGDocHostUIHandler::TranslateAccelerator(
		/* [in] */ LPMSG lpMsg,
		/* [in] */ const GUID * pguidCmdGroup,
		/* [in] */ DWORD nCmdID)
{
	PY_GATEWAY_METHOD;
	return InvokeViaPolicy("TranslateAccelerator", NULL, "NNl",
				   PyWinObject_FromMSG(lpMsg),
				   PyWinObject_FromIID(*pguidCmdGroup),
				   nCmdID);
}
Exemplo n.º 14
0
// COM Server helpers.
HRESULT PyCom_RegisterGatewayObject(REFIID iid, pfnPyGatewayConstructor ctor, const char *interfaceName)
{
	if (ctor==NULL) return E_INVALIDARG;
	if (g_obPyCom_MapServerIIDToGateway==NULL) {
		g_obPyCom_MapServerIIDToGateway = PyDict_New();
	}
	if (g_obPyCom_MapServerIIDToGateway==NULL) return E_OUTOFMEMORY;
	PyObject *keyObject = PyWinObject_FromIID(iid);
	if (!keyObject) return E_FAIL;

	PyObject *valueObject = PyLong_FromVoidPtr((void *)ctor);

	if (!valueObject) {
		Py_DECREF(keyObject);
		return E_FAIL;
	}
	if (PyDict_SetItem(g_obPyCom_MapServerIIDToGateway, keyObject, valueObject)!=0) {
		Py_DECREF(keyObject);
		return E_FAIL;
	}
	Py_DECREF(valueObject);
	// Now in the other server map.
	if (g_obPyCom_MapGatewayIIDToName) {
		valueObject = PyString_FromString((char *)interfaceName);
		if (!valueObject) {
			Py_DECREF(keyObject);
			return E_FAIL;
		}
		if (PyDict_SetItem(g_obPyCom_MapGatewayIIDToName, keyObject, valueObject)!=0) {
			Py_DECREF(valueObject);
			Py_DECREF(keyObject);
			return E_FAIL;
		}
		Py_DECREF(valueObject);
	}
	// And finally in the map of names to gateway IIDs.
	if (g_obPyCom_MapInterfaceNameToIID) {
		valueObject = PyWinCoreString_FromString(interfaceName);
		if (!valueObject) {
			Py_DECREF(keyObject);
			return E_FAIL;
		}
		// Note we reuse the key as the value, and value as the key!
		if (PyDict_SetItem(g_obPyCom_MapInterfaceNameToIID, valueObject, keyObject)!=0) {
			Py_DECREF(valueObject);
			Py_DECREF(keyObject);
			return E_FAIL;
		}
		Py_DECREF(valueObject);
	}
	Py_DECREF(keyObject);

	return S_OK;
}
Exemplo n.º 15
0
int PyCom_RegisterIIDs( PyObject *dict, const PyCom_InterfaceSupportInfo *pInterfaces, int numEntries)
{
	int i;
	for ( i = numEntries; i--; ) {
		PyObject *newIID = PyWinObject_FromIID(*pInterfaces[i].pGUID);
		if (!newIID) return -1;
		int rc = PyDict_SetItemString(dict, (char *)pInterfaces[i].iidName, newIID);
		Py_DECREF(newIID);
		if (rc!=0) return -1;
	}
	return 0;
}
Exemplo n.º 16
0
// Register a Python on both the UID and Name maps.
int PyCom_RegisterClientType(PyTypeObject *typeOb, const GUID *guid)
{
	if ( guid == NULL )
		return 0;

	PyObject *obiid = PyWinObject_FromIID(*guid);
	if ( !obiid )
		return 1;
	int rc = PyDict_SetItem(g_obPyCom_MapIIDToType, obiid, (PyObject *)typeOb);
	Py_DECREF(obiid);
	return rc;
}
// @pymethod |PyIBackgroundCopyJob|GetId|Description of GetId.
PyObject *PyIBackgroundCopyJob::GetId(PyObject *self, PyObject *args)
{
	IBackgroundCopyJob *pIBCJ = GetI(self);
	if ( pIBCJ == NULL )
		return NULL;
	GUID val;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIBCJ->GetId( &val );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob );
	return PyWinObject_FromIID(val);
}
Exemplo n.º 18
0
// @pymethod <o PyIID>|PyIShellLibrary|GetFolderType|Returns the library type, shell.FOLDERTYPEID_*
PyObject *PyIShellLibrary::GetFolderType(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	FOLDERTYPEID ft;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->GetFolderType(&ft);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	return PyWinObject_FromIID(ft);
}
STDMETHODIMP PyGConnectionPointContainer::FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP)
{
	PY_GATEWAY_METHOD;
	if (ppCP==NULL) return E_POINTER;
	*ppCP = NULL;
	PyObject *obIID = PyWinObject_FromIID(riid);
	PyObject *result;
	HRESULT hr = InvokeViaPolicy("FindConnectionPoint", &result, "O", obIID);
	Py_XDECREF(obIID);
	if (FAILED(hr)) return hr;
	if (result != Py_None && !PyCom_InterfaceFromPyObject(result, IID_IConnectionPoint, (void **)ppCP))
		hr = PyCom_SetCOMErrorFromPyException(GetIID());
	Py_XDECREF(result);
	return (hr==S_OK && *ppCP==NULL) ? CONNECT_E_NOCONNECTION : hr;
}
Exemplo n.º 20
0
// @pymethod <o PyIID>|PyIExplorerCommand|GetCanonicalName|Description of GetCanonicalName.
PyObject *PyIExplorerCommand::GetCanonicalName(PyObject *self, PyObject *args)
{
	IExplorerCommand *pIEC = GetI(self);
	if ( pIEC == NULL )
		return NULL;
	if ( !PyArg_ParseTuple(args, ":GetCanonicalName") )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	GUID guid;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIEC->GetCanonicalName( &guid );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIEC, IID_IExplorerCommand );
	return PyWinObject_FromIID(guid);
}
Exemplo n.º 21
0
// @pymethod <o PyIID>|pythoncom|ReadClassStg|Reads a CLSID from a storage object.
PyObject *pythoncom_ReadClassStg(PyObject *self, PyObject *args)
{
	PyObject *obStg;
	if (!PyArg_ParseTuple(args, "O:ReadClassStg",
					   &obStg)) // @pyparm <o PyIStorage>|storage||The storage to read the CLSID from.
		return NULL;
	IStorage *pStorage;
	if (!PyCom_InterfaceFromPyObject(obStg, IID_IStorage, (void **)&pStorage, FALSE))
		return NULL;
	CLSID clsidRet;
	PY_INTERFACE_PRECALL;
	HRESULT hr = ReadClassStg(pStorage, &clsidRet);
	pStorage->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	return PyWinObject_FromIID(clsidRet);
}
Exemplo n.º 22
0
// @pymethod <o PyIID>|pythoncom|ReadClassStm|Retrieves the CLSID from a stream
PyObject *pythoncom_ReadClassStm(PyObject *self, PyObject *args)
{
	PyObject *obStm;
	if (!PyArg_ParseTuple(args, "O:ReadClassStm",
		&obStm))	// @pyparm <o PyIStream>|Stm||An IStream interface
		return NULL;
	IStream *pStm;
	if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE))
		return NULL;
	CLSID clsidRet;
	PY_INTERFACE_PRECALL;
	HRESULT hr = ReadClassStm(pStm, &clsidRet);
	pStm->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	return PyWinObject_FromIID(clsidRet);
}
Exemplo n.º 23
0
// @pymethod |PyICategoryProvider|GetDefaultCategory|Description of GetDefaultCategory.
PyObject *PyICategoryProvider::GetDefaultCategory(PyObject *self, PyObject *args)
{
	ICategoryProvider *pICP = GetI(self);
	if ( pICP == NULL )
		return NULL;
	if ( !PyArg_ParseTuple(args, ":GetDefaultCategory") )
		return NULL;
	HRESULT hr;
	GUID guid = __uuidof(NULL);
	SHCOLUMNID scid;
	PY_INTERFACE_PRECALL;
	hr = pICP->GetDefaultCategory( &guid, &scid );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICP, IID_ICategoryProvider );
	return Py_BuildValue("NN", PyWinObject_FromIID(guid), PyObject_FromSHCOLUMNID(&scid));
}
// @pymethod <o PyIID>|PyIConnectionPoint|GetConnectionInterface|Retrieves the IID of the interface represented by the connection point.
PyObject *PyIConnectionPoint::GetConnectionInterface(PyObject *self, PyObject *args)
{
	if ( !PyArg_ParseTuple(args, ":GetConnectionInterface") )
		return NULL;

	IConnectionPoint *pICP = GetI(self);
	if ( pICP == NULL )
		return NULL;

	IID iid;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pICP->GetConnectionInterface(&iid);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return SetPythonCOMError(self,hr);

	return PyWinObject_FromIID(iid);
}
Exemplo n.º 25
0
// @pymethod <o PyIID>|PyIPersist|GetClassID|Returns the class identifier (CLSID) for the component object.
PyObject *PyIPersist::GetClassID(PyObject *self, PyObject *args)
{
	if ( !PyArg_ParseTuple(args, ":GetClassID") )
		return NULL;

	IPersist *pIP = GetI(self);
	if ( pIP == NULL )
		return NULL;

	CLSID clsid;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIP->GetClassID(&clsid);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIP, IID_IPersist);

	return PyWinObject_FromIID(clsid);
}
Exemplo n.º 26
0
// @pymethod <o PyIID>|PyIKnownFolderManager|FolderIdFromCsidl|Returns the folder id that corresponds to a CSIDL
PyObject *PyIKnownFolderManager::FolderIdFromCsidl(PyObject *self, PyObject *args)
{
	IKnownFolderManager *pIKFM = GetI(self);
	if ( pIKFM == NULL )
		return NULL;
	// @pyparm int|Csidl||The legacy CSIDL identifying a folder
	int csidl;
	IID kfid;
	if ( !PyArg_ParseTuple(args, "i:FolderIdFromCsidl", &csidl))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIKFM->FolderIdFromCsidl( csidl, &kfid );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIKFM, IID_IKnownFolderManager );
	return PyWinObject_FromIID(kfid);
}
STDMETHODIMP PyGPropertyDescriptionList::GetAt(
	UINT iElem,
	REFIID riid,
	void ** ppv)
{
	PY_GATEWAY_METHOD;

	PyObject *obriid = PyWinObject_FromIID(riid);
	if (obriid==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetAt");
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetAt", &result, "kO", iElem, obriid);
	Py_DECREF(obriid);
	if (FAILED(hr)) return hr;
	if (!PyCom_InterfaceFromPyObject(result, riid, ppv, FALSE))
		hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetAt");
	Py_DECREF(result);
	return hr;
}
Exemplo n.º 28
0
// @pymethod <o PyIID>|propsys|PSLookupPropertyHandlerCLSID|Returns the GUID of the property handler for a file
// @comm If no handler is found, the returned error code can be deceptive as it seems to indicate
//   that the file itself was not found
static PyObject *PyPSLookupPropertyHandlerCLSID(PyObject *self, PyObject *args)
{
	PyObject *obfname;
	TmpWCHAR fname;
	// @pyparm str|FilePath||Name of file
	IID iid;
	if (!PyArg_ParseTuple(args, "O:PSLookupPropertyHandlerCLSID", &obfname))
		return NULL;
	if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = PSLookupPropertyHandlerCLSID(fname, &iid);
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr))
		return PyCom_BuildPyException(hr);
	return PyWinObject_FromIID(iid);
};
Exemplo n.º 29
0
// @pymethod <o PyIID>|PyIDebugDocumentInfo|GetDocumentClassId|Returns a CLSID describing the document type.
PyObject *PyIDebugDocumentInfo::GetDocumentClassId(PyObject *self, PyObject *args)
{
	IDebugDocumentInfo *pIDD = GetI(self);
	if ( pIDD == NULL )
		return NULL;
	if ( !PyArg_ParseTuple(args, ":GetDocumentClassId") )
		return NULL;
	CLSID pclsidDocument;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIDD->GetDocumentClassId( &pclsidDocument );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return SetPythonCOMError(self,hr);

	PyObject *obpclsidDocument = PyWinObject_FromIID(pclsidDocument);
	PyObject *pyretval = Py_BuildValue("O", obpclsidDocument);
	Py_XDECREF(obpclsidDocument);
	return pyretval;
}
// @pymethod |PyISpecifyPropertyPages|GetPages|Description of GetPages.
PyObject *PyISpecifyPropertyPages::GetPages(PyObject *self, PyObject *args)
{
	ISpecifyPropertyPages *pISPP = GetI(self);
	if ( pISPP == NULL )
		return NULL;

	if ( !PyArg_ParseTuple(args, ":GetPages") )
		return NULL;

	CAUUID pages;
    pages.cElems=0;
    pages.pElems=NULL;

    HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISPP->GetPages( &pages );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr);

	PyObject *opages=PyTuple_New(pages.cElems);
    if(!opages)
    {
        ::CoTaskMemFree(pages.pElems);
        return NULL;
    }

    for(unsigned i=0;i<pages.cElems;++i)
    {
        PyObject *sub=PyWinObject_FromIID(pages.pElems[i]);
        if(!sub)
        {
            Py_DECREF(opages);
            ::CoTaskMemFree(pages.pElems);
            return NULL;
        }
		PyTuple_SET_ITEM(opages, i, sub);
    }

    ::CoTaskMemFree(pages.pElems);
    return opages;
}